Bläddra i källkod

Better volume scaling in PassThroughUSB example

dds
PaulStoffregen 7 år sedan
förälder
incheckning
ca594397d7
1 ändrade filer med 9 tillägg och 1 borttagningar
  1. +9
    -1
      examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino

+ 9
- 1
examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino Visa fil

@@ -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);

Laddar…
Avbryt
Spara