|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
-
-
- #include <SerialFlash.h>
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
-
- #include "guitar_e2_note.h"
- #include "guitar_a2_note.h"
- #include "guitar_d3_note.h"
- #include "guitar_g3_note.h"
- #include "guitar_b3_note.h"
- #include "guitar_e4_note.h"
- #include "tuba_1.h"
- #include "tuba_2.h"
- #include "tuba_3.h"
- #include "tuba_4.h"
- #include "tuba_5.h"
-
- AudioAnalyzeNoteFrequency notefreq;
- AudioOutputAnalog dac;
- AudioPlayMemory wav_note;
- AudioMixer4 mixer;
-
- AudioConnection patchCord0(wav_note, 0, mixer, 0);
- AudioConnection patchCord1(mixer, 0, notefreq, 0);
- AudioConnection patchCord2(mixer, 0, dac, 0);
-
- IntervalTimer playNoteTimer;
-
- void playNote(void) {
- if (!wav_note.isPlaying()) {
-
- wav_note.play(guitar_e2_note);
-
-
-
-
-
-
-
-
-
-
- digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
- }
- }
-
- void setup() {
- AudioMemory(30);
-
-
- notefreq.begin(.15);
- pinMode(LED_BUILTIN, OUTPUT);
-
- playNoteTimer.priority(144);
- playNoteTimer.begin(playNote, 1000);
- }
-
- void loop() {
-
- if (notefreq.available()) {
- float note = notefreq.read();
- float prob = notefreq.probability();
- Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
- }
- }
|