Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Simple_Sine.ino 2.0KB

9 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. C C# D Eb E F F# G G# A Bb B
  3. 0 16.35 17.32 18.35 19.45 20.60 21.83 23.12 24.50 25.96 27.50 29.14 30.87
  4. 1 32.70 34.65 36.71 38.89 41.20 43.65 46.25 49.00 51.91 55.00 58.27 61.74
  5. 2 65.41 69.30 73.42 77.78 82.41 87.31 92.50 98.00 103.8 110.0 116.5 123.5
  6. 3 130.8 138.6 146.8 155.6 164.8 174.6 185.0 196.0 207.7 220.0 233.1 246.9
  7. 4 261.6 277.2 293.7 311.1 329.6 349.2 370.0 392.0 415.3 440.0 466.2 493.9
  8. 5 523.3 554.4 587.3 622.3 659.3 698.5 740.0 784.0 830.6 880.0 932.3 987.8
  9. 6 1047 1109 1175 1245 1319 1397 1480 1568 1661 1760 1865 1976
  10. 7 2093 2217 2349 2489 2637 2794 2960 3136 3322 3520 3729 3951
  11. 8 4186 4435 4699 4978 5274 5588 5920 6272 6645 7040 7459 7902
  12. Guitar strings are E2=82.41Hz, A2=110Hz, D3=146.8Hz, G3=196Hz, B3=246.9Hz, E4=329.6Hz
  13. Bass strings are (5th string) B0=30.87Hz, (4th string) E1=41.20Hz, A1=55Hz, D2=73.42Hz, G2=98Hz
  14. You can change the frequency by typing "f " + frequency in the serial monitor.
  15. EX. "f 30.87"
  16. You can change the amplitude by typing "a " + amplitude in the serial monitor. (0,1)
  17. EX. "a .5"
  18. */
  19. #include <AudioTuner.h>
  20. #include <Audio.h>
  21. #include <Wire.h>
  22. #include <SPI.h>
  23. #include <SD.h>
  24. AudioTuner tuner;
  25. AudioSynthWaveformSine sine;
  26. AudioOutputAnalog dac;
  27. AudioMixer4 mixer;
  28. AudioConnection patchCord1(sine, 0, mixer, 0);
  29. AudioConnection patchCord2(mixer, 0, tuner, 0);
  30. AudioConnection patchCord3(mixer, 0, dac, 0);
  31. // hold serial commands
  32. char buffer[10];
  33. void setup() {
  34. // put your setup code here, to run once:
  35. AudioMemory(4);
  36. sine.frequency(30.87);
  37. sine.amplitude(1);
  38. }
  39. void loop() {
  40. // put your main code here, to run repeatedly:
  41. if (tuner.available()) {
  42. float note = tuner.read();
  43. float prob = tuner.probability();
  44. Serial.printf("Note: %3.2f | Probility: %.2f\n", note, prob);
  45. }
  46. if (Serial.available()) {
  47. Serial.readBytesUntil('\n', buffer, 10);
  48. handleCmds( buffer );
  49. }
  50. }