Browse Source

Better volume scaling in PassThroughUSB example

dds
PaulStoffregen 7 years ago
parent
commit
ca594397d7
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino

+ 9
- 1
examples/HardwareTesting/PassThroughUSB/PassThroughUSB.ino View File

void loop() { void loop() {
// read the PC's volume setting // read the PC's volume setting
float vol = usb1.volume(); float vol = usb1.volume();

// scale to a nice range (not too loud) // scale to a nice range (not too loud)
// and adjust the audio shield output volume // 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); sgtl5000_1.volume(vol);


delay(100); delay(100);

Loading…
Cancel
Save