relpipe-data/examples-jack-midi-monitoring.xml
author František Kučera <franta-hg@frantovo.cz>
Mon, 21 Feb 2022 00:43:11 +0100
branchv_0
changeset 329 5bc2bb8b7946
parent 313 a43265235e5a
permissions -rw-r--r--
Release v0.18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
296
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
<stránka
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
	
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
	<nadpis>Monitoring MIDI messages using JACK</nadpis>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
	<perex>examine events running through a JACK pipeline or bind MIDI keys to actions + bonus: Roland MT-32</perex>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
	<m:pořadí-příkladu>04100</m:pořadí-příkladu>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
	<text xmlns="http://www.w3.org/1999/xhtml">
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
			A powerful audio system called <a href="https://jackaudio.org/">JACK</a> allows us to
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
			build pipelines consisting of audio interfaces, players, recorders, filters and effects…
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
			and route sound streams (both PCM and MIDI) through them.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
			MIDI messages can come from keyboards or other hardware MIDI controllers or from MIDI players and other software.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
			Sometimes it is useful to check what is happening under the hood and examine particular MIDI messages
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
			instead of just playing them on a sound module or synthesizer.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
			In this example we will show how to bridge two seemingly unrelated worlds: real-time audio and relational pipes.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
			We can join the JACK graph with <code>relpipe-in-jack</code> command.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
			It does not consume STDIN, it gets events from JACK instead, so no other input data are needed.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
		
297
192b0059a6c4 Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents: 296
diff changeset
    26
		<m:pre jazyk="bash">relpipe-in-jack | relpipe-out-csv</m:pre>
296
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
			We are connected to the JACK daemon now, but no data are routed to us.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
			So we need to direct some MIDI streams to our input:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
		<m:img src="img/jack-connections-1.png"/>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
			And then incoming MIDI events will generate output like this:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
		<pre><![CDATA["event","channel","note_on","note_pitch","note_velocity","controller_id","controller_value","raw"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
"note","0","true","43","64","0","0","90 2b 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
"note","0","false","43","64","0","0","80 2b 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
"note","0","true","50","64","0","0","90 32 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
"note","0","false","50","64","0","0","80 32 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
"note","0","true","67","64","0","0","90 43 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
"note","0","false","67","64","0","0","80 43 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
"control","0","false","0","0","32","1","b0 20 01"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
"control","0","false","0","0","0","0","b0 00 00"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
"unknown","0","false","0","0","0","0","c0 00"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
"note","0","true","36","64","0","0","90 24 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
"note","0","false","36","64","0","0","80 24 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
"sysex","0","false","0","0","0","0","f0 41 10 16 12 20 00 00 61 68 6f 6a 3e f7"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
"note","0","true","60","64","0","0","90 3c 40"
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
"note","0","false","60","64","0","0","80 3c 40"]]></pre>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
			CSV is not the only option. Once data are in the machine-readable relational format,
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
			we can convert them into any other format or process them using any relational transformation.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
			For ad-hoc monitoring, we can use <code>relpipe-out-gui</code> and watch MIDI messages – as they come –
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
			in a table in GUI:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
		<m:img src="img/jack-monitoring-gui-1.png"/>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
			As we can see, there are raw MIDI data and also some decoded values.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
			Future versions of <code>relpipe-in-jack</code> should provide improved decoder and other features like timing information.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
			We can use <code>relpipe-in-jack</code> not only for monitoring 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
			but we can also write a simple script that binds particular MIDI events
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
			to actions to be executed – like starting a program or running a script on background.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
			So we can map some keys/buttons/knobs on our piano, mixer or other controller:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
		<m:pre jazyk="bash"><![CDATA[#!/bin/bash
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
relpipe-in-jack \
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
	| relpipe-out-nullbyte \
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
	| while read_nullbyte event channel note_on note_pitch velocity c_id c_value raw; do
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
		if   [[ "$note_pitch" == "21" && "$note_on" == "true" ]]; then kcalc &
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
		elif [[ "$note_pitch" == "23" && "$note_on" == "true" ]]; then dolphin &
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
		fi
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
	done]]></m:pre>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    88
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    89
			Many audio applications have similar feature, 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    90
			but we can leave this script running on the background 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
			even when we do not want to have loaded a complex software like a DAW (Digital audio workstation).
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
		
313
a43265235e5a examples: Monitoring MIDI messages using JACK – relpipe-in-jack: @id for the MT-32 part
František Kučera <franta-hg@frantovo.cz>
parents: 297
diff changeset
    95
		<h2 id="mt32_display_message">Bonus: display messages on Roland MT-32</h2>
296
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    97
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    98
			Maybe you remember games or MIDI files that <i>magically</i> displayed text messages on your 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    99
			<a href="https://en.wikipedia.org/wiki/Roland_MT-32">MT-32</a> unit 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   100
			which you used to generate wonderful sounds and music from the MIDI signal.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   101
			Let us look inside and check how this <i>magic</i> works.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   102
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   103
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   104
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   105
			We have to route the MIDI signal through JACK and fork it there (similarly to <code>tee</code> in shell)
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   106
			so it will flow both to the MT-32 and the <code>relpipe-in-jack</code> process.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   108
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   109
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   110
			Given that we have running the JACK daemon (can be started from GUI application like QjackCtl)
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   111
			and <code>a2j</code> which bridges ALSA-MIDI and JACK-MIDI together.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   112
			We set up the routing (the fork) and then play a SMF (Standard MIDI file) file:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   113
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   114
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   115
		<pre>aplaymidi --port=14:0 test.mid</pre>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   116
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   117
		<p>Proper port number could be found here:</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   118
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   119
		<pre><![CDATA[$ aplaymidi -l
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   120
 Port    Client name                      Port name
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   121
 14:0    Midi Through                     Midi Through Port-0
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   122
 24:0    Rubix44                          Rubix44 MIDI 1]]></pre>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   123
 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   124
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   125
			Data sent to the <i>Midi Through</i> port in the ALSA-MIDI emerges in the <code>a2j</code> in the JACK-MIDI graph
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   126
			and then flows to <code>relpipe-in-jack</code>.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   127
			So the MT-32 will play the sounds and display messages (if any) and we will get copy of everything in
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   128
			<code>relpipe-in-jack</code> that passes data to command like <code>relpipe-out-gui</code>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   129
			or <code>relpipe-out-csv</code> where we see decoded messages and also raw MIDI data.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   130
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   131
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   132
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   133
			n.b. the <i>Midi Through</i> in the ALSA-MIDI graph should be connected to our audio interface 
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   134
			(e.g. <a href="https://blog.frantovo.cz/c/365/Roland%20Rubix44%20%E2%80%93%20extern%C3%AD%20zvukov%C3%A1%20karta">Rubix44</a>)
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   135
			which is linked to the MT-32 using a MIDI cable.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   136
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   137
	
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   138
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   139
			Messages that cause text to be showed on the MT-32 display are so called <i>System Exclusive (SysEx) messages</i>.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   140
			After executing the <code>aplaymidi</code> we see for example:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   141
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   142
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   143
		<m:img src="img/mt-32-display-1.jpeg"/>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   144
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   145
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   146
			And <code>relpipe-in-jack</code> captured and reported this SysEx message:
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   147
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   148
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   149
		<pre>f0 41 10 16 12 20 00 00 <strong>52 65 6c 61 74 69 6f 6e 61 6c 20 70 69 70 65 73</strong> 14 f7</pre>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   150
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   151
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   152
			The highlighted part (52 … 73) is easy – it is just the <code>Relational pipes</code> ASCII bytes in HEX.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   153
			But what does the rest mean?
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   154
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   155
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   156
		<ul>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   157
			<li><code>f0</code> = start of SysEx message</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   158
			<li><code>41</code> = Roland <a href="https://www.midi.org/specifications-old/item/manufacturer-id-numbers">manufacturer ID</a>. This is important because SysEx messages are vendor-specific. So devices from other manufacturers (that might be in the same MIDI daisy-chain) will know, that this message is not for them and will ignore it.</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   159
			<li><code>10</code> = device ID – if we have more units with same manufacturer and model ID, we should assign them different device IDs, so we can address them individually.</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   160
			<li><code>16</code> = model ID</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   161
			<li><code>12</code> = command ID, 12 is set, 11 is get</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   162
			<li><code>20 00 00</code> = the address of the value we want to set, 20 00 00 is the text to be displayed</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   163
			<li><code>14</code> = checksum computed from the <code>20 00 00 … 73</code> part</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   164
			<li><code>f7</code> = end of the SysEx message</li>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   165
		</ul>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   166
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   167
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   168
			Only the start and end of the SysEx message and the manufacturer ID are part of the MIDI standard.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   169
			The rest of the bytes is Roland specific. SysEx messages can do much more than controlling the display – consult the documentation for particular device.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   170
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   171
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   172
	
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   173
		<p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   174
			We can generate our own messages using the <a href="https://hg.frantovo.cz/midi/mt-32-display/">mt-32-display</a> tool.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   175
			It produces SysEx messages for Roland MT-32 in hex format which can be passed directly to the <code>amidi</code> command (see examples in the code).
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   176
			Unfortunately <code>amidi</code> works only with hardware ports and is unable to route through JACK.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   177
			But there is another tool called <a href="https://hg.frantovo.cz/midi/sysex2smf/">sysex2smf</a>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   178
			which translates raw SysEx data to Standard MIDI file (<code>*.mid</code>).
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   179
			And SMF can be played using the <code>aplaymidi</code> which can be routed through JACK and our pipelines.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   180
			So the 48 lines of C++ code (both tools together) is everything we need to enjoy this nice feature of our MT-32 unit.
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   181
		</p>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   182
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   183
		<video src="https://blog.frantovo.cz/s/1581/mt-32.webm" poster="img/mt-32-video-1.jpeg" controls="controls" width="820px">Maybe you often ask: What would MT-32 do?</video>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   184
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   185
		
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   186
	</text>
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   187
418e11eb6fea examples: Monitoring MIDI messages using JACK – relpipe-in-jack
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   188
</stránka>