Bug in MidiMessage?


#1

check out the following snippet.

    std::vector<int> pitches = FretPosition::StringPitches(); // {40,45,50,55,59,64}
    for( int i = pitches[0]; i < pitches[pitches.size()-1]+FretPosition::NumFrets-1; i++ ) { //  < X + 21
        //std::cout << i << "\n";
        MidiMessage m;
        m.noteOn(1, i, 0.5f );    // i = 40 
        std::cout << m.getNoteNumber() << "\n"; //prints out 247.   
    }

 

when i add breakpoints to the m.noteOn line and step thru the code, the 2nd byte in the MidiMessage.PreallocatedData.asBytes is set to 40.

then when I finish stepping thru all of the MidiMessage.cpp code, come back out to this snippet and inspect the variable m, the MidiMessage.preallocatedData.asBytes[1] is set to -9 (displayed as decimal).   What could be causing that value to change from 40 to -9 (or uint 247)?  

What gives? 

 

 


#2

noteOn is a static method, it returns a MidiMessage. The MidiMessage "m" you have there is just junk.

MidiMessage m (MidiMessage::noteOn (1, i, 0.5f));

#3

oh.

my bad for not reading the documentation correctly!