[Pkg-alsa-devel] Bug#246405: alsa-base: soundfont loading

Darren Salt Darren Salt <linux@youmustbejoking.demon.co.uk>, 246405@bugs.debian.org
Wed, 28 Apr 2004 20:07:27 +0100


This message is in MIME format which your mailer apparently does not support.
You either require a newer version of your software which supports MIME, or
a separate MIME decoding utility.  Alternatively, ask the sender of this
message to resend it in a different format.

--909895135--1698439453--470436753
Content-Type: text/plain; charset=us-ascii

Package: alsa-base
Version: 1.0.4-2
Severity: wishlist
Tags: sid patch

The attached patch allows alsa-base to load a sound font file on startup,
which is useful for those of us who have sound cards such as the SB Live.
There are configuration options for the file name and for any extra options
for asfxload.

With this patch applied, alsa-base should be modified such that it either
Recommends: or Suggests: awesfx (>= 0.5).

-- 
| Darren Salt   | nr. Ashington, | linux (or ds) at
| woody, sarge, | Northumberland | youmustbejoking
| RISC OS       | Toon Army      | demon co uk
|   Oh, sarge too...

A man with one watch knows what time it is; a man with two is never sure.

--909895135--1698439453--470436753
Content-Type: text/plain; charset=iso-8859-1; name="alsa-soundfont.patch"
Content-Disposition: attachment; filename="alsa-soundfont.patch"
Content-Transfer-Encoding: quoted-printable

--- alsa-driver-1.0.4~/debian/alsa-base.conf
+++ alsa-driver-1.0.4/debian/alsa-base.conf
@@ -14,3 +14,13 @@
 # Valid syntax same as a regular expression character range, with the
 # restriction that only valid runlevels are allowed.
 runlevels_save=3D'[2-5]'
+
+# If your sound card (or one of your sound cards) has a built-in MIDI sy=
nth
+# and uses sound fonts, you can put the name of it here, or leave it bla=
nk to
+# not load anything.
+# The file will be loaded using asfxload (package "awesfx").
+soundfont=3D""
+
+# Extra options for asfxload. The default is "-i"; you shouldn't need to=

+# change it.
+soundfontopts=3D""
--- alsa-driver-1.0.4~/debian/alsa-base.config
+++ alsa-driver-1.0.4/debian/alsa-base.config
@@ -12,5 +12,7 @@
 done
=20
 db_input low alsa-base/alsactl_store_on_shutdown || true
+db_input medium alsa-base/soundfont || true
+db_input low alsa-base/soundfontopts || true
 db_go
=20
--- alsa-driver-1.0.4~/debian/alsa-base.init
+++ alsa-driver-1.0.4/debian/alsa-base.init
@@ -12,6 +12,8 @@
 # Default settings
 alsactl_store_on_shutdown=3D"autosave always"
 runlevels_save=3D'[2-5]'
+soundfont=3D""
+soundfontopts=3D"-i"
=20
 [ -e /etc/default/alsa ] && . /etc/default/alsa
=20
@@ -25,6 +27,15 @@
 	    echo "       You may want to run 'alsactl restore' manually to view=
 any errors."
 	    exit 1
 	fi
+	if [ "$soundfont" !=3D "" ] && [ -x /usr/bin/asfxload ]; then
+	    printf "Loading soundfont file ... "
+	    if /usr/bin/asfxload $soundfontopts "$soundfont" 2>&1; then
+		echo "done."
+	    else
+		echo "failed:"
+		echo "       Either there's no suitable sound card or no MIDI modules =
are loaded."
+	    fi
+	fi
 	;;
     stop)
 	if [ "$alsactl_store_on_shutdown" !=3D "never autosave" ]; then
@@ -39,6 +50,13 @@
 		fi
 	    fi
 	fi
+	if [ "$soundfont" !=3D "" ] && [ -x /usr/bin/asfxload ]; then
+	    printf "Unloading soundfonts ... "
+	    if /usr/bin/asfxload -i 2>&1; then
+		echo "done."
+	    else
+		echo "failed."
+	    fi
 	;;
     restart|reload)
 	$0 stop && $0 start
--- alsa-driver-1.0.4~/debian/alsa-base.postinst
+++ alsa-driver-1.0.4/debian/alsa-base.postinst
@@ -25,7 +25,25 @@
 	else
 	    db_get alsa-base/alsactl_store_on_shutdown
 	    alsactl_store_on_shutdown=3D"$RET"
-	    sed -e "s/alsactl_store_on_shutdown=3D.*/alsactl_store_on_shutdown=3D=
\"$alsactl_store_on_shutdown\"/" /etc/default/alsa > /etc/default/alsa.tm=
p
+	    db_get alsa-base/soundfont
+	    soundfont=3D"$RET"
+	    db_get alsa-base/soundfontopts
+	    soundfontopts=3D"$RET"
+	    sed -e "s/alsactl_store_on_shutdown=3D.*/alsactl_store_on_shutdown=3D=
\"$alsactl_store_on_shutdown\"/; \
+		    s!soundfont=3D.*!soundfont=3D\"$soundfont\"!; \
+		    s!soundfontopts=3D.*!soundfontopts=3D\"$soundfontopts\"!" \
+		/etc/default/alsa > /etc/default/alsa.tmp
+	    # append the extra options if necessary
+	    if dpkg --compare-versions "$2" le "1.0.4-2"; then
+		sed -ne "/^runlevels_save/ { \
+			   : loop; \
+			   s!soundfont=3D.*!soundfont=3D\"$soundfont\"!; \
+			   s!soundfontopts=3D.*!soundfontopts=3D\"$soundfontopts\"!; \
+			   p; N; s/^.*\n//; b loop; \
+			 }; d" \
+		    /usr/share/alsa-base/alsa-base.conf >> /etc/default/alsa.tmp
+	fi
+
 	    mv /etc/default/alsa /etc/default/alsa.debconf-backup
 	    mv /etc/default/alsa.tmp /etc/default/alsa
 	fi
--- alsa-driver-1.0.4~/debian/alsa-base.templates
+++ alsa-driver-1.0.4/debian/alsa-base.templates
@@ -7,3 +7,20 @@
  option is for people who change their mixer settings, and want to keep =
their
  changes across reboots. If enabled, the init script will run "alsactl s=
tore"
  on shutdown.
+
+Template: alsa-base/soundfont
+Type: string
+Default:=20
+_Description: Load a sound font file?
+ If you have a sound card such as the SB Live! which has an on-board
+ MIDI synth, then you may wish to load a sound font file. If you do,
+ then enter the name of the file here; otherwise, leave this blank.
+ Also leave it blank if you only have FM synths such as those provided
+ by Yamaha OPL-based cards.
+
+Template: alsa-base/soundfontopts
+Type: string
+Default: -i
+_Description: Options for asfxload (loading a sound font)
+ If you're loading a sound font, you may specify options for asfxload
+ here. (You should really leave this as "-i".)

--909895135--1698439453--470436753--