2007-12-05

How to get Timidity to work (more or less) as a software synth with OSS 4

Posted in General at 7:00

Note: This is still fragile, so I can’t help you if it doesn’t work on your system.

I finally got around to trying OSS 4 and I just can’t go back to ALSA. Not only is it less cantankerous, the mixer curve I get by leaving my soundcard on defaults and adjusting the vmix in-kernel mixer is much nicer.

Unfortunately, there was one problem. MIDI support for OSS 4 is still in development and I have old Windows games which use MIDI for their background music. With ALSA, I had been using Timidity as a software synth that Wine could hook into, but I couldn’t get that to work with libsalsa (the OSS 4 ALSA compatibility layer) so I decided to look for an alternative.

It’s a jerry-rig, but I figured out how to strap the ALSA userland onto OSS 4 so that Wine has a way to get MIDI events to Timidity. Details below…

Step 1: Install OSS

(Remember to symlink /dev/dsp to your preferred /dev/dspN if it forgets.)

Make sure alsa-lib (or your equivalent) stays installed and that the lines in /usr/sbin/soundon
for setting up libsalsa are commented out. (The ebuild on bugs.gentoo.org which I used comes with a patch to
do this)

If you want to do this yourself, find the line which says “# Use library based ALSA compatibility”
and comment out the block which follows it. If you don’t know how to do this, I suggest grabbing
the patch from bugs.gentoo.org.

If you want to use the ebuild, it’s at Bug 184123.

Step 2: Create an /etc/asound.conf

It should contain only the following:


pcm.!default {
        type oss
        device /dev/dsp
}

Step 3: Set up your ALSA kernel modules

Set up the following ALSA config in your kernel:


Device Drivers --> Sound -->
	<M> Sound card support
	Advanced Linux Sound Architecture  --->
		<M> Advanced Linux Sound Architecture
		<M>   Sequencer support
		[*]   Support old ALSA API

The following were something I tested but didn’t see any difference to. Your mileage may vary.


		<M>   RTC Timer support
		[*]     Use RTC as default sequencer timer

Everything else should be disabled.

Step 4: Adjust your init scripts

Make sure your init scripts successfully load OSS 4 and then adjust them to run “modprobe snd-seq” after it has checked and found no ALSA.

Step 5: Set up Timidity

This part took the the longest to figure out. Timidity is VERY fickle in this setup, so your mileage may vary. Here’s what I had to do:

  • Timidity had to be run from inside my KDE session. (not from an initscript)
  • I had to use artsdsp and set Timidity to use ALSA output

The command I used was “artsdsp timidity -iA -Os” but the -Os was just to make sure. (It was default on my system)

The second-best I found was “timidity -iA -Op” (Portaudio output without artsdsp) and it could be run from an initscript, but it would go silent after the first song or two.

Plain ordinary ALSA output had a similar problem, but also had timing glitches. Ironically, when Timidity is just playing a midi file directly as opposed to receiving MIDI events via ALSA, the timing glitches are absent.

RSS feed for comments on this post · TrackBack URL

Leave a Comment

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.

Bad Behavior has blocked 266 access attempts in the last 7 days.