No internet connection
  1. Home
  2. How to

How to send MIDI messages to iCON P1-M Midi Controller

By Nicolas Aparicio @Nicolas_Aparicio
    2024-12-15 02:05:29.806Z

    Hey team,

    I've been trying to control my iCON P1-M Midi Controller through SoundFlow, I've read a few posts but can't pinpoint what I'm missing to make it work.
    Here is the info I've got from the MIDI Studio and Logic's controller assignment section to make the controller bank one track to the right.
    I've tried doing this with sendNote, setting the externalMidiPort to deviceName, "iCON P1-M V1.04 Port 1" or "Port 1"

    Thanks in advance,
    Nic.

    function bankController() {
        // Info of controller from Logic's Midi Assignments 👇
        // 90 31 Lo7 - value change | Note Ch 1, C#2, Lo7 | Bank One Right
    
        // Device name on Mac's MIDI Studio | Port 1
        const deviceName = 'iCON P1-M V1.04 '
    
        sf.midi.sendCC({
            externalMidiPort: deviceName,
            midiChannel: 1,
            midiCC: 31,
            value: 90,
        });
    }
    
    bankController();
    
    • 5 replies
    1. Hi Nic,

      This indicates you need to send a Note On event, not a CC event.

      // 90 31 Lo7 - value change | Note Ch 1, C#2, Lo7 | Bank One Right
      

      0x90 as the first byte indicates Note On, on channel 1.

      sf.midi.sendCC will send a CC event, not a note On event.

      Try using the corresponding action for sending Note On events instead: sf.midi.sendNote

      1. It's important you read midi messages from left to right. The first byte has information about the type of message, and potentially the channel number. The 2nd and 3rd bytes have different meaning depending on the type of message. For Notes, the 2nd byte is the note number, and the 3rd byte the velocity.

        You can investigate more here:
        https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html

        1. This screenshot is all for channel 1 - so the first byte of a Note On message on Channel 1 is 0x90. For Channel 2 that would be 0x91, and so forth.

          1. Sending a Note On message with SF:

            sf.midi.sendNote({
                externalMidiPort: deviceName,
                midiNoteOnOff: 'NoteOn',
                midiChannel: 1,
                midiNote: 0x31, //Assuming the "31" in your comment was hexadecimal, not decimal
                velocity: /* the 'Lo7' placeholder value - this likely refers to the "lower 7 bits" of the value you're trying to set. It needs to be a number between 0 and 127 */0,
            });
            

            Since in your case, you're actually being asked to send raw midi messages that don't really have anything to do with notes, you could also just construct the byte array yourself instead of having to go through two levels of abstractions to get to the end point:

            sf.midi.send({
                externalMidiPort: deviceName,
                midiBytes: [0x90, 0x31, 0 /* some number */],
            });
            

            One more important thing. I'm assuming the notation from your comment was in hexadecimal notation, ie. 0x90, 0x31. These are decimal numbers 144 and 49, respectively. It's important to always prefix hexadecimal notation with "0x" in javascript (and ideally, in documentation such as comments) to avoid confusion.

            1. NNicolas Aparicio @Nicolas_Aparicio
                2024-12-16 21:45:00.807Z

                Oh wow, this is amazing, thanks @chrscheuer!
                Thanks for all the extra info as well, love how you guys always go an extra mile helping out 💪.
                I'll give this a try tonight and let you know how I go.
                Cheers,
                Nic