示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func ctrl1(c Controller, lauter bool) {
	//
	switch c {
	case Left:
		if lauter {
			if volume_left < MaxVol {
				volume_left++
			}
		} else {
			if volume_left > 0 {
				volume_left--
			}
		}
	case Right:
		if lauter {
			if volume_right < MaxVol {
				volume_right++
			}
		} else {
			if volume_right > 0 {
				volume_right--
			}
		}
	case Balance:
		if lauter {
			if volume_left < MaxVol {
				volume_left++
			}
			if volume_right > 0 {
				volume_right--
			}
		} else {
			if volume_right < MaxVol {
				volume_right++
			}
			if volume_left > 0 {
				volume_left--
			}
		}
	case All:
		if lauter {
			if volume_left < MaxVol {
				volume_left++
			}
			if volume_right < MaxVol {
				volume_right++
			}
		} else {
			if volume_left > 0 {
				volume_left--
			}
			if volume_right > 0 {
				volume_right--
			}
		}
	}
	C.volCtrl(C.int(cdd), C.uchar(volume_left), C.uchar(volume_right))
	balance = Volume(Balance)
}
示例#2
0
文件: imp.go 项目: CaptainSoOmA/Uni
func ctrl(c Controller, i uint8) {
	//
	l, r, j := uint(volume_left), uint(volume_right), uint(i)
	sum := l + r
	mid := sum / 2
	switch c {
	case Left:
		l = j
	case Right:
		r = j
	case Balance:
		if i == 0 {
			l, r = sum, 0
		} else if j == MaxVol {
			l, r = 0, sum
		} else {
			r = (sum * j) / MaxVol
			l = sum - r
		}
	case All:
		if l == r {
			l, r = j, j
		} else {
			l += j
			if l >= mid {
				l -= mid
			} else {
				l = 0
			}
			r += j
			if r >= mid {
				r -= mid
			} else {
				r = 0
			}
		}
	}
	if l > MaxVol {
		l = MaxVol
	}
	if r > MaxVol {
		r = MaxVol
	}
	volume_left, volume_right = uint8(l), uint8(r)
	C.volCtrl(C.int(cdd), C.uchar(volume_left), C.uchar(volume_right))
	balance = Volume(Balance)
}