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