how can I send a midi command from bash through jack to my HW controller?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

how can I send a midi command from bash through jack to my HW controller?

Athanasios Silis
Hi all,
I have a BCR2000 and would like to use a script to set some values on these knobs and buttons.

amidi should be able to help me do that but I somehow cannot properly set the name of the port in order to use it. Note, jackd server is up and running and then I also use the "aj2midid" midi bridge to populate hw and software midi ports in jack,

So even though I thought this would be easy , I am stuck somewhere.

The command I am trying to use is
amidi -p"14:0" -S <3x bytes depicting the midi CC command>

now port "14" SHOULD be the "Midi Through port as it appears in qjackctl's "midi" tab. I got it from
$ aconnect -i -o
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 16: 'TerraTec DMX6Fire' [type=kernel]
    0 'MIDI-Front DMX6fire 0'
   32 'Wavetable DMX6fire 0'
client 24: 'Hoontech SoundTrack Audio DSP24' [type=kernel]
    0 'MIDI-1 Hoontech/STA DSP24 2'
   32 'MIDI-2 Hoontech/STA DSP24 2'
client 28: 'Hoontech SoundTrack Audio DSP24' [type=kernel]
    0 'MIDI-1 Hoontech/STA DSP24 3'
   32 'MIDI-2 Hoontech/STA DSP24 3'
client 32: 'BCR2000' [type=kernel]
    0 'BCR2000 MIDI 1  '
    1 'BCR2000 MIDI 2  '
    2 'BCR2000 MIDI 3  '

but running "amidi -p14:0 -S <hexbytes>" returns
cannot open port "14:0": No such file or directory

What am I doing wrong?

thank you in advance for your help


_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Len Ovens
On Sun, 8 Oct 2017, Athanasios Silis wrote:

> Hi all,
> I have a BCR2000 and would like to use a script to set some values on these knobs
> and buttons.
>
> amidi should be able to help me do that but I somehow cannot properly set the
> name of the port in order to use it. Note, jackd server is up and running and
> then I also use the "aj2midid" midi bridge to populate hw and software midi ports
> in jack,

I think in this case a2jmidid would have to be off. amidi uses alsa midi,
not jack midi so far as I know. (I could be wrong, try using the alsa
ports first)

> The command I am trying to use is
> amidi -p"14:0" -S <3x bytes depicting the midi CC command>
>
> now port "14" SHOULD be the "Midi Through port as it appears in qjackctl's "midi"
> tab. I got it from

qjackctl's midi tab is jack midi ports. To see alsa midi ports look at the
alsa tab.

> client 32: 'BCR2000' [type=kernel]
>     0 'BCR2000 MIDI 1  '
>     1 'BCR2000 MIDI 2  '
>     2 'BCR2000 MIDI 3  '
>
> but running "amidi -p14:0 -S <hexbytes>" returns
> cannot open port "14:0": No such file or directory

maybe try 32:0?


--
Len Ovens
www.ovenwerks.net

_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Jeanette C.
In reply to this post by Athanasios Silis
Oct 8 2017, Athanasios Silis has written:
...
> amidi -p"14:0" -S <3x bytes depicting the midi CC command>
...
Hi Athanasios,
amidi uses ALSA hardware ports, not ALSA SEQuencer ports. On my system
MIDI thru doesn't show up under those. You can list them with:
amidi -l
or look at:
/proc/asound/cards

Since you're sending MIDI CCs and no SysEx you can use a tool that
supports ALSA SEQ ports.

If your CCs and values are always the same - or just a few setups - you
could put them inside a MIDI file and then use aplaymidi. Otherwise
there is midish a commandline tool, that supports its own bash-like
scripting. It wouldn't be too hard to set something like this up.
http://www.midish.org

If Python or other scripting languages are an option, there are some
packages for these languages which support ALSASEQ I/O. If midish looks
promising, but too much work for a start, I could help.

HTH.

Best wishes,

Jeanette

--------
* website: http://juliencoder.de - for summer is a state of sound
* SoundCloud: https://soundcloud.com/jeanette_c

... About some useless information,
Supposed to fire my imagination <3
(Britney Spears)
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Athanasios Silis
Hi all and thank you for your immediate responses.
In the end what I was looking for was not the "midi through port" but a virtual midi port.
To do that I had to add in /etc/modules-load.d/audio.conf
snd-virmidi midi_devs=1 index=5

then I could see
$ amidi -l
Dir Device    Name
..... (other devices) .....
IO  hw:5,0    Virtual Raw MIDI (16 subdevices)

and at the same time it would show up in jack's "midi" tab
then I could simply use it as

amidi -phw:5,0 -S <hexbytes>

and the midi msg was surely enough sent correctly to the HW controller.

Thank you for your help!
I hope this helps others as well

On Sun, Oct 8, 2017 at 2:50 AM, Jeanette C. <[hidden email]> wrote:
Oct 8 2017, Athanasios Silis has written:
...
amidi -p"14:0" -S <3x bytes depicting the midi CC command>
...
Hi Athanasios,
amidi uses ALSA hardware ports, not ALSA SEQuencer ports. On my system
MIDI thru doesn't show up under those. You can list them with:
amidi -l
or look at:
/proc/asound/cards

Since you're sending MIDI CCs and no SysEx you can use a tool that
supports ALSA SEQ ports.

If your CCs and values are always the same - or just a few setups - you
could put them inside a MIDI file and then use aplaymidi. Otherwise
there is midish a commandline tool, that supports its own bash-like
scripting. It wouldn't be too hard to set something like this up.
http://www.midish.org

If Python or other scripting languages are an option, there are some
packages for these languages which support ALSASEQ I/O. If midish looks
promising, but too much work for a start, I could help.

HTH.

Best wishes,

Jeanette

--------
* website: http://juliencoder.de - for summer is a state of sound
* SoundCloud: https://soundcloud.com/jeanette_c

... About some useless information,
Supposed to fire my imagination <3
(Britney Spears)


_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Jeremy Jongepier
On 10/08/2017 03:20 AM, Athanasios Silis wrote:

> Hi all and thank you for your immediate responses.
> In the end what I was looking for was not the "midi through port" but a
> virtual midi port.
> To do that I had to add in /etc/modules-load.d/audio.conf
> snd-virmidi midi_devs=1 index=5
>
> then I could see
> $ amidi -l
> Dir Device    Name
> ..... (other devices) .....
> IO  hw:5,0    Virtual Raw MIDI (16 subdevices)
>
> and at the same time it would show up in jack's "midi" tab
> then I could simply use it as
>
> amidi -phw:5,0 -S <hexbytes>
>
> and the midi msg was surely enough sent correctly to the HW controller.
>
> Thank you for your help!
> I hope this helps others as well
Fwiw I created something similar a few years ago, maybe it could be
helpful in this context too:
https://github.com/autostatic/scripts/blob/ubuntu/volca_preset_loader

Best,

Jeremy


_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

David Kastrup
In reply to this post by Athanasios Silis
Athanasios Silis
<[hidden email]> writes:

> So even though I thought this would be easy , I am stuck somewhere.
>
> The command I am trying to use is
> amidi -p"14:0" -S <3x bytes depicting the midi CC command>

amidi uses hardware ports, not sequencer ports.

They look like

dak@lola:/usr/local/tmp/lilypond$ amidi -l
Dir Device    Name
IO  hw:1,0,0  UM-4 MIDI 1
IO  hw:1,0,1  UM-4 MIDI 2
IO  hw:1,0,2  UM-4 MIDI 3
IO  hw:1,0,3  UM-4 MIDI 4

> now port "14" SHOULD be the "Midi Through port as it appears in qjackctl's
> "midi" tab. I got it from
> $ aconnect -i -o
> client 0: 'System' [type=kernel]
>     0 'Timer           '
>     1 'Announce        '
> client 14: 'Midi Through' [type=kernel]
>     0 'Midi Through Port-0'
> client 16: 'TerraTec DMX6Fire' [type=kernel]
>     0 'MIDI-Front DMX6fire 0'
>    32 'Wavetable DMX6fire 0'
> client 24: 'Hoontech SoundTrack Audio DSP24' [type=kernel]
>     0 'MIDI-1 Hoontech/STA DSP24 2'
>    32 'MIDI-2 Hoontech/STA DSP24 2'
> client 28: 'Hoontech SoundTrack Audio DSP24' [type=kernel]
>     0 'MIDI-1 Hoontech/STA DSP24 3'
>    32 'MIDI-2 Hoontech/STA DSP24 3'
> client 32: 'BCR2000' [type=kernel]
>     0 'BCR2000 MIDI 1  '
>     1 'BCR2000 MIDI 2  '
>     2 'BCR2000 MIDI 3  '
>
> but running "amidi -p14:0 -S <hexbytes>" returns
> cannot open port "14:0": No such file or directory

I have no idea why you would not use 32:0 if the BCR2000 is explicitly
listed as such.  However, again those are sequencer ports, not hardware
ports.

On my system, I'd see

dak@lola:/usr/local/tmp/lilypond$ aconnect -i -o
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'UM-4' [type=kernel,card=1]
    0 'UM-4 MIDI 1     '
    1 'UM-4 MIDI 2     '
    2 'UM-4 MIDI 3     '
    3 'UM-4 MIDI 4     '

But I would not use 20:0 for amidi but rather hw:1,0,0 .  "UM-4 MIDI 1"
doesn't work either: it's just there for informational purposes.

dak@lola:/usr/local/tmp/lilypond$ amidi -p 20:0 -d
ALSA lib rawmidi.c:286:(snd_rawmidi_open_noupdate) Unknown RawMidi 20:0
cannot open port "20:0": No such file or directory
dak@lola:/usr/local/tmp/lilypond$ amidi -p hw:1,0,0 -d
^C
0 bytes read
dak@lola:/usr/local/tmp/lilypond$ amidi -p "UM-4 MIDI 1" -d
ALSA lib rawmidi.c:286:(snd_rawmidi_open_noupdate) Unknown RawMidi UM-4 MIDI 1
cannot open port "UM-4 MIDI 1": No such file or directory


--
David Kastrup
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

David Kastrup
In reply to this post by Athanasios Silis
Athanasios Silis
<[hidden email]> writes:

> Hi all and thank you for your immediate responses.
> In the end what I was looking for was not the "midi through port" but a
> virtual midi port.
> To do that I had to add in /etc/modules-load.d/audio.conf
> snd-virmidi midi_devs=1 index=5
>
> then I could see
> $ amidi -l
> Dir Device    Name
> ..... (other devices) .....
> IO  hw:5,0    Virtual Raw MIDI (16 subdevices)
>
> and at the same time it would show up in jack's "midi" tab
> then I could simply use it as
>
> amidi -phw:5,0 -S <hexbytes>
>
> and the midi msg was surely enough sent correctly to the HW controller.

You need virtual devices in order to emulate a _raw_ device for a device
only existing as an ALSA _sequencer_ port (like some virtual keyboard or
ALSA's Midi through).

But you already _have_ a raw device.  This makes no sense.  Why don't
you use the raw device for the BCR2000 rather than (presumably)
connecting its sequencer device to the Midi Through sequencer port of
ALSA and then needing a virtual raw device in order to access the Midi
Through sequencer port?

--
David Kastrup
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Clemens Ladisch
In reply to this post by David Kastrup
David Kastrup wrote:
> $ amidi -p "UM-4 MIDI 1" -d
> ALSA lib rawmidi.c:286:(snd_rawmidi_open_noupdate) Unknown RawMidi UM-4 MIDI 1

The card number can be replaced with the card ID:

  amidi -p hw:UM4 -d


Regards,
Clemens
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Christopher Arndt
In reply to this post by Jeanette C.
Am 08.10.2017 um 01:50 schrieb Jeanette C.:
> If Python or other scripting languages are an option, there are some
> packages for these languages which support ALSASEQ I/O. If midish looks
> promising, but too much work for a start, I could help.

For example, here's how you would use my python-rtmidi package [1] to
send a control change message for controlelr #1 (modulation) with value
127 to the first JACK MIDI port that contains the string "BCR 2000" in
its name:

import rtmidi
from rtmidi.midiutil import open_midioutput
from rtmidi.midiconstants import CONTROL_CHANGE, MODULATION_WHEEL

midiout, portname = open_midioutput(
        port='BCR 2000',
        api=rtmidi.API_UNIX_JACK,
        client_name="My test client")
midiout.send_message([CONTROL_CHANGE, MODULATION_WHEEL, 127])


If you want to use ALSA, just drop the 'api' keyword parameter to the
'open_midioutput' function.

[1] https://pypi.python.org/pypi/python-rtmidi


Chris
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Clemens Ladisch
In reply to this post by David Kastrup
David Kastrup wrote:
> But you already _have_ a raw device.  This makes no sense.  Why don't
> you use the raw device for the BCR2000 rather than (presumably)
> connecting its sequencer device to the Midi Through sequencer port of
> ALSA and then needing a virtual raw device in order to access the Midi
> Through sequencer port?

Because the raw MID port might already have been opened by Jack etc.
Going through the sequencer allows sharing/merging.


Regards,
Clemens
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

David Kastrup
In reply to this post by Clemens Ladisch
Clemens Ladisch <clemens-P6GI/[hidden email]>
writes:

> David Kastrup wrote:
>> $ amidi -p "UM-4 MIDI 1" -d
>> ALSA lib rawmidi.c:286:(snd_rawmidi_open_noupdate) Unknown RawMidi UM-4 MIDI 1
>
> The card number can be replaced with the card ID:
>
>   amidi -p hw:UM4 -d

Bah.  Indeed:

dak@lola:/usr/local/tmp/lilypond$ amidi -p hw:UM4 -d
^C
0 bytes read
dak@lola:/usr/local/tmp/lilypond$ amidi -l
Dir Device    Name
IO  hw:1,0,0  UM-4 MIDI 1
IO  hw:1,0,1  UM-4 MIDI 2
IO  hw:1,0,2  UM-4 MIDI 3
IO  hw:1,0,3  UM-4 MIDI 4
dak@lola:/usr/local/tmp/lilypond$ aplaymidi -l
 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 20:0    UM-4                             UM-4 MIDI 1
 20:1    UM-4                             UM-4 MIDI 2
 20:2    UM-4                             UM-4 MIDI 3
 20:3    UM-4                             UM-4 MIDI 4
dak@lola:/usr/local/tmp/lilypond$ cat /proc/asound/cards
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xfe020000 irq 31
 1 [UM4            ]: USB-Audio - UM-4
                      EDIROL UM-4 at usb-0000:00:1a.7-4.4, full speed

Any reason the user-level commands do not talk about the "card ID" but
show something else?

--
David Kastrup
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I send a midi command from bash through jack to my HW controller?

Clemens Ladisch
David Kastrup wrote:
> Clemens Ladisch writes:
>> The card number can be replaced with the card ID:
>
> Any reason the user-level commands do not talk about the "card ID" but
> show something else?

Hysterical raisins, I guess (in the Good Old Times™, card numbers were stable).


Regards,
Clemens
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user