This is an incredible feature within the ZGameEditor. In this video I will show you how to link midi data to your music visualizations. We will link note on off data to turn an object light on/off for a 3d sphere and also use midi keys to move the object in all directions. The concept of status messages and other events like volume,panning, and velocity is also explained.
To monitor midi messages.
Code: Select all
void OnMidiMessage(int Status, int Data1, int Data2)
{
trace("Status="+IntToStr(Status));
trace("Data1="+IntToStr(Data1));
trace("Data2="+IntToStr(Data2));
}
This is a special case where the Data1 and Data2 need to be combined to a 14-bit value between 0..16383.
This function does the trick:
Code: Select all
int PitchBytes(int First, int Second)
{
int data14bit;
data14bit = Second;
data14bit = data14bit << 7;
data14bit = data14bit|First;
return data14bit;
}
Code: Select all
//use function to convert data1 and data2 to a standard 14bit value.
float Pitch=PitchBytes(MidiData1,Mididata2);
//for use you can rescale values to suite your needs, this sets a range of -127 to 127
int PitchScaled=floor(((Pitch-8192)/16383)*127*2);