public static void SendSetMessage(FWC.Opcode opcode, uint data1, float data2) { ushort id = msgID++; byte[] msg = new byte[37]; msg[0] = 0xF0; // start byte msg[1] = 0x00; // mfc highest byte msg[2] = 0x00; // mfc high byte msg[3] = 0x41; // mfc low byte byte[] guts = new byte[16]; byte[] temp = new byte[32]; byte[] temp2 = BitConverter.GetBytes(id); temp2.CopyTo(guts, 0); temp2 = BitConverter.GetBytes((uint)opcode); temp2.CopyTo(guts, 4); temp2 = BitConverter.GetBytes(data1); temp2.CopyTo(guts, 8); temp2 = BitConverter.GetBytes(data2); temp2.CopyTo(guts, 12); EncodeBytes(temp, guts); temp.CopyTo(msg, 4); //DebugByte(guts); /*DecodeBytes(guts, temp); * DebugByte(guts);*/ msg[36] = 0xF7; //DebugByte(msg); lock (out_lock_obj) if (Midi.SendLongMessage(midi_out_handle, msg) != 0) { Debug.WriteLine("Error in SendLongMessage"); } }
public static extern int ReadOp(FWC.Opcode opcode, uint data1, uint data2, out float rtn);
public static extern int WriteOp(FWC.Opcode opcode, float data1, uint data2);
public static int ReadOp(FWC.Opcode opcode, uint data1, uint data2, out float rtn) { rtn = 0; return(-1); }
public static int WriteOp(FWC.Opcode opcode, float data1, uint data2) { return(-1); }
public static float SendGetMessageFloat(FWC.Opcode opcode, uint data1, uint data2) { ushort id = msgID++; byte[] msg = new byte[37]; msg[0] = 0xF0; // start byte msg[1] = 0x00; // mfc highest byte msg[2] = 0x00; // mfc high byte msg[3] = 0x41; // mfc low byte byte[] guts = new byte[16]; byte[] temp = new byte[32]; byte[] temp2 = BitConverter.GetBytes(id); temp2.CopyTo(guts, 0); temp2 = BitConverter.GetBytes((uint)opcode); temp2.CopyTo(guts, 4); temp2 = BitConverter.GetBytes(data1); temp2.CopyTo(guts, 8); temp2 = BitConverter.GetBytes(data2); temp2.CopyTo(guts, 12); EncodeBytes(temp, guts); temp.CopyTo(msg, 4); //DebugByte(guts); /*DecodeBytes(guts, temp); * DebugByte(guts);*/ msg[36] = 0xF7; //DebugByte(msg); lock (out_lock_obj) if (Midi.SendLongMessage(midi_out_handle, msg) != 0) { Debug.WriteLine("Error in SendLongMessage"); } int counter = 0; while (counter++ < 100) { if (midi_in_table.ContainsKey(id)) { byte[] buf = (byte[])midi_in_table[id]; midi_in_table.Remove(id); return(BitConverter.ToSingle(buf, 2)); } Thread.Sleep(10); } Debug.WriteLine("Timeout waiting on return Midi message."); /*Midi.MidiInStop(midi_in_handle); * Midi.MidiInReset(midi_in_handle); * Midi.AddSysExBuffer(midi_in_handle); * Midi.MidiInStart(midi_in_handle);*/ return(0); }