Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

42 rindas
1.1KB

  1. #include <Audio.h>
  2. #include <Wire.h>
  3. #include <SPI.h>
  4. #include <SD.h>
  5. #include <SerialFlash.h>
  6. AudioInputUSB usb1; //xy=200,69 (must set Tools > USB Type to Audio)
  7. AudioOutputI2S i2s1; //xy=365,94
  8. AudioConnection patchCord1(usb1, 0, i2s1, 0);
  9. AudioConnection patchCord2(usb1, 1, i2s1, 1);
  10. AudioControlSGTL5000 sgtl5000_1; //xy=302,184
  11. void setup() {
  12. AudioMemory(12);
  13. sgtl5000_1.enable();
  14. sgtl5000_1.volume(0.6);
  15. }
  16. void loop() {
  17. // read the PC's volume setting
  18. float vol = usb1.volume();
  19. // scale to a nice range (not too loud)
  20. // and adjust the audio shield output volume
  21. if (vol > 0) {
  22. // scale 0 = 1.0 range to:
  23. // 0.3 = almost silent
  24. // 0.8 = really loud
  25. vol = 0.3 + vol * 0.5;
  26. }
  27. // use the scaled volume setting. Delete this for fixed volume.
  28. sgtl5000_1.volume(vol);
  29. delay(100);
  30. }
  31. // Teensyduino 1.35 & earlier had a problem with USB audio on Macintosh
  32. // computers. For more info and a workaround:
  33. // https://forum.pjrc.com/threads/34855-Distorted-audio-when-using-USB-input-on-Teensy-3-1?p=110392&viewfull=1#post110392