|
|
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
19: - Software
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:
129: hatari --midi /dev/snd/midiC1D0
130:
1.1.1.2 ! root 131: Note: In older (obsolete) Linux distros SDL_mixer may take exclusive
! 132: access to the PCM (sound) device, but as the soft synthetizer is
! 133: already connected to it, one may need to use --nosound option to get
! 134: MIDI sound working. In recent distros this shouldn't anymore be
! 135: a problem thanks to Pulseaudio.
1.1 root 136:
137:
138: MIDI and networking
139: -------------------
140:
141: If you direct the MIDI data to stdout, you can use just ssh to
142: forward the MIDI output over network:
143: hatari --midi-in "" --midi-out /dev/stdout --log /dev/stderr |\
144: ssh [email protected] "cat>/dev/snd/midiC1D0"
145:
146: (Note that logging is re-directed to stderr so that it doesn't
147: mess the MIDI output to standard output and --midi-in is set
148: empty in case you don't have MIDI input device locally.)
149:
150:
151: MIDI-networking two Hatari emulators can be most easily done with socat.
152:
153: MIDI networking over normal TCP/IP network:
154: @remote.site:
155: socat -b1 PTY,raw,echo=0,link=/tmp/midi1 TCP4-LISTEN:33333 &
156: hatari --midi-in /tmp/midi1 --midi-out /tmp/midi1 &
157: @local.site:
158: socat -b1 PTY,raw,echo=0,link=/tmp/midi2 TCP4:remote.site:33333 &
159: hatari --midi-in /tmp/midi2 --midi-out /tmp/midi2 &
160:
161: Buffer size (-b) is set to one just in case (by default socat buffer
162: size is 8K, but all the MIDI communication is done byte at the time).
163:
164: You may need to open a hole into your firewall for the given port
165: (here 33333). Usually there's a hole for the www-traffic in firewalls,
166: but the port for that (80) is below 1000, so if you use "www" as
167: the port, most likely you need to run "socat" as root. To test this
168: with a single machine, use "localhost" as the "remote.site".
169:
170: Local MIDI network:
171: socat -b1 PTY,raw,echo=0,link=/tmp/midi1 PTY,raw,echo=0,link=/tmp/midi2 &
172: hatari --midi-in /tmp/midi1 --midi-out /tmp/midi1 &
173: hatari --midi-in /tmp/midi2 --midi-out /tmp/midi2 &
174:
175: If you don't have "socat" installed, local-midi-ring.sh script shows how
176: to join several (local) Hatari emulators into a MIDI ring using fifos.
177:
178:
179: Software
180: --------
181:
182: In Debian, the tools mentioned above come from following packages:
183: - alsa-utils (aconnect, aplaymidi)
184: - alsa-tools (sbiload)
185: - awesfx (sfxload)
186: - pmidi
187: - vkeybd
1.1.1.2 ! root 188: - vmpk
1.1 root 189: - aconnectgui
190: - qsynth
191: - fluidsynth
192: - fluid-soundfont-* (soundfonts)
193: - timidity
1.1.1.2 ! root 194: - horgand
! 195: - qjackctl
1.1 root 196: - socat
197: See http://packages.debian.org/ for more details on them.
198:
199: Below are upstream links to some of these tools.
200:
201: Vkeybd:
202: http://alsa.opensrc.org/Vkeybd
203:
1.1.1.2 ! root 204: Virtual MIDI Piano Keyboard (vmpk):
! 205: http://vmpk.sourceforge.net/
! 206:
1.1 root 207: Patch (ALSA connecting) utilities:
208: http://alsa.opensrc.org/AlsaMidiPatchbays
209:
210: FluidSynth:
211: http://www.iiwu.org/fluidsynth/
212:
1.1.1.2 ! root 213: Horgand:
! 214: http://horgand.berlios.de/
! 215:
1.1 root 216: Soundfonts:
217: http://alsa.opensrc.org/SoundFontHandling
218:
219: List of some soft-synthetizers:
220: http://alsa.opensrc.org/SoftSynths
221:
222: Kaconnect:
223: http://alsamodular.sourceforge.net/
224:
1.1.1.2 ! root 225: QjackCtl:
! 226: http://qjackctl.sourceforge.net/
! 227:
1.1 root 228: socat:
229: http://www.dest-unreach.org/socat/
230:
231: MidiMaze:
232: http://en.wikipedia.org/wiki/MIDI_Maze
233:
234:
235: Additional documentation
236: ------------------------
237:
238: ALSA midi overview:
239: http://alsa.opensrc.org/AlsaMidiOverview
240:
241: How to set up soundcards with hardware MIDI synthesis capability (AWE & OPL3):
242: https://help.ubuntu.com/community/Midi/HardwareSynthesisSetup
243:
244: Virtual midi hardware setup:
245: http://www.tldp.org/HOWTO/MIDI-HOWTO-10.html
246:
247: Timidity Howto:
248: http://lau.linuxaudio.org/TiMidity-howto.html
249:
250: Midi with ALSA (old):
251: http://www.linuxfocus.org/English/September2002/article259.shtml
252:
253: Midi on Linux:
254: http://www.linuxjournal.com/article/7773
255:
256: MIDI, Musical Instrument Digital Interface protocol:
257: 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.