|
|
1.1 root 1:
2: Getting (Linux) ALSA midi support and MIDI networking working with Hatari
3: =========================================================================
4:
5: If you don't have a real MIDI sequencer, you can use the MIDI synthesizer
6: of your sound card (if available) or use a software synthetizer.
7:
8: For (Debian) package names and links to software referenced in this
9: text, see end of the text. Most of the distros should have in their
10: repositories packages at least for some of them though.
11:
12: Contents:
1.1.1.5 ! root 13: - Quick start
! 14: - Using a soundcard with built-in MIDI synthesis capability
1.1 root 15: - Making MIDI soft-synthetizer to work with ALSA
16: - Using FluidSynth instead of Timidity
1.1.1.2 root 17: - Other software synthetizers
1.1 root 18: - Making it all to work with Hatari
1.1.1.5 ! root 19: - Forwarding MIDI over network
1.1.1.4 root 20: - Linux & Atari MIDI related software
1.1 root 21: - Additional documentation
22:
23:
1.1.1.5 ! root 24: Quick start
! 25: -----------
! 26:
! 27: *If* Hatari is built with PortMidi, getting MIDI output from Hatari is
! 28: simple.
! 29:
! 30: Just start a MIDI software synthetizer (on Debian/Ubuntu):
! 31: $ sudo apt install qsynth
! 32: $ qsynth
! 33:
! 34: (Hatari scans for ALSA MIDI devices only at start, so the MIDI output
! 35: and input devices need to be there before starting Hatari.)
! 36:
! 37: Then start Hatari, and in the "Devices" option screen, select "Enable
! 38: MIDI emulation" and for the "output" option, select "Synth input
! 39: port".
! 40:
! 41: That's all!
! 42:
! 43: Rest of this document is about lower level MIDI (raw device) access
! 44: without PortMidi, Linux MIDI usage in general, and notes of some
! 45: useful Open Source MIDI software available on Linux.
! 46:
! 47:
! 48: Using a soundcard with built-in MIDI synthesis capability
1.1 root 49: ---------------------------------------------------------
50:
51: If your soundcard is capable of playing MIDI sound (i.e. you can play a .mid
52: file with the "aplaymidi" command using the appropriate port), you can use this
53: synthesis device for Hatari, too. However, you still might have to install and
54: connect a virtual midi device, so that Hatari can access it through a
55: /dev/snd/midiC*D* device file (see instructions below).
56:
57: Please note that you might also have to load instrument patches into your sound
58: card first, for example with the program "sfxload" for AWE64 based sound cards,
59: or with the program "sbiload" for OPL3 based sound cards.
60:
61:
62: Making MIDI soft-synthetizer to work with ALSA
63: -----------------------------------------------
64:
65: Make Timidity into an ALSA output device with:
66: timidity -Os -iA
67: (-O: output=alsa, -i: interface=alsa)
68:
69: To make it use less CPU and be more responsive, use:
70: timidity -Os -iA -B2,8 -EFreverb=0 -EFchorus=0
71: (-B: 2,8=set small buffers, -EFx=0: disable effects)
72:
73: Make vkeybd (virtual midi keyboard app) into an ALSA input device with:
74: vkeybd
1.1.1.2 root 75: Or use the newer & nicer looking "Virtual MIDI Piano Keyboard":
76: vmpk
1.1 root 77:
78: View the resulting (software) ALSA input and output devices:
79: aconnect -i -o
80:
81: Then connect the vkeybd output port to the timidity input port with:
82: aconnect <vkeybd port> <timidity port>
83: Or use one of the GUI programs for this like kaconnect, aconnectgui etc.
84:
85: Now you can use the virtual midi keyboard for testing the sound
86: synthesis.
87:
88:
1.1.1.2 root 89: Finally you can test how well midi files are played.
1.1 root 90: Check which ALSA port Timidity provides:
91: aplaymidi -l
92:
93: And use that port for playing a midi file:
94: aplaymidi -p <port, e.g. 129:0> test.mid
95: (or use 'pmidi')
96:
97: Note: Remember that you need to re-connect the (virtual) device
98: ports each time you restart them.
99:
100:
101: Using FluidSynth instead of Timidity
102: ------------------------------------
103:
104: Instead of Timidity, you also use other soft-synthetizers,
105: like FluidSynth:
106: fluidsynth --audio-driver=alsa --midi-driver=alsa_seq soundfont.sf2
107:
108: You could play a bit with other options to get more performance,
109: sound volume etc:
110: --reverb=no --chorus=no -o synth.polyphony=16 --gain=0.6
111:
112: And if you don't like the FluidSynth shell, use:
113: --no-shell --server
114:
115: Qsynth provides a GUI for above:
116: qsynth <soundfont>
117:
1.1.1.2 root 118: Note: FluidSynth v1.0.7a in older (obsolete) Linux distros has buffer
119: overruns, but they're fixed in v1.0.8 or newer that are in the current
120: Linux distros.
121:
122:
123: Other software synthetizers
124: ---------------------------
125:
126: Of the other soft-synthetizers, I like also Horgand organ emulator
127: as it has pretty good organ sound, but it needs Jack connection kit
128: (+ e.g. qjackctl) for sound to work properly (not have sound underruns).
1.1 root 129:
130:
131: Making it all to work with Hatari
132: ---------------------------------
133:
1.1.1.5 ! root 134: Hatari requires midi hardware devices to work, it doesn't support ALSA
! 135: directly without PortMidi. To get the software synth ALSA devices to
! 136: appear as HW midi devices, run following as *root*:
1.1 root 137: modprobe snd-virmidi
138:
139: When you list your ALSA output devices with:
140: aconnect -o
1.1.1.2 root 141: You should see in addition to the soft-synth also 4 virtual hardware
1.1 root 142: devices.
143:
144: Then connect (with aconnect or one of the GUIs) the first virtual
1.1.1.2 root 145: HW port to the same soft-synth port where you connected the virtual
1.1 root 146: midi keyboard.
147:
148: Check which number was assigned by ALSA to the new virtual midi card:
149: cat /proc/asound/cards
150:
151: And give to Hatari the corresponding ALSA midi device. In my case
152: VirMidi was Card 1 and as the port used above was first one, I give
153: Hatari the following midi device:
1.1.1.3 root 154: hatari --midi-out /dev/snd/midiC1D0
155:
156: (For the virtual midi keyboard, give same device with --midi-in option.)
1.1 root 157:
1.1.1.2 root 158: Note: In older (obsolete) Linux distros SDL_mixer may take exclusive
159: access to the PCM (sound) device, but as the soft synthetizer is
160: already connected to it, one may need to use --nosound option to get
161: MIDI sound working. In recent distros this shouldn't anymore be
162: a problem thanks to Pulseaudio.
1.1 root 163:
164:
1.1.1.5 ! root 165: Forwarding MIDI over network
! 166: ----------------------------
1.1 root 167:
168: If you direct the MIDI data to stdout, you can use just ssh to
169: forward the MIDI output over network:
170: hatari --midi-in "" --midi-out /dev/stdout --log /dev/stderr |\
171: ssh [email protected] "cat>/dev/snd/midiC1D0"
172:
173: (Note that logging is re-directed to stderr so that it doesn't
174: mess the MIDI output to standard output and --midi-in is set
175: empty in case you don't have MIDI input device locally.)
176:
177:
178: MIDI-networking two Hatari emulators can be most easily done with socat.
179:
180: MIDI networking over normal TCP/IP network:
181: @remote.site:
182: socat -b1 PTY,raw,echo=0,link=/tmp/midi1 TCP4-LISTEN:33333 &
183: hatari --midi-in /tmp/midi1 --midi-out /tmp/midi1 &
184: @local.site:
185: socat -b1 PTY,raw,echo=0,link=/tmp/midi2 TCP4:remote.site:33333 &
186: hatari --midi-in /tmp/midi2 --midi-out /tmp/midi2 &
187:
188: Buffer size (-b) is set to one just in case (by default socat buffer
189: size is 8K, but all the MIDI communication is done byte at the time).
190:
191: You may need to open a hole into your firewall for the given port
192: (here 33333). Usually there's a hole for the www-traffic in firewalls,
193: but the port for that (80) is below 1000, so if you use "www" as
194: the port, most likely you need to run "socat" as root. To test this
195: with a single machine, use "localhost" as the "remote.site".
196:
197: Local MIDI network:
198: socat -b1 PTY,raw,echo=0,link=/tmp/midi1 PTY,raw,echo=0,link=/tmp/midi2 &
199: hatari --midi-in /tmp/midi1 --midi-out /tmp/midi1 &
200: hatari --midi-in /tmp/midi2 --midi-out /tmp/midi2 &
201:
202: If you don't have "socat" installed, local-midi-ring.sh script shows how
203: to join several (local) Hatari emulators into a MIDI ring using fifos.
204:
205:
1.1.1.4 root 206: Linux & Atari MIDI related Software
207: -----------------------------------
1.1 root 208:
209: In Debian, the tools mentioned above come from following packages:
210: - alsa-utils (aconnect, aplaymidi)
211: - alsa-tools (sbiload)
212: - awesfx (sfxload)
213: - pmidi
214: - vkeybd
1.1.1.2 root 215: - vmpk
1.1 root 216: - aconnectgui
217: - qsynth
218: - fluidsynth
219: - fluid-soundfont-* (soundfonts)
220: - timidity
1.1.1.2 root 221: - horgand
222: - qjackctl
1.1 root 223: - socat
224: See http://packages.debian.org/ for more details on them.
225:
226: Below are upstream links to some of these tools.
227:
228: Vkeybd:
229: http://alsa.opensrc.org/Vkeybd
230:
1.1.1.2 root 231: Virtual MIDI Piano Keyboard (vmpk):
232: http://vmpk.sourceforge.net/
233:
1.1 root 234: Patch (ALSA connecting) utilities:
1.1.1.5 ! root 235: http://alsa.opensrc.org/AlsaMidiPatchbays
1.1 root 236:
237: FluidSynth:
238: http://www.iiwu.org/fluidsynth/
239:
1.1.1.2 root 240: Horgand:
241: http://horgand.berlios.de/
242:
1.1 root 243: Soundfonts:
244: http://alsa.opensrc.org/SoundFontHandling
245:
246: List of some soft-synthetizers:
247: http://alsa.opensrc.org/SoftSynths
248:
249: Kaconnect:
250: http://alsamodular.sourceforge.net/
251:
1.1.1.2 root 252: QjackCtl:
253: http://qjackctl.sourceforge.net/
254:
1.1 root 255: socat:
256: http://www.dest-unreach.org/socat/
257:
1.1.1.4 root 258:
259: As to Atari MIDI programs, here's an incomplete list
260: of games supporting MIDI music:
261: http://www.atari-forum.com/viewtopic.php?f=3&t=21473&start=25#p195632
262:
263: MidiMaze supports up to 16 players over MIDI network:
1.1 root 264: http://en.wikipedia.org/wiki/MIDI_Maze
265:
266:
267: Additional documentation
268: ------------------------
269:
270: ALSA midi overview:
271: http://alsa.opensrc.org/AlsaMidiOverview
272:
273: How to set up soundcards with hardware MIDI synthesis capability (AWE & OPL3):
274: https://help.ubuntu.com/community/Midi/HardwareSynthesisSetup
275:
276: Virtual midi hardware setup:
277: http://www.tldp.org/HOWTO/MIDI-HOWTO-10.html
278:
279: Timidity Howto:
280: http://lau.linuxaudio.org/TiMidity-howto.html
281:
282: Midi with ALSA (old):
283: http://www.linuxfocus.org/English/September2002/article259.shtml
284:
285: Midi on Linux:
286: http://www.linuxjournal.com/article/7773
287:
288: MIDI, Musical Instrument Digital Interface protocol:
289: http://en.wikipedia.org/wiki/Midi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.