Skip to contentSkip to conversation

AD1889 OPL3 Synthesis

parisc-linux Stuart Brady 1 participant 2 messages Jun 26, 2005

lore
Share & tools
lore
#0 lore raw

I thought I'd explain what's needed to get the AD1889's OPL3 synthesis working. (BTW, OPL3 synthesis is pretty primative.)

ALSA provides everything needed to use the OPL3 device. Most drivers initialise the hardware if necessary, and then call snd_opl3_create() followed by snd_opl3_hwdep_new(). snd_opl3_free() is automatically called by the ALSA layer when the module is unloaded, so there's no need to call it explicitly.

snd_opl3_create() takes port addresses, so I've had to add a new function, snd_opl3_create_mapped(). This isn't in mainline 2.6.12 yet.

I'm not happy with the snd_opl3_create_mapped() interface yet... The AD1889 driver maps the region containing the OPL3 registers, but the OPL3 driver does the iounmap(). I've been told that this is the right way to do it, but it still seems broken.

There should only be one change needed to get the AD1889 OPL3 support working though. The DS_SYDA register has to be set, so that it's not muted, and that the attenuation is set reasonably. Which is either:

	ad1889_writew(chip, AD_DS_SYDA, 0x3f3f);
	ad1889_readw(chip, AD_DS_SYDA);

or the constant should be 0x0000 rather than 0x3f3f.

I used playmidi for testing. There are some example MIDI files:
/usr/share/doc/playmidi/examples/*.mid.gz. Unfortunately, ALSA's OPL3 code has some bugs which affect the quality of the music produced. Also, playmidi's instruments need some work.

I was getting silence when testing before, but it otherwise appeared to be working. There's probably a mixer channel associated with the OPL3 (or SYN, see below) which must be used. I have no idea which this is.

It seems that if the SYEN bit in the DS_WSMC register is set, this enables a secondary wave channel (which is called SYN, just to be confusing) and _disables_ the OPL3 - which results in an HPMC if an attempt is made to use the OPL3's registers.

The RES channel appears to be take the output of the SYN channel or the OPL3 (whichever is enabled), resampling it at the rate specified by the DS_RES register. It looks as though the SYN channel's sample rate and format is always that of the WAV channel, which limits its use.

Signature · 5 lines
Stuart Brady
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
#1 lore raw
Quoted 8 lines · Stuart Brady

I used playmidi for testing. There are some example MIDI files:
/usr/share/doc/playmidi/examples/*.mid.gz. Unfortunately, ALSA's OPL3 code has some bugs which affect the quality of the music produced. Also, playmidi's instruments need some work.

I was getting silence when testing before, but it otherwise appeared to be working. There's probably a mixer channel associated with the OPL3 (or SYN, see below) which must be used. I have no idea which this is.

I forgot to mention -- there seems to be another bug in ALSA: before you can play anything, you'll have to run:

cat /proc/asound/seq/clients

I've no idea why, and I haven't got around to reporting it to the ALSA developers yet. If you don't do this, you'll see:

playmidi: No playback device found.

Also, if you try to play the example MIDI files using playmidi, without gunzipping them first, playmidi will just segfault.

BTW, playmidi produces better sound if it is passed the "-4" option, but this reduces the number of notes that can be played simultaneously.

You could also try using pmidi, which doesn't rely on OSS emulation, although this didn't work for me.

If anyone's looking for a more sensible way to play MIDI files, I would suggest using TiMidity++, which doesn't use OPL3.

Cheers,

Signature · 5 lines
Stuart Brady
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux