Use this guide to setup your MIDI synth, if you have a soundcard with hardware MIDI synthesis capability (see SoundcardsWithHardwareSynth )

Please be absolutely sure you have a soundcard with hardware MIDI synthesis capability before you following any of the instructions here! If you haven't, refer to MidiSoftwareSynthesisHowTo instead.

For Sound Blaster Live/Audigy

Preliminary Check

First, let's check if the required kernel modules are loaded. In my experience, all releases of Ubuntu after Hoary will have the kernel modules loaded already.

Open a terminal and issue this command:

aplaymidi -l

If you see something similar to this:

  Port    Client name                      Port name
 62:0    Midi Through                     Midi Through Port-0
 64:0    EMU10K1 MPU-401 (UART)           EMU10K1 MPU-401 (UART)
 65:0    Emu10k1 WaveTable                Emu10k1 Port 0
 65:1    Emu10k1 WaveTable                Emu10k1 Port 1
 65:2    Emu10k1 WaveTable                Emu10k1 Port 2
 65:3    Emu10k1 WaveTable                Emu10k1 Port 3

It means that the required modules are loaded and you can skip this step. Else, we need to make the required modules load at boot. To do this, issue this command at the terminal:

gksudo gedit /etc/modules

When prompted, enter your password. Now, at the end of the file, add this:

snd-seq # Unnecessary?
snd-seq-device # Unnecessary?
snd-seq-midi # Unnecessary?
#snd-seq-oss # Outdated and unavailable.
snd-seq-midi-event # Unnecessary?
snd-emu10k1-synth # Most likely only this module is necessary.

(You may not need all of these... I have found it to work with just the first three.)

Then save and exit gedit. Now, at the terminal, issue this command:

sudo modprobe -a snd-seq snd-seq-device snd-seq-midi snd-seq-midi-event snd-emu10k1-synth

Next Step

Then, we need to install the package "awesfx". You will need the universe and multiverse repositories enabled; for help on that please refer to AddingRepositoriesHowto

Issue the following command into a terminal:

sudo aptitude install awesfx

Now, we need a soundfont. If you have windows installed on this machine, you can retrieve 2gmgsmt.sf2 from the windows/system32/drivers/ folder. Else, you can get a soundfont from the internet.

For help getting soundfonts from the internet: Websites: http://www.personalcopy.com (try Unison.sf2) http://www.hammersound.net/ or look up soundfonts in a search engine. A big list may be found at http://timidity.s11.xrea.com/files/readme_cfgp.htm in which the fifth soundfont from the top (SGM-whatever) is quite complete for general use with TiMidity++.

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 There is a Linux version available on the website.

Now, once you've got a soundfont, issue this command at the terminal:

asfxload /path/to/file.sf2

And now, you're ready to listen to some midi files. If you need a MIDI file to test this with, here's a short one: http://www.webpost.net/av/avatarmaster/patricksworld.mid

Now, type "aplaymidi -l" in the terminal. This will tell you the ALSA MIDI port number for the synth. In my experience on all versions of Ubuntu before Edgy, it is 65:0. On Edgy, it is 17:0.

In the output of "aplaymidi -l", you should see something similar to this:

 62:0    Midi Through                     Midi Through Port-0
 64:0    EMU10K1 MPU-401 (UART)           EMU10K1 MPU-401 (UART)
 65:0    Emu10k1 WaveTable                Emu10k1 Port 0
 65:1    Emu10k1 WaveTable                Emu10k1 Port 1
 65:2    Emu10k1 WaveTable                Emu10k1 Port 2
 65:3    Emu10k1 WaveTable                Emu10k1 Port 3

As you see, it tells you the port number for the emu10k1 wavetable, which is what will play your MIDI.

At the terminal, do this:

aplaymidi -p 65:0 file.mid

(where 65:0 is the port number that aplaymidi -l reports to you, and file.mid is the filename of the midi file you want to play

You should be hearing wonderful synthesized music.

For Sound Blaster Awe64 (and probably also Awe32)

First, let's check if the required kernel modules are loaded.

Open a terminal and issue this command:

aplaymidi -l

If you see something similar to this:

  Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 16:0    Sound Blaster 16                 Sound Blaster 16 MIDI
 17:0    Emu8000 WaveTable                Emu8000 Port 0
 17:1    Emu8000 WaveTable                Emu8000 Port 1
 17:2    Emu8000 WaveTable                Emu8000 Port 2
 17:3    Emu8000 WaveTable                Emu8000 Port 3

It means that the required modules are loaded and you can skip this step. Else, we need to make the required modules load at boot. To do this, issue this command at the terminal:

gksudo gedit /etc/modules

When prompted, enter your password. Now, at the end of the file, add this:

snd-sbawe
snd-emu8000-synth

Then save and exit gedit. Now, at the terminal, issue this command:

sudo modprobe -a snd-sbawe snd-emu8000-synth

Then, we need to install the package "awesfx". You will need the universe and multiverse repositories enabled; for help on that please refer to AddingRepositoriesHowto

Issue the following command into a terminal:

sudo aptitude install awesfx

Now, we need a soundfont. If you have windows installed on this machine, you can retrieve 2gmgsmt.sf2 from the windows/system32/drivers/ folder. Else, you can get a soundfont from the internet.

For help getting soundfonts from the internet: Websites: http://www.personalcopy.com (try Unison.sf2) http://www.hammersound.net/ or look up soundfonts in a search engine. A big list may be found at http://timidity.s11.xrea.com/files/readme_cfgp.htm in which the fifth soundfont from the top (SGM-whatever) is quite complete for general use with TiMidity++.

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 There is a Linux version available on the website.

You are advised to choose a small soundfont. Some models in the Sound Blaster Awe series have only 512 kByte of soundfont memory...

Now, once you've got a soundfont, issue this command at the terminal:

asfxload file.sf2

And now, you're ready to listen to some midi files.

Now, type "aplaymidi -l" in the terminal. This will tell you the ALSA MIDI port number for the synth. In my experience on all versions of Ubuntu before Edgy, it is 65:0. On Edgy, it is 17:0.

In the output of "aplaymidi -l", you should see something similar to this:

  Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 16:0    Sound Blaster 16                 Sound Blaster 16 MIDI
 17:0    Emu8000 WaveTable                Emu8000 Port 0
 17:1    Emu8000 WaveTable                Emu8000 Port 1
 17:2    Emu8000 WaveTable                Emu8000 Port 2
 17:3    Emu8000 WaveTable                Emu8000 Port 3

As you see, it tells you the port number for the emu8000 wavetable, which is what will play your MIDI.

At the terminal, do this:

aplaymidi -p 17:0 file.mid

(where 17:0 is the port number that aplaymidi -l reports to you, and file.mid is the filename of the midi file you want to play

You should be hearing wonderful synthesized music.

For Soundcards with OPL3 FM synth

Some older soundcards (from around 1995 or so, I think) had the OPL3 chip on them for MIDI synthesis. http://en.wikipedia.org/wiki/Yamaha_YMF262 If you have an old pentium computer, or a PCI soundcard that came from an old Pentium computer, it may have the OPL3 chip on it, so you can use it for MIDI synthesis. However, it doesn't sound very good. The instrument sounds are very synthetic and only about 7 sounds can be played at one time. You might as well just go and set up Software MIDI synthesis. But if you still want to get it working anyway, here is this guide. NOTE: This can only apply to Dapper, and versions of Ubuntu after Dapper, since older ones do not have a package that we need in their repositories; alsa-tools.

First, let us load the modules needed. Open a terminal and run this command:

sudo modprobe -a snd-seq snd-seq-device snd-seq-midi snd-seq-oss snd-seq-midi-event snd-opl3-synth

Now, run this command:

aplaymidi -l

It should tell you something similar to this:

 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 16:0    Avance Logic ALS4000             Avance Logic ALS4000 MIDI
 17:0    OPL3 FM synth                    OPL3 FM Port
 20:0    MPU-401 UART                     MPU-401 UART MIDI

Note the "OPL3 FM synth" part. That should be in the output. If it isn't, then you don't have a soundcard that has the OPL3 FM chip on it, so stop following this guide. If it is, you do indeed have the OPL3 FM chip; so continue following this guide.

Now you need to make the required modules load at boot. To do this, issue this command at the terminal:

gksudo gedit /etc/modules

When prompted, enter your password. Now, at the end of the file, add this:

snd-seq
snd-seq-device
snd-seq-midi
snd-seq-oss
snd-seq-midi-event
snd-opl3-synth

Then save the changes and exit gedit.

Now, we need to install the package "alsa-tools". You may need the multiverse and universe repositories enabled for this. If you haven't got them enabled and need help doing that, please refer to AddingRepositoriesHowto

Run this command in the terminal.

sudo aptitude install alsa-tools

Now, we are ready to load the instrument patches for it.

Run this command in the terminal:

sbiload -p 17:0 --opl3 /usr/share/sounds/opl3/std.o3 /usr/share/sounds/opl3/drums.o3

Please note, the port number (shown here as 17:0) may differ for you. Check the output of aplaymidi -l to make sure what the port number for the OPL3 is on your system.

Once that is done, we're ready to test it out. Here is a MIDI file to test it with: http://www.webpost.net/av/avatarmaster/patricksworld.mid

Now, run this command in the terminal:

aplaymidi -p 17:0 /path/to/file.mid

Remember, the port number might be different for you. Check the output of aplaymidi -l to make sure which one. If you can't hear anything, run "alsamixer" in a terminal and make sure the "synth" mixer item is not muted or set to a volume level of 0 or something.

If it all worked, you should be hearing some tinny old synth noises.


CategoryAudio CategoryHardware

Midi/HardwareSynthesisSetup (last edited 2010-08-03 08:42:21 by quequotion)