Hey everyone!
I'm brand new to JUCE, I'd just like to say that it's amazing how relatively painless getting everything set up with the IntroJucer and VS2013 was. It's an extraordinarly impressive framework.
Anyways, I'm making a simple VST that turns a Novation Launchpad into a spectrum analyzer. It basically just does a FFT, does some processing to downsample the results to something that can be displayed on an 8 x 8 grid, then dumps that out via MIDI note on messages to activate the Launchpad's LEDs.
I've got everything working nicely, except I've run into a snag where dumping out more than around 50 MIDI messages per second starts spiking the CPU like crazy. I've narrowed it down to the MIDI output being the problem; if I change the MIDI out port on the VST wrapper so that it's not sending to my Launchpad, CPU use is negligable as I would expect. Just in general, the MIDI output seems to be using way more cycles than it should.
I'm likely doing something wrong, but I haven't been able to figure out what's going on. Here's a snippet of my code that's generating the MIDI output:
void LaunchpadLightsAudioProcessor::dumpGridStateToMidi(MidiBuffer& midiMessages) { midiMessages.clear(); midiMessages.ensureSize(3 * (64 + 2)); for (int row = 0; row < 8; ++row) { for (int col = 0; col < 8; ++col) { if (colorGrid[row][col] != lastColorGrid[row][col]) { MidiMessage ledUpdate(144, rowColToMidiNote[row][col], colorGrid[row][col]); ledUpdate.setChannel(1); midiMessages.addEvent(ledUpdate, midiMessages.getLastEventTime() + 1); lastColorGrid[row][col] = colorGrid[row][col]; } } } }
Any kind of help or direction is appreciated!
Some other potentially relevant info:
- That method is being called from processBlock, but not on every processBlock, it's called about 24 times per second.
- 32-bit Windows VST2
- Host is FL Studio 11 32 bit
- According to the Launchpad Programmer's Reference Guide, "Launchpad uses a low-speed version of USB. A limitation of this is that it accepts a maximum of 400 messages per second."