MidiSoftwareSynthesisHowTo
How to get midi sound in Ubuntu
You need this guide unless:
you have a [:SoundcardsWithHardwareSynth:soundcard with a linux-supported hardware synth]
- you are using external MIDI instruments
If you're not sure, you probably need it.
There are two main programs that do software synthesis, Timidity and Fluidsynth. This section only covers Timidity at the moment.
Installing Timidity
You will need the Universe repository enabled (see AddingRepositoriesHowto)
Start by installing Timidity (see SynapticHowto).
Next you need a set of samples. The easiest way is to install package 'freepats' (a 28 MB download), and you're done. Alternatively, for better sound, read 'Finding and setting up a soundfont' below.
Once you've done that, you can try playing a midi file:
timidity myfile.mid
If all is well, you should hear delicate strains of synthesised music. If you have problems, read 'Reducing CPU usage' below.
Setting up Timidity as a MIDI server
Issue the following commands:
sudo modprobe snd-seq-device sudo modprobe snd-seq-midi sudo modprobe snd-seq-oss sudo modprobe snd-seq-midi-event sudo modprobe snd-seq
This loads missing modules. You may not need all these (I found it worked with just the first two). Then enter:
timidity -iA -B2,8 -Os1l -s 44100
This loads timidity as a midi server and opens 2 midi ports, 128:0 ad 128:1. After issuing it, you should have midi players working. You can open another terminal and issue a command such as:
pmidi -p 128:0 music.mid kmid music.mid
To close timidity, press CTRL-C in the terminal it's running in.
Launching the server as root may improve performance because of higher priorities given to the process.
Notedit, or your score editor of choice can then be loaded and recognised the midi ports.
If the computer is busy doing something else other than playing music, you may hear scratches or have latency problems. This might be solved with a realtime kernel patch, but is out of the scope of this HOWTO.
Automatically starting Timidity on boot
Ubuntu Hoary sets up scripts in /etc/init.d when you install Timidity. To start it on boot, edit /etc/default/timidity and uncomment the line
TIM_ALSASEQ=true
You'll also need to add the modules you loaded earlier to /etc/modules.
Finding and setting up a soundfont
Websites: http://www.personalcopy.com (try Unison.sf2) http://www.hammersound.net/ or look up soundfonts in a search engine.
If you end up with a file ending with .sfArk, it's compressed in an annoying proprietary format. You may need a windows machine to decompress it, depending which version they've used. Details at http://melodymachine.com/sfark.htm
soundfont /pathtothesoundfontfile/soundfontfile.sf2
sfArk on Linux
If you need to decompress sfArk compressed Soundfonts then you can easily install sfArk into linux using WINE. If you don't have WINE installed on your machine then you can install it with the following command:
sudo apt-get install wine
Next, you must obtain sfArk from this URL listed above. Once you have WINE installed, all you must do is change to the directory where you have downloaded sfArk and issue the following command:
wine nameoffile
sfArk also works beautifully in Crossover Office 5 as well.
Then you need to create the file /etc/timidity/timidity.cfg and add the following line (edit as appropriate):
Reducing CPU usage
If Timidity uses too much CPU on your slow machine, try adding these lines to the start of /etc/timidity/timidity.cfg (you may need to create this file)
opt EFresamp=l #use linear resampling opt EFvlpf=d #disable VLPF opt EFreverb=d #disable reverb opt EFchorus=d #disable chorus opt EFdelay=d #disable delay
Discussion
Ask questions at [http://ubuntuforums.org/showthread.php?p=336935]
Discuss this page at ["MidiSoftwareSynthesisHowTo/talk"]