Array Format for Sending CC Messages Using .send() #408
-
Hi Everyone! I'm hoping someone may be able to confirm for me the correct array structure and content for sending CC messages using the
method, rather than the
method.
Or is it something else that I haven't thought of yet? Whatever the correct format is, will it give me the same result as using
Sorry if I'm duplicating a question already asked and for the long-winded explanation. For the life of me, I couldn't find the detail I'm after on the website. Any and all help is hugely appreciated and gratefully received. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
If you look at the documentation for the WebMidi.outputs[0].send([176, 9, 64]); |
Beta Was this translation helpful? Give feedback.
-
Thank you for responding so quickly and providing a succinct answer. Thanks, too, for the link to the documentation - brilliant! |
Beta Was this translation helpful? Give feedback.
-
My apologies, I'm still encountering some difficulty with the WebMidi.outputs.send function in my ReactJS app. I can create 2 WebMidi MIDI port objects by selecting them from a populated select box of all available input and output devices and triggering onselect events:
So far, so good. However, for some unknown reason, sending the midiDataArray array, despite being in the format [x, y, z] and all are valid integers, such as those in my previous example (x = 176, y = 9, z = 64), doesn't appear to work:
myOutPort.send( ) does not send a MIDI message, does not trigger an error, does not break the code, nor do I get the console message. It doesn't do anything. Most likely, I'm missing something really obvious that I just can't see. If
|
Beta Was this translation helpful? Give feedback.
-
Hi Jean-Philippe, Thanks again for your speedy reply. You were correct in suspecting there was missing code, so there's no scoping issues. I double checked and both ports are definitely WebMidi objects. The Strangely enough, I swapped WEBMIDI.js flavours from IIFE to ESM using npm and importing WebMidi, and changed the In case you're interested, this gives you some background on what I'm using it for: Thanks for all your assistance. Scott. |
Beta Was this translation helpful? Give feedback.
-
I'm glad you got it working. I checked the provided link and your project seems quite promising. Seeing as you are an academic, you might be interested in a paper I wrote about WEBMIDI.js called: User-Friendly MIDI in the Web Browser. It was published by the NIME conference in 2022. |
Beta Was this translation helpful? Give feedback.
If you look at the documentation for the
Output.send()
method, you will see that it can accept, as its first argument, an array of numbers, aUint8Array
or aMessage
object. If we go with the array, the syntax would be something similar to this: