You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * AK4558 Sine Out Test
  3. * 2015 by Michele Perla
  4. *
  5. * A simple hardware test which sends two 440 Hz sinewaves to the
  6. * LOUT/ROUT pins of the HiFi Audio CODEC Module. One of the waves
  7. * is out-of-phase by 90° with the other.
  8. *
  9. */
  10. #include <Audio.h>
  11. #include <Wire.h>
  12. #include <SPI.h>
  13. #include <SD.h>
  14. #include <SerialFlash.h>
  15. AudioSynthWaveformSine sine2;
  16. AudioSynthWaveformSine sine1;
  17. AudioOutputI2S i2s1;
  18. AudioConnection patchCord1(sine2, 0, i2s1, 0);
  19. AudioConnection patchCord2(sine1, 0, i2s1, 1);
  20. AudioControlAK4558 ak4558;
  21. int phase = 0;
  22. void setup() {
  23. // put your setup code here, to run once:
  24. AudioMemory(12);
  25. while (!Serial);
  26. ak4558.enable();
  27. ak4558.enableOut();
  28. AudioNoInterrupts();
  29. sine1.frequency(440);
  30. sine2.frequency(440);
  31. sine1.amplitude(1.0);
  32. sine2.amplitude(1.0);
  33. AudioInterrupts();
  34. }
  35. void loop() {
  36. phase+=10;
  37. if (phase==360) phase=0;
  38. AudioNoInterrupts();
  39. sine2.phase(phase);
  40. AudioInterrupts();
  41. delay(250);
  42. }