For test purposes in handleMidiOn() I switch on an LED which I switch off in handleNoteOff(). As soon as I start sending midi notes to the Daisy, the led starts to flash according to the notes I send. Nice!
However, when I add a callback for audio processing to setup(),
DAISY.begin(AudioCallback);
the midi notes are not processed anymore, or at least I do not see the LEDs flashing (the audio is processed though). Is this to be expected or do I have to handle the MIDI.begin and DAISY.begin differently?
If I change the sequence of commands, so start the audio callback before the midi callback, then only the audio callback is running. Do I need to chain them in some sort of way?
I would suggest that for questions like this, it is best to post a complete program demonstrating your problem. Reduce the program to the minimum needed.
In fact, on the Teensy forum, this is a strict rule. It saves a lot of unnecessary back and forth dialog.
The program is much too large (and has a lot of code files that need to be linked) to be posted even in a reduced size. Therefore I ended with the question whether the callbacks need to be chained or not? Basically I’m wondering how the callback mechanism works. E.g. what will happen if the AudioCallBack takes too long to do its thing between consecutive samples / buffers. Will it be interrupted by the next start of the callback routine? And does the same go for the midi call back routine?
Now I’m more confused. DaisyDuino/examples/Pod/Midi/Midi.ino works for me, and it uses Audio callback , and MIDI.setHandleNoteOn(handleNoteOn). Then I added a call to set a NoteOff handler, and it works correctly.
So I’m back to wondering, what is different in your program? Are you calling MIDI.read() in the loop()?
Yes, I am. But I’m getting a feeling that my AudioCallback routine takes up too much time.
I have the same processing code without the midi part running just fine when I compile it without the Arduino IDE using a Makefile, so I’m wondering whether compiling in the IDE produces code that runs less efficient.
The code is not exactly the same as I’m having trouble adding the MIDI.h to the Makefile code and I am not using the “DaisyDuino.h” because I do not seem to need it. So I’ve not been able to run the midi code using the Makefile setup. But the audio processing works well and is free of distortion when I’m running that code.