-
Notifications
You must be signed in to change notification settings - Fork 27
I've been trying to get things set up so I can switch between jukebox mode and regular midi control mode via a digital input. I am able to compile fine with both JUKEBOX and MIDI_VIA_SERIAL2 defined. I was initially just going to put an IF statement in regular_checks() to run jukebox_tick() or MIDI2.read() based on the input value. This works, but adds a static chopping noise to the output. I'm guessing this is some sort of interrupt issue but I'm not sure where to check from here. Any ideas where I should look?
All reactions
It was the ESP core code. Switched to 2.0.17 and everything works as expected. I am even able to put the digitalRead inside the regular_checks() function so I can switch between jukebox and midi mode on the fly. Thank you for the support and for being so responsive!
Replies: 5 comments 4 replies
Please, provide a piece of code that you think to be guilty. It seems that there's no more CPU time to run extra logics.
All reactions
Here was my initial attempt. midijack is set by a digital input in the setup routine. If I manually set midijack to a constant HIGH or LOW I still get significant distortion in the output. I have both MIDI_VIA_SERIAL2 and JUKEBOX defined in the config.h. Is there a different way I should be approaching this switch?
`void regular_checks() {
timer1_fired = false;
#ifdef MIDI_VIA_SERIAL
MIDI.read();
#endif
#ifdef MIDI_VIA_SERIAL2
if (midijack == LOW) MIDI2.read();
#endif
#ifdef JUKEBOX
if (midijack == HIGH) jukebox_tick();
#endif
}`
All reactions
Unfortunately this may be because of 'if' itself. I don't have hardware by me, so I only can suggest the following minimal clean experiment.
//globally
bool sw = true;
//in regularChecks
if (sw) MIDI2.read();
else jukebox_tick();
Also try undefining DEBUG_ON.
Finally if it turns out that it's IF to blame, we can substitute it with a function pointer that changes only when switch state changes, and no logics applied when calling a placeholder function in a loop.
All reactions
Thanks for the suggestions. I had tried the if / else and it causes the same distortion as using two ifs. Double checked all my DEBUGs are undef. I also tried making two different regular_check functions, one for midi control, and one for jukebox and doing the switch there, but that also created distortion. Finally, I tried just running both MIDI2.read() and jukebox_tick() at the same time. I was able to trigger notes via MIDI as the jukebox played, but the distortion was still present.
All reactions
What version of ESP Arduino Core do you use? If it is 3.0.0+ then I would suggest to try your code in 2.0.17 or close to it. I haven't throughly tested 3.x.x.
Also please specify what environment do you have: board, IDE ver., ESP Arduino core ver.?
All reactions
I have ESP core 2.0.11 installed currently, I will bump that up to 2.0.17 and test. My IDE is currently 2.2.1. Hardware is a Wemos / lolin D32 Pro with 8MB of PSRAM. Using a PCM5102 with everything wired to the default pins.
All reactions
BTW, are there some other code changes compared to the original repo?
All reactions
It was the ESP core code. Switched to 2.0.17 and everything works as expected. I am even able to put the digitalRead inside the regular_checks() function so I can switch between jukebox and midi mode on the fly. Thank you for the support and for being so responsive!
All reactions
Great that the solution was so simple