Annotation of hatari/doc/alsa-midi.txt, revision 1.1.1.3

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.