Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

10 лет назад
10 лет назад
10 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* DAP AVC example; AVC is SGTL5000 equiv of AGC
  2. This example code is in the public domain
  3. */
  4. #include <Audio.h>
  5. #include <Wire.h>
  6. #include <SPI.h>
  7. #include <SD.h>
  8. #include <SerialFlash.h>
  9. const int myInput = AUDIO_INPUT_LINEIN;
  10. // const int myInput = AUDIO_INPUT_MIC;
  11. // Create the Audio components. These should be created in the
  12. // order data flows, inputs/sources -> processing -> outputs
  13. //
  14. AudioInputI2S audioInput; // audio shield: mic or line-in
  15. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  16. // Create Audio connections between the components
  17. //
  18. AudioConnection c1(audioInput, 0, audioOutput, 0); // left passing through
  19. AudioConnection c2(audioInput, 1, audioOutput, 1); // right passing through
  20. // Create an object to control the audio shield.
  21. //
  22. AudioControlSGTL5000 audioShield;
  23. void setup() {
  24. // Audio connections require memory to work. For more
  25. // detailed information, see the MemoryAndCpuUsage example
  26. AudioMemory(4);
  27. // Enable the audio shield and set the output volume.
  28. audioShield.enable();
  29. audioShield.inputSelect(myInput);
  30. audioShield.volume(0.5);
  31. audioShield.audioPreProcessorEnable();
  32. // here are some settings for AVC that have a fairly obvious effect
  33. audioShield.autoVolumeControl(2,1,0,-5,0.5,0.5); // see comments starting line #699 of control_sgtl5000.cpp in ./libraries/audio/
  34. // AVC has its own enable/disable bit
  35. // you can use audioShield.autoVolumeEnable(0); to turn off AVC
  36. }
  37. elapsedMillis chgMsec=0;
  38. float lastVol=1024;
  39. void loop() {
  40. // every 10 ms, check for adjustment
  41. if (chgMsec > 10) {
  42. float vol1=analogRead(15)/1023.0;
  43. vol1=(int)vol1;
  44. if(lastVol!=vol1)
  45. {
  46. audioShield.volume(vol1);
  47. lastVol=vol1;
  48. }
  49. chgMsec = 0;
  50. }
  51. }