Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the MIDIusb support play notes on multiple channels? #139

Open
weshi opened this issue Mar 3, 2023 · 4 comments
Open

Does the MIDIusb support play notes on multiple channels? #139

weshi opened this issue Mar 3, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@weshi
Copy link

weshi commented Mar 3, 2023

Hello,

When I tried to use the MIDIusb class to send notes (by calling the noteON) with different values of channels, it seems that it only worked for channel 0. Is this a known issue?

Thanks,
Wenbo

@chegewara
Copy link
Owner

Hi,
to be honest i had no chance to play with midi too much, as i am not an expert.
Only tests i remember were with android smartphone, but i dont remember what or how it worked.

@weshi
Copy link
Author

weshi commented Mar 6, 2023

Thank you for the quick reply @chegewara.

I did futher investigation and testing, and figured out that it was caused by the way function tud_midi_stream_write was called. Let's take noteON for example:

In your current version, it's defined as:

void MIDIusb::noteON(uint8_t note, uint8_t velocity, uint8_t channel)
{
log_v("ON: %d\n", note);
uint8_t buf[] = {0x90, note, velocity};
tud_midi_stream_write(channel, buf, 3);
}

I looked at the definition of tud_midi_stream_write, the first parameter is: uint8_t cable_num;

I'm not sure what's the definition of this cable num, but if I always pass 0 to it, and OR the channel value to the status byte (i.e., buf[0]), then it worked correctly:

void MIDIusb::noteON(uint8_t note, uint8_t velocity, uint8_t channel)
{
log_v("ON: %d\n", note);
uint8_t buf[] = {(uint8_t)(0x90 | channel), note, velocity};
tud_midi_stream_write(0, buf, 3);
}

Thanks,
Wenbo

@chegewara chegewara added the bug Something isn't working label Mar 6, 2023
@DavidMR91
Copy link

Hello, I would like to ask if this correction has already been implemented, as I am facing the same issue where when I try to use channels other than the default one, the MIDI information transmission fails. Thank you.

@jsonslim
Copy link

In my case the Windows PC recognises the midi device, but no notes are sent, when i call midi.noteOn(), does anyone have this prob?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants