## Why midi

With nowadays mp3 files, the midi files were never appeal to me, even with the WaveTable synthesizer, because I know hardware based WaveTable synthesizer might really sounds good, but they are not as good as mp3s. Moreover, the midi support under Linux has always been limited, so I never bother to figure it out, until now.

Why midi now? Because I've just found out the ABC music notation language (http://www.walshaw.plus.com/abc/).

The ABC music notation language is a wonderful tool to typeset sheet music. ABC is one of the best designed, easy to use, well-thought out, and nicely implemented notation formats I've ever seen: IMHO, it surpasses other good notation languages like GNU Lilypond or MusiXTeX. (Philip's Music Writer is a serious contender though.) You can write music in a very simple ASCII format and convert it to MIDI, or typeset it to make professional-looking scores.

— http://abcplus.sourceforge.net/

I'm always a big fan of documenting complicated things using plain text. With ABC to notate music in plain text, even as complicated as Beethoven's Symphony No. 7, (http://www.ucolick.org/~sla/abcmusic/sym7mov2.html), music notations can be easily and portably stored or transported electronically. IMHO, midi is the notation for music instruments; while ABC is the notation for human, and computer too. For machine to analyze tunes (via artificial intelligence), plain text based notation is the first step.

A common editor such as vi or emacs is all that is needed to write an abc file. After the file has been written, it can be converted to a standard MIDI file using abc2mid or to a print-ready format using abc2mtex (MusicTeX), abc2ps (PostScript) or abc2pdf (Adobe PDF).

— http://www.linuxjournal.com/article/8629

With ABC notation, one can not only produce professional-looking scores, or MIDI sound files, but also can translate MIDI files into plain text notations as well, with the help of Midi2abc (YAPS, http://abc.sourceforge.net/abcMIDI/).

References:

Abc collections http://www.walshaw.plus.com/abc/tunes.html There are now a large number of abc-notated tunes available on the internet (mostly folk & traditional).

documented on: 2008-05-28, xpt

## Play abc files via midi under Debian

Here is the simplest way to play abc files under Debian (all commands are run from command line).

First, enable your system to play midi files. The following simple steps will guarantee that you can play midi, no matter what sound card you may have. If you have sound card that has hardware support to play midi, you can also try to install the proper sound card midi driver if you want.

1. Make sure your sound system is working, e.g., you can play mp3 or wave files.

2. Install the 'timidity' and 'freepats' packages

$aptitude install timidity freepats The following NEW packages will be installed: freepats libflac8 timidity 0 packages upgraded, 3 newly installed, 0 to remove. Need to get 29.5MB/29.7MB of archives. After unpacking 36.1MB will be used. 3. Optionally install the playmidi package if you don't have a mid file to test that will surely work. $ aptitude install playmidi
gunzip < /usr/share/doc/playmidi/examples/jazz.mid.gz > jazz.mid
4. Play the midi file using timidity

timidity jazz.mid

If everything works fine, you should be able to hear the midi song. Else check the rest of this note collection for troubleshootings.

Now, we get to the playing abc files part.

1. Install the 'abcm2ps' and 'abcmidi' packages. The abc2mps has became the main standard for creating PostScript files from ABC files; the abcmidi package consists of several programs: abc2midi, abc2abc, and midi2abc. Check http://abc.sourceforge.net/abcMIDI/ for details.

$aptitude install abcm2ps abcmidi The following NEW packages will be installed: abcm2ps abcmidi 0 packages upgraded, 2 newly installed, 0 to remove. Need to get 242kB of archives. After unpacking 614kB will be used. 2. Prepare a abc file. The sample file I used here is from http://www.linuxjournal.com/article/8629. Use your favorite editor to create a file Scale.abc: X:1 T:A Scale In C C:DLP M:4/4 L:1/4 K:C C D E F | G A B c |1 c/2B/2A/2G/2 | F/2E/2D/2C/2 :|2 c4 || 3. Convert the abc file as midi file. $ abc2midi Scale.abc
writing MIDI file Scale1.mid
4. Now play it.

\$ timidity Scale1.mid
Playing Scale1.mid
MIDI file: Scale1.mid
Format: 0  Tracks: 1  Divisions: 480
Sequence: A Scale In C
Playing time: ~15 seconds
Notes cut: 0
Notes lost totally: 0

That's it. Now go crazy and download every abc file available from the Internet, starting from the sites listed in this note collection. :-)

documented on: 2008-05-29, xpt

## Three Steps to MIDI on Linux

By harishankar at 2006-02-17

I've always wanted to document any tricky steps to getting things done in Linux and MIDI is a very tricky one indeed. In fact, for most of us, the only way to play MIDI music is to install TiMidity++ and use it as an ALSA sequencer. I've struggled though, in the past, due to lack of documentation for this and so decided to share my knowledge in a place where others can easily get the bigger picture without getting confused with the details. Note that this is not an extensive article and will not go in-depth into each step, but only to serve as a general guide to MIDI on Linux.

I assume that you've properly installed and configured ALSA drivers and sound generally works in your system. Also I assume that you have a fair idea of how to install and uninstall packages for your particular distribution or know how to compile from source.

The three steps are then:

1. Install TiMidity++. If you are a Debian user, this package is available in the official repositories. Other binary versions may be available. You can also compile from source. Instructions and download location available at the TiMidity website. Binary packages for select distros:

• Debian package

• Slackware binaries

• RPM packages

2. Get some good sound patches — You will also need to download and install additional sound fonts and configure the software. Debian users can use Freepats. But I recommend the eaw patches which are of higher quality. No Debian packages are available, but luckily you can just download it and extract it in any location. You can download the tar.gz at http://gentoo.mirrors.pair.com/distfiles/eawpats12_full.tar.gz. Just extract it into your home directory. Let's say /home/hari/eawpats.

3. Replace the default TiMidity++ timidity.cfg file (rename the old file to something like timidity.conf.old) with the one in the /home/hari/eawpats/linuxconfig folder. Just edit it to make sure the location points to the directory where you extracted the EAW patches. The config file is located usually in the /etc/timidity/ folder in Debian. I don't know about other distros. Here is how the file looks like. Just change the dir setting to whichever location you extracted the EAW patches to:

dir /home/hari/eawpats/
source gravis.cfg
source gsdrums.cfg
source gssfx.cfg
source xgmap2.cfg
#mid -> wav: timidity input.mid -Ow1S -s 44100 -o output.wav

All right, you've now installed it. To test it, you need to play a MIDI file. If you have one, just run

timidity filename.mid

from the command line and enjoy the music! If timidity fails with an error message, just check the timidity.cfg file to make sure the path to your patches directory is correct. The EAW patches are excellent and much better than the freepats package in Debian, so the extra trouble to download and install it is worth it.

Now you have got MIDI playback. What if you want to use TiMidity++ as your ALSA sequencer device? Well, for this you have to issue this command from the command line:

timidity -iA -B8,2 -Os

This basically means that you are running timidity as an ALSA sequencer device (-iA) and you've set the buffer fragmensts to 8,2 (-B8,2) and the output device as ALSA (-Os). There you go. Now you can play MIDI files from KDE also. Don't forget to check out the TiMidity++ man and documentation pages as well.

You must run the above command every time you boot Linux if you want to use TiMidity++ as an ALSA back end so that you can play MIDI files from KDE (KMid) without using the timidity command line every time. The added advantage is that you can use MIDI composing tools like NoteEdit or Rosegarden without any additional setup because ALSA automatically recognizes the MIDI devices. So I recommend that you add this command to your startup scripts.

documented on: 2008-05-28

## How to play midi files

http://bbs.archlinux.org/viewtopic.php?pid=273986

I tried to use timidity, which is supposed to be able to play midi by synthesizing it itself. . . I EVENTUALLY noticed some passing mention of soundfonts and discovered that these are required. Why isn't this mentioned in any howtos anywhere? Anyway, armed with this valuable but neglected information I downloaded the yamaha DX7 soundfont from hammersound.net, and added it to the timidity config file.

I'm still getting the following message:

No instrument mapped to tone bank 0, program 48 - this instrument will not be heard

### How to play midi files

"this instrument will not be heard" messages mean your soundfont is incomplete. There are sites which have free soundfonts but they usually only satisfy a certain niche (e.g. drum kits, piano kits)

What you want for playing midi files is a General Midi soundfont. http://en.wikipedia.org/wiki/General_Midi http://en.wikipedia.org/wiki/Soundfont

Check out the soundfonts in aur.

documented on: 2007-08-17, Gilneas

### How to play midi files

midi files contain notes for a song, then you need instruments to play those notes.

Now some soundcards have ram on em that contain soundfonts, ie prerecorded instruments that can be used to play those notes.

If you dont have a soundfont soundcard, you can still use the notes to control soft synths etc to get sound or use timidity to play them with downloaded soundfonts.

Now using progs like soundgarden the notes dont usually automatically get sent to righ instrument, thus ports are need to know what instument plays what notes.

BTW

i got asus and nforce too and the spdiff was pain in the arse to setup. although midis work:

Install timidity, install fluidr3 (soundfont), get some midifiles http://www.mididb.com/ , play with timidity:

timidity download/Unforgiven.mid

works for me.

documented on: 2007-08-17, Mikko777

## ALSA midi support

http://hatari.sourceforge.net/docs/alsa-midi.txt

If you don't have a real MIDI sequencer, use a software synthetizer.

### Making MIDI soft-synthetizer to work with ALSA

Make Timidity into an ALSA output device with:

timidity -Os -iA

(-O: output=alsa, -i: interface=alsa)

To make it use less CPU and be more responsive, use:

timidity -Os -iA -B2,8 -EFreverb=0 -EFchorus=0

(-B: 2,8=set small buffers, -EFx=0: disable effects)

Make vkeybd (virtual midi keyboard app) into an ALSA input device with:

vkeybd

View the resulting (software) ALSA input and output devices:

aconnect -i -o

Then connect the vkeybd input to timidity output with:

kaconnect

or if you don't have this UI program, just use 'aconnect' directly:

aconnect <sender port> <receiver port>

Now you can use the virtual midi keyboard for testing the sound synthesis.

Finally You can test how well midi files are played. Check which ALSA port Timidity provides:

aplaymidi -l

And use that port for playing a midi file:

aplaymidi -p <port, e.g. 129:0> test.mid

(or use 'pmidi')

Note: Remember that you need to re-connect the (virtual) device ports each time you restart them.

### Using FluidSynth instead of Timidity

Instead of Timidity, you also use other soft-synthetizers, like FluidSynth:

fluidsynth --audio-driver=alsa --midi-driver=alsa_seq soundfont.sf2

You could play a bit with other options to get more performance, sound volume etc:

--reverb=no --chorus=no -o synth.polyphony=16 --gain=0.6

And if you don't like the FluidSynth shell, use:

--no-shell --server

#### Software

Vkeybd
Patch (ALSA connecting) utilities
FluidSynth
Soundfonts
List of some soft-synthetizers
socat
MidiMaze

#### Overviews

ALSA midi overview
Virtual midi hardware setup
Timidity Howto
Midi with ALSA (old)
Midi on Linux

documented on: 2008-05-28

### Playing Midi files for Intel AC'97

http://lists.linuxcoding.com/rhl/2007q2/msg13488.html

Try starting timidity like this:

timidity -iA -Os -B2,8 --reverb 0 --realtime-priority 1

and then see what aplaymidi -l says.

Andras

## Play MIDI under GNU/Linux with ALSA

http://bertrandbenoit.blogspot.com/2008/05/play-midi-under-gnulinux-with-alsa.html

There is lots of articles on the subject but it is not so trivial to get needed information to use ALSA tools to play MIDI files.

This is some quick information:

• the first is obviously to have a working ALSA installation,

• if you have several sound cards, ensure the default is well the wanted one (for instance using system-config-soundcard under Fedora),

• then it is important to ensure not having mute channel(s), you can use alsamixer for this,

• then ensure to have a way to load soundfonts into the wavetable of the sound card; for instance of sound card managed AWE32/Emu10k1 sound driver, you can install the awesfx package

yum install awesfx
• get a soundfonts to load, for instance this one,

• at any moment, to check if there is a loaded soundfonts:

cat /proc/asound/card?/wavetableD?
• you can clear currently loaded soundfounts but you want to keep it:

/bin/asfxload -i

/bin/asfxload
• find the "addresses" into the "/proc/asound/card?/wavetableD?" file (for instance: 17:0 17:1 17:2 17:3),

• finally test installation using aplaymidi to play a MIDI file

aplaymidi -p "addresses"* "MIDI file path"
• addresses must be coma separated, 17:0,17:1,17:2,17:3 for instance.

documented on: 27 May 2008, Bertrand BENOIT

## MIDI Web resources

Sound in Debian GNU/Linux http://newbiedoc.berlios.de/wiki/Sound_in_Debian_GNU/Linux

### The Linux MIDI-HOWTO

By Phil Kerr v1.20, May 2002

1. Introduction.

3. Where to get this document.

4. Acknowledgments.

5. Disclaimer.

6. Background to MIDI.

7. Configuring MIDI devices.

• 7.1 ALSA 0.9 quick install

• 7.2 Latency

8. Software.

• 8.1 Drivers

• 8.2 MIDI file players

• 8.3 Sequencers

• 8.4 MIDI Trackers

• 8.5 Drum editors

• 8.6 Patch editors

• 8.7 Software synths

• 8.8 Plugins

• 8.9 Notation

• 8.10 Development

9. MIDI Development.

• 9.1 Example 1

• 9.2 Example 2

• 9.3 Example 3

10. HOWTO Use MIDI Sequencers With Softsynths.

• 10.1 Introduction

• 10.2 Device Setup

• 10.3 Routing MIDI Events

• 10.4 Graphical MIDI Patch Bays

• 10.5 Applications

• 10.6 Sequencers

• 10.7 Software Synthesizer

• 10.8 Acknowledgments

12. Feedback.

### Sound & MIDI Software For Linux

Sound & MIDI Software For Linux http://linux-sound.org/

The purpose of this page is to indicate what Linux sound and music tools I personally use on a regular basis… many other apps are as important and/or evolved, but I use them far less frequently. Think of this page as a proof that Linux sound and music software is certainly mature enough to use for a power-user's desktop studio.

The selected applications all share the following characteristics:

• usability

• stability

• maturity

• development longevity

CD Software
Csound & Cmix Helpers
Demos
Digital DJ
Documentation/Newsworthy
Drumming
DSP Software
Emulators
Effects Processors
File Compression
File Conversion
Games & Game Software
Guitar Software
Java Miscellanea
Linux Audio Bundles & Distributions
Linux Music On-line
Mailing Lists
MIDI Software
Mixers
MOD Trackers/Players/Resources
MPEG (MP3) Players/Encoders
Multitrack Recorders/Mixers
Music Notation
Musicians Utilities
Network Audio
OggVorbis Software
Other Sound+MIDI Pages
Other UNIX Audio and MIDI Software
Players & Recorders
Repositories
Scopes
Software Synthesis
Software Tools
Sound Cards & Drivers
Soundfile Editors
Speech Synthesis/Analysis
Telephony/AV Conferencing

## Midi editor

Newsgroups:  gmane.linux.debian.user
Date:        Mon, 20 Feb 2006 08:36:51 +0000
 > > I'm trying to create some midi file. I'm using etch.
[snip]
> > If anyone has suggestion, they warmly welcome !
> Hi,
> I'd second rosegarden

Nah, after years of struggling with NWC, abc, Noteedit, Rosegarden etc, I gave up and swung over to Lilypond. It does things the Linux way. Super.

Joe

### Midi editor

> But can I generate a midi file with it ? (I don't want to print it, just
> listen to it )

Yes, here's an example: (try to get a 2.6 version, I am on Debian testing. I am not sure about chords, or complex stuff)

\version "2.6.3"
composer =  ""
piece = "Raspberry Jam"
dedication = "For Molly Daly"
}
}
melody = \relative c' {
\clef treble
\key g \major
\time 6/8
\repeat volta 2 { %TUNE_START
b'8    d8    d8    d8 b8    d8    \bar "|" e8    fis8    g8    d8
b8    g8 \bar "|" c8    b8    a8    b8    a8    g8    \bar "|" a8
g8 e8    g8    e8    d8    \bar "|" g8    d'8    d8    d8    b8 d8
\bar "|" e8    fis8    g8    d8    b8    g8        \bar "|" c8    b8
a8    b8    a8    g8    \bar "|" d8    g8    fis8 g4.              \bar "|"
}
}
\repeat volta 2 {
d'8    e8    fis8    g8    d8    b8    \bar "|" g'8    d8 b8    g'8
d8    b8    \bar "|" d8    e8    fis8    g8    d8  b8    \bar "|" c8
a8    a8    a4.    \bar "|"
g8    d'8    d8    d8    b8    d8    \bar "|" e8    fis8    g8    d8
b8 g8        \bar "|" c8    b8    a8    b8    a8    g8    \bar "|" d8
g8    fis8    g4.
} % TUNE_END
}
}
\score {
\new Staff \melody
\layout { }
\midi { \tempo 4=60 }      %%%%%%%%%%%%%  MIDI FILE %%%%%%%%%%%%%
}
}

Joe

### Midi editor

> I'd second rosegarden
> use timidity for playing midi and look for freepats for midi sound
> files.

Timidity and freepats works correctly, it's just rosegarden that I don't manage to install.

Pooly