int MIDI_msg_len(uint32_t msg){ int byte1 = MIDI_msg_byte1(msg); R_ASSERT(byte1!=0xf0); R_ASSERT(byte1!=0xf7); if (byte1<0x80 || byte1>0xff){ RT_message("Illegal msg: %x",msg); return 0; } return MidiMessage::getMessageLengthFromFirstByte(byte1); }
static void send_raw_midi_message(struct SoundPlugin *plugin, int64_t block_delta_time, uint32_t msg){ Data *data = (Data*)plugin->data; int cc = MIDI_msg_byte1(msg); int data1 = MIDI_msg_byte2(msg); int data2 = MIDI_msg_byte3(msg); if (cc>=0xe0 && cc<0xf0) { int pitch = (data2<<7) + data1; sendpitchbend(plugin->data, 0, pitch, data->time + block_delta_time); } else if (cc >= 0xb0 && cc <0xc0) sendcontrolchange(data,0,data1,data2, data->time + block_delta_time); }
static void send_raw_midi_message(struct SoundPlugin *plugin, int64_t block_delta_time, uint32_t msg){ uint8_t data[3]; data[0] = MIDI_msg_byte1(msg); data[1] = MIDI_msg_byte2(msg); data[2] = MIDI_msg_byte3(msg); int num_bytes_used; MidiMessage message(data, 3, num_bytes_used, 0); if (num_bytes_used>0) { Data *data = (Data*)plugin->data; MidiBuffer &buffer = data->midi_buffer; buffer.addEvent(message, block_delta_time); } // else // RError("Illegal midi msg: %x",msg); // Well, the illegal message could have been created by a third party plugin. }