MidiKeyboardComponent "bug"


#1

I found a bug in the MidiKeyboardComponent.   well, more like unexpected behavior

If you place the MidiKeyboardState object AFTER your MidiKeyboardComponent in your custom class, the MidiKeyboardComponent won't display note-on messages from a midi controller properly.   

so always:

class CustomClass {
public: 
  CustomClass() : keyboard(state, MidiKeyboardComponent::horizontalKeyboard) {}
private:
  MidiKeyboardState state;
  MidiKeyboardComponent keyboard;
};

and not 


class CustomClass { 
public: CustomClass() : keyboard(state, MidiKeyboardComponent::horizontalKeyboard) {} 
private: 
  MidiKeyboardComponent keyboard;
  MidiKeyboardState state;  
};

 

When i reorganized my custom class' header file, this ordering bug kept me occupied for a good 2 hours smh

 


#2

That's basic C++: it's the order your members are constructed.

http://stackoverflow.com/questions/1242830/constructor-initialization-list-evaluation-order

Clang will warn about your members being constructed and dependant in a weird way, GCC too I believe (?) - but not any of the MSVC compilers.