Skip to contentSkip to conversation

Testers Wanted: OPL3 hwdep loader interface

PATCH Takashi Iwai 3 participants 12 messages Oct 26, 2007 – Oct 31, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

one of big pending patches on my local tree is the removal of seq-instr interface. The only real user of instrument layer is OPL3 patch loader, and I'd like to move this to hwdep interface.

The patch below is to move the OPL3 patch loading to hwdep device. Two more patches will follow in other mails for alsa-lib addition and sbiload change.

Can someone test whether these patches work? Unfortunately, I have no hardware with OPL3 at this moment around here.

Thanks,

Takashi

drivers/opl3/opl3_lib.c +2 -0
diff -r 88d273f360dd drivers/opl3/opl3_lib.c
@@ -327,6 +327,7 @@ static int snd_opl3_free(struct snd_opl3
 	snd_assert(opl3 != NULL, return -ENXIO);
 	if (opl3->private_free)
 		opl3->private_free(opl3);
+	snd_opl3_clear_patches(opl3);
 	release_and_free_resource(opl3->res_l_port);
 	release_and_free_resource(opl3->res_r_port);
 	kfree(opl3);
@@ -521,6 +522,7 @@ int snd_opl3_hwdep_new(struct snd_opl3 *
 	/* operators - only ioctl */
 	hw->ops.open = snd_opl3_open;
 	hw->ops.ioctl = snd_opl3_ioctl;
+	hw->ops.write = snd_opl3_write;
 	hw->ops.release = snd_opl3_release;
 
 	opl3->seq_dev_num = seq_device;
drivers/opl3/opl3_midi.c +17 -24

112 lines not on this page · raw message

drivers/opl3/opl3_oss.c +27 -108

156 lines not on this page · raw message

drivers/opl3/opl3_seq.c +1 -21
diff -r 88d273f360dd drivers/opl3/opl3_seq.c
@@ -152,15 +152,7 @@ static int snd_opl3_synth_event_input(st
 {
 	struct snd_opl3 *opl3 = private_data;
 
-	if (ev->type >= SNDRV_SEQ_EVENT_INSTR_BEGIN &&
-	    ev->type <= SNDRV_SEQ_EVENT_INSTR_CHANGE) {
-		if (direct) {
-			snd_seq_instr_event(&opl3->fm_ops, opl3->ilist, ev,
-					    opl3->seq_client, atomic, hop);
-		}
-	} else {
-		snd_midi_process_event(&opl3_ops, ev, opl3->chset);
-	}
+	snd_midi_process_event(&opl3_ops, ev, opl3->chset);
 	return 0;
 }
 
@@ -249,16 +241,6 @@ static int snd_opl3_seq_new_device(struc
 		return err;
 	}
 
-	/* initialize instrument list */
-	opl3->ilist = snd_seq_instr_list_new();
-	if (opl3->ilist == NULL) {
-		snd_seq_delete_kernel_client(client);
-		opl3->seq_client = -1;
-		return -ENOMEM;
-	}
-	opl3->ilist->flags = SNDRV_SEQ_INSTR_FLG_DIRECT;
-	snd_seq_fm_init(&opl3->fm_ops, NULL);
-
 	/* setup system timer */
 	init_timer(&opl3->tlist);
 	opl3->tlist.function = snd_opl3_timer_func;
@@ -287,8 +269,6 @@ static int snd_opl3_seq_delete_device(st
 		snd_seq_delete_kernel_client(opl3->seq_client);
 		opl3->seq_client = -1;
 	}
-	if (opl3->ilist)
-		snd_seq_instr_list_free(&opl3->ilist);
 	return 0;
 }
 
drivers/opl3/opl3_synth.c +164 -0

170 lines not on this page · raw message

include/asound_fm.h +17 -0
diff -r 88d273f360dd include/asound_fm.h
@@ -112,4 +112,21 @@ struct snd_dm_fm_params {
 #define SNDRV_DM_FM_OSS_IOCTL_SET_MODE		0x24
 #define SNDRV_DM_FM_OSS_IOCTL_SET_OPL		0x25
 
+/*
+ * Patch Record - fixed size for write
+ */
+
+#define FM_KEY_SBI	"SBI\032"
+#define FM_KEY_2OP	"2OP\032"
+#define FM_KEY_4OP	"4OP\032"
+
+struct sbi_patch {
+	unsigned char prog;
+	unsigned char bank;
+	char key[4];
+	char name[25];
+	char extension[7];
+	unsigned char data[32];
+};
+
 #endif /* __SOUND_ASOUND_FM_H */
include/opl3.h +55 -3

84 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Takashi Iwai

Can someone test whether these patches work?

Will do.

Regards,
Clemens

#2 lore raw
In reply to Takashi Iwai
Quoted 10 lines · Takashi Iwai

one of big pending patches on my local tree is the removal of seq-instr interface. The only real user of instrument layer is OPL3 patch loader, and I'd like to move this to hwdep interface.

The patch below is to move the OPL3 patch loading to hwdep device. Two more patches will follow in other mails for alsa-lib addition and sbiload change.

Can someone test whether these patches work? Unfortunately, I have no hardware with OPL3 at this moment around here.

Working fine. Applied the patches against alsa-{kernel,lib,tools}-1.0.15.

rene@7ixe4:~$ aplaymidi -l
  Port    Client name                      Port name
  14:0    Midi Through                     Midi Through Port-0
  16:0    ESS ES1978 (Maestro 2E)          ESS ES1978 (Maestro 2E) MIDI
  20:0    CS4236B                          CS4236B MIDI
  21:0    OPL3 FM synth                    OPL3 FM Port
rene@7ixe4:~$ cat /proc/asound/hwdep
01-00: OPL3 FM
rene@7ixe4:~$ sbiload -D hw:1,0 -4 std.o3 drums.o3
rene@7ixe4:~$ aplaymidi -p 21:0 music/midi/jzz30xg.mid

<noise>

If you need/want me to, I can also test against an OPL2 (AdLib clone card) but I assume that'll be okay?

Rene.

#3 lore raw
Quoted 13 lines · Rene Herman

Working fine. Applied the patches against alsa-{kernel,lib,tools}-1.0.15.

rene@7ixe4:~$ aplaymidi -l
 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 16:0    ESS ES1978 (Maestro 2E)          ESS ES1978 (Maestro 2E) MIDI
 20:0    CS4236B                          CS4236B MIDI
 21:0    OPL3 FM synth                    OPL3 FM Port
rene@7ixe4:~$ cat /proc/asound/hwdep
01-00: OPL3 FM
rene@7ixe4:~$ sbiload -D hw:1,0 -4 std.o3 drums.o3
rene@7ixe4:~$ aplaymidi -p 21:0 music/midi/jzz30xg.mid
Quoted 4 lines

<noise>

If you need/want me to, I can also test against an OPL2 (AdLib clone card) but I assume that'll be okay?

rene@6bap:~$ aplaymidi -l
  Port    Client name                      Port name
  14:0    Midi Through                     Midi Through Port-0
  16:0    OPL2 FM synth                    OPL2 FM Port
rene@6bap:~$ cat /proc/asound/hwdep
00-00: OPL2 FM
rene@6bap:~$ sbiload -D hw:0,0 std.sb drums.sb
rene@6bap:~$ aplaymidi -p 16:0 midi/jzz30xg.mid

<same noise>

So, OPL2 same deal. However -- there is a problem after all. With this as the source file:

http://members.home.nl/rene.herman/opl3/jzz30xg.mid

using the old sbiload with the sb and o3 patches respectively, produces:

http://members.home.nl/rene.herman/opl3/jzz30xg-cs4236b_opl3-seq-sb.ogg
http://members.home.nl/rene.herman/opl3/jzz30xg-cs4236b_opl3-seq-o3.ogg

while with the new hwdep sbiload, I hear:

http://members.home.nl/rene.herman/opl3/jzz30xg-cs4236b_opl3-hwdep-sb.ogg
http://members.home.nl/rene.herman/opl3/jzz30xg-cs4236b_opl3-hwdep-o3.ogg

While much less annoying... something's still missing. The former are how they are supposed to be rendered. A problem with the "drums"?

Rene.

#4 lore raw
Quoted 2 lines · Rene Herman

However -- there is a problem after all. [...] While much less annoying... something's still missing.

Several instruments aren't played at all, at least those with program number 40 and up (strings) and 64 and up (saxophones).

Regards,
Clemens

#5 lore raw

At Mon, 29 Oct 2007 08:41:40 +0100,

Quoted 7 lines · Clemens Ladisch
Quoted 2 lines · Rene Herman

However -- there is a problem after all. [...] While much less annoying... something's still missing.

Several instruments aren't played at all, at least those with program number 40 and up (strings) and 64 and up (saxophones).

OK, how about the revised patch below to alsa-tools?

thanks,

Takashi

seq/sbiload/README +20 -40
diff -r 9b306261208b seq/sbiload/README
@@ -1,4 +1,4 @@ This is sbiload - an OPL2/3 FM instrumen
-This is sbiload - an OPL2/3 FM instrument loader for ALSA sequencer
+This is sbiload - an OPL2/3 FM instrument loader for ALSA hwdep
 
 Written by Uros Bizjak <[email protected]>
 Web: http://www.kss-loka.si/~uros/sbiload.html
@@ -14,62 +14,42 @@ By default it will install into /usr/loc
 By default it will install into /usr/local/bin, change INSTDIR in
 make.conf to change this.
 
-Before use
-----------
-
-Please check that the correct sequencer modules are loaded for your
-sound card. You need to load snd-synth-opl3 module.
-
 Usage
 -----
 
-	loadsbi [-p client:port] [-4] [-l] [-P path] [-v level] instfile drumfile
+	loadsbi [-D device] [-4] [-P path] [-v level] instfile drumfile
 
-	  -p, --port=client:port  - An ALSA client and port number to use
+	  -D, --device=name       - An ALSA hwdep name to use
 	  -4  --opl3              - Four operators (OPL3) file type
-	  -l, --list              - List possible output ports
 	  -P, --path=path         - Specify the patch path
 	  -v, --verbose=level     - Verbose level
 
-Because you may have more than one sound card and each sound
-card may have several MIDI connections, you have to tell sbiload
-which one to use.
+When you have multiple sound cards and/or there may be multiple OPL2/3
+synth devices, you have to tell sbiload which one to use, and pass its
+hwdep name via -D option.  Otherwise, sbiload will load the data onto
+the first found device.
 
-First find out what the possibilities are for your system:
+To find out the hwdep name of the OPL devices,  check
+/proc/asound/hwdep file first.  It has the list of hwdep devices
+currently available on your system.
 
-If you run: 
-	
-	sbiload -l
+	% cat /proc/asound/hwdep
+	00-00: Emux WaveTable
+        00-01: OPL3 FM
+	01-00: OPL3 FM
 
-it will give you a list of the devices. On my system I get: 
-	
-	 Port     Client name                       Port name 
-	 64:0     0: MIDI Synth                     MIDI 0-0 
-	 65:0     OPL3 FM Synth                     OPL3 FM Synth port
+In the example above, you have two OPL3 devices.  To the first one
+(00-01), which means the first card (00-) and the second device (01),
+pass "-D hw:0,1".  For the second OPL3 device (01-00), pass "-D
+hw:1,0" instead.
 
-
-Only OPLx FM Synth port can be used with sbiload. In the example above
-the first one is the external Midi port, and the second is the internal
-four-operator FM synthesizer (OPL3).
-
-If you don't see anything listed then check that the correct ALSA
-modules are loaded as in the section "Before use".
 
 Running sbiload
 ---------------
 
-You specify the port to use with the -p option, or by setting the
-environment variable ALSA_OUT_PORT. 
+Pass the instrument and drum file data as arguments.
 
-For example to use port 0 on client 65 to load four-operator FM
-instrument
-	
-	sbiload -p 65:0 --opl3 std.o3 drums.o3
-
-or 
-	
-	export ALSA_OUT_PORT=65:0 
-	sbiload --opl3 std.o3 drums.o3 
+	% sbiload std.o3 drums.o3
 
 
 Acknowledgements
seq/sbiload/sbiload.c +162 -400

760 lines not on this page · raw message

#6 lore raw
Quoted 7 lines · Takashi Iwai

At Mon, 29 Oct 2007 08:41:40 +0100,

Quoted 2 lines · Clemens Ladisch

Several instruments aren't played at all, at least those with program number 40 and up (strings) and 64 and up (saxophones).

OK, how about the revised patch below to alsa-tools?

Yes, I believe my OPL3 is back to its good ol' horrible self again with that version.

Do you by the way know of other, nicer and/or better patches than the supplied std and drums? Couldn't find any, at least not in the correct format it seems.

[ README ]

seq/sbiload/README By default it will install into /usr/loc · line 52

Quoted 2 lines
seq/sbiload/README +1 -1
-	sbiload --opl3 std.o3 drums.o3 
+	% sbiload std.o3 drums.o3

Should the example indeed lose the --opl3?

Rene.

#7 lore raw

At Mon, 29 Oct 2007 17:51:23 +0100,

Quoted 6 lines · Rene Herman
Quoted 2 lines · Takashi Iwai

At Mon, 29 Oct 2007 08:41:40 +0100,
Clemens Ladisch wrote:

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Several instruments aren't played at all, at least those with program number 40 and up (strings) and 64 and up (saxophones).

OK, how about the revised patch below to alsa-tools?

Yes, I believe my OPL3 is back to its good ol' horrible self again with that version.

Thanks. Then I'll commit the changes tomorrow until someone finds regressions.

Quoted 3 lines

Do you by the way know of other, nicer and/or better patches than the supplied std and drums? Couldn't find any, at least not in the correct format it seems.

Hm, I don't know of others. It'd be fun to play with OPL3 parameter adjustment, though ;)

Quoted 6 lines

[ README ]

seq/sbiload/README By default it will install into /usr/loc · line 52

Quoted 2 lines
seq/sbiload/README +1 -1
-	sbiload --opl3 std.o3 drums.o3 
+	% sbiload std.o3 drums.o3

Should the example indeed lose the --opl3?

With the patch in the previous mail, yes, it's needed. But my latest version that will be committed doesn't need --opl3 option. You can invoke like

% sbiload std drums

and the format and the extension will be chosen automatically according to the hwdep iface type.

Takashi

#8 lore raw
Quoted 6 lines · Takashi Iwai
Quoted 3 lines

Do you by the way know of other, nicer and/or better patches than the supplied std and drums? Couldn't find any, at least not in the correct format it seems.

Hm, I don't know of others. It'd be fun to play with OPL3 parameter adjustment, though ;)

I was thinking of whether or not the standard patches shouldn't simple be builtin but anyone playing with an OPL3 these days is sort of by definition going for the geekness factor I guess. From that viewpoint, external patches do sound better...

Quoted 6 lines
Quoted 5 lines

[ README ]

seq/sbiload/README By default it will install into /usr/loc · line 52

Quoted 2 lines
seq/sbiload/README +1 -1
-	sbiload --opl3 std.o3 drums.o3 
+	% sbiload std.o3 drums.o3

Should the example indeed lose the --opl3?

Quoted 8 lines

With the patch in the previous mail, yes, it's needed. But my latest version that will be committed doesn't need --opl3 option. You can invoke like

% sbiload std drums

and the format and the extension will be chosen automatically according to the hwdep iface type.

Sounds great (assuming that I'll still be able to load the .sb patches into my OPL3 by just specifying std.sb and drums.sb ofcourse).

I believe that at that point you by the way might also make a simple "sbiload" enough, with the names defaulting to "std" and "drums"...

(and a -2 switch to pick std.sb and drums.sb even on an OPL3)

Rene.

#9 lore raw
Quoted 3 lines · Rene Herman
Quoted 2 lines · Takashi Iwai
Quoted 2 lines

Yes, I believe my OPL3 is back to its good ol' horrible self again with that version.

Here too.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Do you by the way know of other, nicer and/or better patches than the supplied std and drums? Couldn't find any, at least not in the correct format it seems.

I think I could poke around in some old Yamaha driver ...

Quoted 7 lines
Quoted 2 lines

Hm, I don't know of others. It'd be fun to play with OPL3 parameter adjustment, though ;)

I was thinking of whether or not the standard patches shouldn't simple be builtin but anyone playing with an OPL3 these days is sort of by definition going for the geekness factor I guess. From that viewpoint, external patches do sound better...

Trying to get General MIDI out of this chip doesn't do it justice.

Maybe I should put opledit into alsa-tools ...

Regards,
Clemens

#10 lore raw
Quoted 5 lines · Clemens Ladisch
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Do you by the way know of other, nicer and/or better patches than the supplied std and drums? Couldn't find any, at least not in the correct format it seems.

I think I could poke around in some old Yamaha driver ...

Wouldn't mind that...

Quoted 3 lines

Trying to get General MIDI out of this chip doesn't do it justice.

Maybe I should put opledit into alsa-tools ...

Nor that. I'm not all that familiar with the OPL (nor anything MIDI related in fact) but given my depository of ISA cards most of which have one, I sure do have a lot of them....

Rene.

#11 lore raw
In reply to Clemens Ladisch

At Tue, 30 Oct 2007 09:24:42 +0100,

Quoted 4 lines · Clemens Ladisch
Quoted 4 lines
Quoted 3 lines

Hm, I don't know of others. It'd be fun to play with OPL3 parameter adjustment, though ;)

Quoted 8 lines
Quoted 4 lines

I was thinking of whether or not the standard patches shouldn't simple be builtin but anyone playing with an OPL3 these days is sort of by definition going for the geekness factor I guess. From that viewpoint, external patches do sound better...

Trying to get General MIDI out of this chip doesn't do it justice.

Maybe I should put opledit into alsa-tools ...

It's a good idea. Better to keep alive in the repo than leaving in wild.

Takashi