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