nathanRamaNoodles / Noodle-Synth

A User-friendly Arduino/Teensy Library to play RTTL/MIDI with infinite polyphonic notes; it has full control over volume, pitch, and music. No shields needed(Just a speaker).
https://create.arduino.cc/projecthub/nathan_ramanathan/play-music-without-delay-40e51b
MIT License
138 stars 14 forks source link

how do I know what note is playing now? #16

Open hdw0 opened 4 years ago

hdw0 commented 4 years ago

I start playing the music sequence. For every note I play, I have to light the right led. As to know what note plays in this moment?

nathanRamaNoodles commented 4 years ago

At this line you can get the current note playing:

noodleSynth->mTrigger(myInstrument, (NOTE_C1 - 1)+((scale - 1) * 12 + note));

You can manually edit the library and create another private variable called uint8_t currentNotePlaying; and set that note as

currentNotePlaying = (NOTE_C1 - 1)+((scale - 1) * 12 + note);

Then in your arduino code, you can do

if(buzzer.currentNotePlaying == NOTE_A1){
    digitalWrite(LED_BUILTIN, HIGH);
}

That's just some pseudo-code though, I'll update the master-branch later. Meanwhile, just edit the library in your own local machine.

hdw0 commented 4 years ago

Thanks very much. Thank you for your responsiveness.