electro-smith / DaisyExamples

Examples for the Daisy Platform
https://github.com/electro-smith/DaisyWiki/wiki
MIT License
372 stars 193 forks source link

WIP: Patch/Nimbus: Midi Support #200

Open baumgartnerniels opened 3 years ago

baumgartnerniels commented 3 years ago

Hi

I'm working on a feature to control all the parameters in the Nimbus Firmware with midi.

I'm marking this as Work in Progress, as the midi handling in the current libdaisy is a bit buggy. Never the less, here is a first working draft. It will work as long as there are no Midi RealTime (clock) messages coming in. Otherwise (and that is usually the case when connecting a midi sequencer) the Midi parser in libdaisy has to be patched to ignore the buggy clock messages. I saw a bit too late that there is a PR https://github.com/electro-smith/libDaisy/pull/350 fixing the Midi parser. I think it makes sense to change this to use the new parser as soon as the mentioned PR is merged.

If you want to test this out in the meantime, here is the midi parser patch:

diff --git a/src/hid/midi.cpp b/src/hid/midi.cpp
index 1df5860..7cb4ec4 100644
--- a/src/hid/midi.cpp
+++ b/src/hid/midi.cpp
@@ -77,8 +77,10 @@ void MidiHandler::Parse(uint8_t byte)
     switch(pstate_)
     {
         case ParserEmpty:
+            // ignore single-byte realtime (Clock) messages
+            if (byte == kRealTimeMask) {}
             // check byte for valid Status Byte
-            if(byte & kStatusByteMask)
+            else if(byte & kStatusByteMask)
             {
                 // Get MessageType, and Channel
                 incoming_message_.channel = byte & kChannelMask;
stephenhensley commented 3 years ago

just marked as a draft since you have it marked as WIP. Feel free to mark it as ready to review when it's ready 😄

stephenhensley commented 3 years ago

Also, we'll be reviewing, and getting the MidiHandler updates merged into libdaisy (and the examples here) sometime next week. Since I know this is semi-dependent on that, that I'd give you an update since that PRs been sitting for a little.

stephenhensley commented 2 years ago

@baumgartnerniels It's been a little bit, but I just wanted to ping you to see if you had any interest in picking this back up?

All the MIDI stuff you were initially waiting on should be resolved (this could actually work with UART and/or USB MIDI now as well).

baumgartnerniels commented 2 years ago

Hi @stephenhensley Right! Sorry, I kind of forgot about this as i just quickly patched the missing bits back then and flashed it to my unit. I'm in the middle of an exam period atm. But I could probably clean this up sometime in january/february.

stephenhensley commented 2 years ago

@baumgartnerniels sounds good!

No worries. I just wanted to ping since the PR has been sitting for a while, and it is certainly a very cool feature!

Thanks!

pagarreton commented 3 months ago

hello, did anyone try to add midi support to Nimbus?