瀏覽代碼

Better volume scaling in PassThroughUSB example

dds
PaulStoffregen 8 年之前
父節點
當前提交
ca594397d7
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. +9
    -1
      examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino

+ 9
- 1
examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino 查看文件

@@ -19,9 +19,17 @@ void setup() {
void loop() {
// read the PC's volume setting
float vol = usb1.volume();

// scale to a nice range (not too loud)
// and adjust the audio shield output volume
vol = vol * 0.75;
if (vol > 0) {
// scale 0 = 1.0 range to:
// 0.3 = almost silent
// 0.8 = really loud
vol = 0.3 + vol * 0.5;
}

// use the scaled volume setting. Delete this for fixed volume.
sgtl5000_1.volume(vol);

delay(100);

Loading…
取消
儲存