Jump to content


Please note: You can easily log in to MPN using your Facebook account!

Sending MIDI messages to the MODX in linux


Recommended Posts

Hi,
I wonder if anybody has been able to successfully send MIDI messages over USB using the amidi command in linux. I also asked this in the Yamahamusicians forum, but I am not sure there would be too many linux users there.
I wrote a script that works perfectly fine on a Nord Stage 2, but I cannot make it work on the MODX (where the only difference should be the hardware port where the messages are sent to).
The amidi -l command lists the MODX interface ports as expected:

Dir Device    Name
IO  hw:3,0,0  MODX MIDI 1
IO  hw:3,0,1  MODX MIDI 2
IO  hw:3,0,2  MODX MIDI 3

 

I am assuming that the ports should be accessible to the amidi command, but sending a Note ON message on Channel 1 (or any other) does not seem to work... The relevant lines are:

#!/bin/bash
i=16
vel=127
note=$(printf "%x\n" "$i")
velo=$(printf "%x\n" "$vel")
midi="90 $note $velo"
amidi -p hw:3,0,0 --send-hex=$midi 

 

The MODX is set to USB MIDI, Single Mode, Channel 1.
The only thing I can think of is that in the Nord, the only hw port detected as a single number while in the MODX there are three (I did try hw:3,0,1 and hw:3,0,2, same result).

I appreciate that the MODX and Montage have an "unusual" MIDI implementation, and I wonder if anybody has any additional suggestions.

Thank you.

 

Link to comment
Share on other sites



MODX Owner's Manual, page 56:

 

Quote

MIDI channels and MIDI ports
MIDI data is assigned to one of sixteen channels, and this
synthesizer is capable of simultaneously playing sixteen
separate Parts, via the sixteen MIDI channels. However,
the sixteen-channel limit can be overcome by using
separate MIDI “ports,” each supporting sixteen channels.
While a single MIDI cable is equipped to handle data over
up to sixteen channels simultaneously, a USB connection
is capable of handling far more—thanks to the use of MIDI
ports. Each MIDI port can handle sixteen channels, and
the USB connection allows up to eight ports, letting you
use up to 128 channels (8 ports x 16 channels) on your
computer.


When connecting this instrument to a computer using a
USB cable, the MIDI ports are defined as follows:


Port 1
The tone generator block in this instrument can recognize
and use only this port. When playing the MODX as a tone
generator from the external MIDI instrument or computer,
you should set the MIDI Port to 1 on the connected MIDI
device or computer.


Port 3
This port is used as the MIDI Thru Port. The MIDI data
received over Port 3 via the [USB TO HOST] terminal will
be re-transmitted to an external MIDI device via the MIDI
[OUT] terminal.


The MIDI data received over Port 3 via the MIDI [IN]
terminal will be re-transmitted to an external device
(computer, etc.) via the [USB TO HOST] terminal. When
using a USB connection, make sure to match the MIDI
transmit port and the MIDI receive port as well as the MIDI
transmit channel and the MIDI receive channel. Make sure
to set the MIDI port of the external device connected to this
instrument according to the above information.

 

Link to comment
Share on other sites

MODX Owner's Manual, page 55 -- Set “MIDI IN/OUT” to “USB.”

 

Yeah, I know, it's almost insulting to mention it. But, I have been burned so many times when the MODX isn't listening on the intended physical port: 5-pin vs. USB. 🥵

 

Just by inspection, MIDI note number 16? That seems pretty low for testing purposes. If you send MIDI note 16 to a drum set, for example, you might not get an audible response. Maybe try around middle C (MIDI note number 48 or 60)?

 

As mentioned in my previous post, the first port communicates with the MODX tone generator. I recommend double-checking the settings on the Utility MIDI I/O and Advanced tabs.

 

I agree, if your Linux box can talk to the Nord, it should talk to the MODX. 

 

Good luck and good fortune -- pj

 

  • Like 1
Link to comment
Share on other sites

Thank you @pjd, I was aware of the description of the different ports in the manual and I tried all three visible ports, just in case.

The piece of code above is a simplified version of my script (which is a loop, kind of a sample robot, which sends notes On and Off sequentially over a range of notes). I did try many other higher note values and it is still the same problem.

I am coming to the conclusion that either amidi might be failing to address the MODX port, or I am calling the port incorrectly.

(I note that the manual says that via USB one can use up to 8 ports with 16 channels, but only 3 are visible to amidi).

 

I might explore using a USB-to-5pin MIDI cable and see whether that works, although I ignore which of those cable/interfaces work in linux (I read that many cheap ones do not work properly).

I would be grateful for any other suggestion.

Thanks again.

Link to comment
Share on other sites

Hi --

Saw your messages and replies on Yamaha Musicians Forum. I made similar progress working on a Raspberry Pi. MODX is connected directly to the Pi -- no hub.

Input worked fine as shown below.

    pjd@raspberrypi:~ $ aconnect -l
    client 0: 'System' [type=kernel]
        0 'Timer           '
        1 'Announce        '
    client 14: 'Midi Through' [type=kernel]
        0 'Midi Through Port-0'
    client 24: 'MODX' [type=kernel,card=2]
        0 'MODX MIDI 1     '
        1 'MODX MIDI 2     '
        2 'MODX MIDI 3     '

    pjd@raspberrypi:~ $ amidi -l
    Dir Device    Name
    IO  hw:2,0,0  MODX MIDI 1
    IO  hw:2,0,1  MODX MIDI 2
    IO  hw:2,0,2  MODX MIDI 3

    pjd@raspberrypi:~ $ amidi -p hw:2,0,0 -d

    90 48 3F
    90 48 00
    90 4A 3C
    90 4A 00
    90 47 30
    90 47 00
    90 43 3C
    90 43 00
    90 40 37
    90 40 00
    90 3C 22
    90 3E 22
    90 3E 00
    90 3C 00^C
    42 bytes read

Now the weird part. I ran the dump command, amidi -p hw:2,0,0 -d, in one terminal window and sent Note ON/Note OFF messages from a separate independent terminal window:

    pjd@raspberrypi:~/Notes $ amidi -p hw:2,0,0 -S "90 47 3F"
    pjd@raspberrypi:~/Notes $ amidi -p hw:2,0,0 -S "80 47 0"
    pjd@raspberrypi:~/Notes $ amidi -p hw:2,0,0 -S "90 47 3F"
    pjd@raspberrypi:~/Notes $ amidi -p hw:2,0,0 -S "80 47 0"

Note ON/Note OFF are successful while the dump command is running. Kill the dump command and Note ON/OFF stops working. This behavior is repeatable.

Feel free to post this info to Yamaha Musicians Forum along with a "Hi!" and my regards. I just don't have time to interact on many forums...

 

-- pj

 

Music tech blog: sandsoftwaresound.net
 

  • Like 1
Link to comment
Share on other sites

I'm thinking that the issue is somehow on the Linux side -- as if the ongoing amidi dump establishes a "connection" to the MODX port and the concurrent amidi send commands can exploit the "connection". At this point, I don't have much in the way of working hypotheses. 😞

  • Like 1
Link to comment
Share on other sites

I performed a few more experiments. Connected a Yamaha PSS-A50. It presents only one MIDI port to Linux and worked flawlessly.

 

I connected a MIDI monitor to the MODX 5-pin OUT in order to monitor MIDI THRU behavior (via MODX MIDI port 3). Sent Note ON/OFF to hw:2,0,3 which should be the THRU port (according to the Owner's Manual). I observed similar behavior -- THRU data displays in the monitor when an amidi dump is running concurrently. 

 

I smell a rat on the Linux side and it may be related to the MODX presenting three MIDI ports to Linux...

 

About it for today -- pj

 

  • Like 1
Link to comment
Share on other sites

Hi Mr -G-

 

Spent a few more minutes this morning with experiments. Basically, I confirmed our observations.

 

Tried playing a GM file with aplaymidi. Tried aconnecting vkeybd to the MODX port. No MIDI data is transmitted unless amidi -p hw:2,0,0 -d is running. Weird.

 

Yep, it sounds like a Linux-side issue, not MODX. I would like to use RPi with MODX -- got a few ideas -- and would like to see this work! If I get time later, maybe I'll look at the code for amidi. 

 

Thanks for mentioning this thread on the Yamaha Musicians Forum.

 

-- pj

 

  • Like 1
Link to comment
Share on other sites

Hi again, pjd. The plot thickens (just a bit)... perhaps you saw the message in the other forum stating that the MX49 shows 5 ports and still works fine. Could that be a MODX implementation issue and not just because the number of ports?

 

Link to comment
Share on other sites

Hi Mr -G-

 

Yep, I did see the post about MX. I agree that it shoots down the multiple port hypothesis.

 

I'm keeping an open mind as to root cause -- too easy to go down a rat hole when debugging. So, I'm calling it "a failure to communicate", not an MODX issue per se. We're more likely to get a fix on the Linux side than MODX as I doubt if Yamaha see Linux as important. Ironic, because MODX itself runs Linux ... 😃

 

Can't see which of the squabbling two children are at fault, MODX or Linux. Bugs in Linux? Shocked! Shocked! (Not.)

 

aconnect and amidi detect and show all three MODX ports. I'm wondering if MODX identifies itself differently to Linux than MX (not really knowing how or what a MIDI device reports to Linux when hot plugged.) I still want to look at the amidi code, but I'm running out of time today.

 

There ought to be a way to get this going!

 

-- pj

 

  • Like 1
Link to comment
Share on other sites

Hi --

 

Did a few more simple experiments. I turned LOCAL off and tried a loopback with aconnect, something like "aconnect 24:0 24:0" where 24 is the MODX client. The loopback works fine. Any struck note is returned to the MODX tone generator.

 

I spent about an hour looking at the amidi code. I don't think amidi was intended for anything beyond basic ALSA testing. The internal control flow is a bit baroque. It seems to allow combining -S with -d. So, the command "amidi -p hw:2,0,0 -d -S "90 48 3F"" sends the MIDI note and then awaits bytes from MODX. It actually plays the note!

 

I don't think I would use amidi to send MIDI from a shell script. It might be better to use a simpler program to send MIDI via ALSA without all of the other functional fluff. That would give you a fighting chance to debug the MIDI send issue (if it remains in the new code/program).

 

As to a working hypothesis, I think the sending side hangs (blocks). The dump (-d) code appears to poll the ALSA device and maybe that works around the hang. Might explain why we hear buffered notes when the device finally makes progress.

 

As to why only MODX? Chuh, who knows?

 

All the best -- pj

 

Link to comment
Share on other sites

For those interested, a brief update.

I tried the drumstick program, which is somewhat similar to amidi and sadly it is a similar story. Both the drumstick-metronome and the drumstick-guiplayer work fine with the Nord, but they do not work with the MODX.

drumstick-vpiano does not work either with the MODX. I noted that the port is handled by alsa, so it might be the same problem as before (not being able to deal with the MODX ports).

However, dumping MIDI incoming messages:

drumstick-dumpmid -p MODX:0

works fine.🤔

 

 

Link to comment
Share on other sites

It might be a matter of Midi active sensing, reception may drop if the active sensing message isn't transmitted every so many hundred Milli seconds.

 

I made some Yamaha Midi things, like here

Repeating the Active sensing messages incoming from the Yamaha back into the desired Usb Midi interface might work.

 

T

Link to comment
Share on other sites

Thanks for suggestion! However if that was the case at least the first Note On message should sound and stop about 350ms later? But that does not seem to happen.

There seems to be no way of turning off Active Sensing in the MODX or at least I cannot find how to do it.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...