X.isController() returns false after x.controllerEvent()


#1

I’m trying to create a MidiMessage.controllerEvent(), and then use it to hold older CC events that are coming through. The problem is that when I create an empty MIDI event, and then try to create the CC message, its not testing as a CC message using isController(). Any thoughts? here is my dirty little test code, it prints fail every time.

MidivsttestAudioProcessor::MidivsttestAudioProcessor() :
lastMidiMessage(0xf4),
stepSize(96.0)
{
    lastMidiMessage.controllerEvent(1, 14, 127);
    if(lastMidiMessage.isController()) {
        DBG("win!");
    } else {
        DBG("fail :(");

        unsigned char *data;
        
        data = lastMidiMessage.getRawData();
        unsigned char byte1 = *data;
        *data++;
        unsigned char byte2 = *data;
        *data++;
        unsigned char byte3 = *data;
        
        DBG("HEX: " + String(byte1) + " " + String(byte2)  + " " + String(byte3));
    }
}

#2

controllerEvent is a static method!


#3

Sweet! I didn’t fully understand the “static” thing yet, but that makes a lot of sense now. I fixed it below with this code

MidivsttestAudioProcessor::MidivsttestAudioProcessor() : lastMidiMessage(MidiMessage::controllerEvent(1, 14, 127)), stepSize(96.0) { }