3 void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length) {
4 // SEND_STRING("\nTX: ");
5 // for (uint8_t i = 0; i < length; i++) {
6 // send_byte(bytes[i]);
9 uint8_t * precode = malloc(sizeof(uint8_t) * (length + 2));
10 precode[0] = message_type;
11 precode[1] = data_type;
12 memcpy(precode + 2, bytes, length);
13 uint8_t * encoded = malloc(sizeof(uint8_t) * (sysex_encoded_length(length + 2)));
14 uint16_t encoded_length = sysex_encode(encoded, precode, length + 2);
15 uint8_t * array = malloc(sizeof(uint8_t) * (encoded_length + 5));
20 array[encoded_length + 4] = 0xF7;
21 memcpy(array + 4, encoded, encoded_length);
22 midi_send_array(&midi_device, encoded_length + 5, array);
24 // SEND_STRING("\nTD: ");
25 // for (uint8_t i = 0; i < encoded_length + 5; i++) {
26 // send_byte(array[i]);