Not sure I'm posting this in the right place, if there is somewhere better then please let me know!
I've been working on a project (on Teensy 4.1) for a while and am really starting to hit up against RAM/flash limitations, but I still want to squeeze some more code into the flash.
I've used a bunch of obvious tricks to gain back lots of memory so far, but using the Inspect Memory feature in platformio is now point me at the tx/rx buffers of the MIDIDevices as being a good potential way to free up some flash, since the buffers are currently allocated statically, given that each MIDIDevice_BigBuffer uses over 4KB for buffers and I allow for up to 10 USB MIDI devices to be connected to my Teensy.
I've attempted to move the buffer allocation into the MIDIDeviceBase constructor - a patch for this showing what I've done here: https://github.com/doctea/USBHost_t...SBHost_t36:maybe_fixed_4_stable_dynamic.patch
The change basically just removes the static declaration of the buffers and calls calloc() in the constructor instead. I tried first with malloc() but had the same problem.
Although this compiles and runs, it very quickly (within a few seconds of sending data) causes multiple USB MIDI devices to miss or receive garbled messages.
Is there something obvious I'm missing about this approach that might be causing this not to work?
(I've also had to make several modifications to the USBHost_t36 library to get MIDI clock to work, and also some other changes that I believe have improved stability running multiple USB MIDI devices. These changes are in the branch on my fork on github: https://github.com/doctea/USBHost_t36/tree/maybe_fixed_4_stable -- and I've left my app running and controlling multiple MIDI devices for over 12 hours with no problems using this branch.)
Thanks to anyone who may be able to cast some light on this or suggest another way to achieve it!
I've been working on a project (on Teensy 4.1) for a while and am really starting to hit up against RAM/flash limitations, but I still want to squeeze some more code into the flash.
I've used a bunch of obvious tricks to gain back lots of memory so far, but using the Inspect Memory feature in platformio is now point me at the tx/rx buffers of the MIDIDevices as being a good potential way to free up some flash, since the buffers are currently allocated statically, given that each MIDIDevice_BigBuffer uses over 4KB for buffers and I allow for up to 10 USB MIDI devices to be connected to my Teensy.
I've attempted to move the buffer allocation into the MIDIDeviceBase constructor - a patch for this showing what I've done here: https://github.com/doctea/USBHost_t...SBHost_t36:maybe_fixed_4_stable_dynamic.patch
The change basically just removes the static declaration of the buffers and calls calloc() in the constructor instead. I tried first with malloc() but had the same problem.
Although this compiles and runs, it very quickly (within a few seconds of sending data) causes multiple USB MIDI devices to miss or receive garbled messages.
Is there something obvious I'm missing about this approach that might be causing this not to work?
(I've also had to make several modifications to the USBHost_t36 library to get MIDI clock to work, and also some other changes that I believe have improved stability running multiple USB MIDI devices. These changes are in the branch on my fork on github: https://github.com/doctea/USBHost_t36/tree/maybe_fixed_4_stable -- and I've left my app running and controlling multiple MIDI devices for over 12 hours with no problems using this branch.)
Thanks to anyone who may be able to cast some light on this or suggest another way to achieve it!