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