[Lunar-commits] <moonbase> wildmidi: new module

Duncan Gibson engelsman at lunar-linux.org
Sat Aug 1 02:16:50 CEST 2009


commit 17cef06e4e562e384f67a8af60d8f376ed374412
Author: Paul Bredbury <brebs at sent.com>
Date:   Sat Aug 1 02:16:50 2009 +0200

    wildmidi: new module
    
    Version 0.2.2 added to moonbase
    Integrates with mpd, to play midi files.
---
 zbeta/wildmidi/BUILD                             |   13 ++
 zbeta/wildmidi/DETAILS                           |   44 +++++++
 zbeta/wildmidi/wildmidi-0.2.2-bigendian.patch    |   11 ++
 zbeta/wildmidi/wildmidi-0.2.2-cfg-abs-path.patch |   30 +++++
 zbeta/wildmidi/wildmidi-0.2.2-opt.patch          |   24 ++++
 zbeta/wildmidi/wildmidi-0.2.2-pulseaudio.patch   |  147 ++++++++++++++++++++++
 6 files changed, 269 insertions(+), 0 deletions(-)

diff --git a/zbeta/wildmidi/BUILD b/zbeta/wildmidi/BUILD
new file mode 100644
index 0000000..7f0919f
--- /dev/null
+++ b/zbeta/wildmidi/BUILD
@@ -0,0 +1,13 @@
+(
+
+  # Patches from http://koji.fedoraproject.org/koji/packageinfo?packageID=4841
+  patch_it $SCRIPT_DIRECTORY/wildmidi-0.2.2-opt.patch 1 &&
+  patch_it $SCRIPT_DIRECTORY/wildmidi-0.2.2-cfg-abs-path.patch 1 &&
+  patch_it $SCRIPT_DIRECTORY/wildmidi-0.2.2-pulseaudio.patch 1 &&
+  patch_it $SCRIPT_DIRECTORY/wildmidi-0.2.2-bigendian.patch 1 &&
+
+  autoreconf -fi &&
+  OPTS+=" --disable-static --disable-werror --without-arch" &&
+  default_build
+
+) > $C_FIFO 2>&1
diff --git a/zbeta/wildmidi/DETAILS b/zbeta/wildmidi/DETAILS
new file mode 100644
index 0000000..be4d8f6
--- /dev/null
+++ b/zbeta/wildmidi/DETAILS
@@ -0,0 +1,44 @@
+          MODULE=wildmidi
+         VERSION=0.2.2
+          SOURCE=$MODULE-$VERSION.tar.gz
+      SOURCE_URL=$SFORGE_URL/$MODULE
+      SOURCE_VFY=sha1:fad33365f8aaba3afdca6bb68bc48056425176a3
+        WEB_SITE=http://wildmidi.sourceforge.net/
+         ENTERED=20090721
+         UPDATED=20090721
+           SHORT="a simple software midi player"
+
+cat << EOF
+WildMIDI is a simple software midi player which has a core softsynth
+library that can be use with other applications.
+
+WildMIDI was originally conceived in December 2001 as an experiment to
+see if MIDI files could be played using the same samples as existing
+software but with much less overhead. Coming into existence as a
+command-line player in 2002 the first versions were so successful in
+reducing the overhead that developers from Quakeforge suggested that
+WildMIDI could be turned into a library. 2003 saw the first
+implementations of the WildMIDI library, with Quakeforge being used as
+the test application. The 1st official release of WildMIDI occured in
+2004 with a couple of bug fixes following shortly after.
+
+The WildMIDI library uses Gravis Ultrasound patch files to convert MIDI
+files into audio which is then passed back to the calling application
+for further processing or output. The API of the library is designed so
+that it is easy to include WildMIDI into applications that wish to
+include MIDI file playback. With multiple MIDI file support you can
+develop applications to mix several midi files together at the same
+time, and with the next release you will be able to use a different
+patch set for each MIDI file.
+
+Currently there is a small command-line player that accompanies the
+library which gives just one example of the use of the WildMIDI
+library. The next release will also contain a "self-contained" player
+which will play midi files without the extra overhead that occurs with
+the library. This is achieved by having a core source that is shared
+between the library and "self-contained" player.
+
+The future of the project will not end with the library, but with the
+library the door is open to possibilities including a software MIDI
+device, or a graphical MIDI sequencer.
+EOF
diff --git a/zbeta/wildmidi/wildmidi-0.2.2-bigendian.patch b/zbeta/wildmidi/wildmidi-0.2.2-bigendian.patch
new file mode 100644
index 0000000..d10b4bd
--- /dev/null
+++ b/zbeta/wildmidi/wildmidi-0.2.2-bigendian.patch
@@ -0,0 +1,11 @@
+--- wildmidi-0.2.2/src/wildmidi.c.orig	2004-01-28 18:13:46.000000000 +0000
++++ wildmidi-0.2.2/src/wildmidi.c	2008-07-06 14:31:38.000000000 +0100
+@@ -442,7 +442,7 @@
+ 		return -1;
+ 	}
+ 	
+-	if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16) < 0) {
++	if (snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16_LE) < 0) {
+ 		printf("ALSA does not support 16bit signed audio for your soundcard\n");
+ 		close_alsa_output();
+ 		return -1;
diff --git a/zbeta/wildmidi/wildmidi-0.2.2-cfg-abs-path.patch b/zbeta/wildmidi/wildmidi-0.2.2-cfg-abs-path.patch
new file mode 100644
index 0000000..46c3373
--- /dev/null
+++ b/zbeta/wildmidi/wildmidi-0.2.2-cfg-abs-path.patch
@@ -0,0 +1,30 @@
+diff -up wildmidi-0.2.2/src/wildmidi_lib.c.abs wildmidi-0.2.2/src/wildmidi_lib.c
+--- wildmidi-0.2.2/src/wildmidi_lib.c.abs	2004-01-28 19:13:46.000000000 +0100
++++ wildmidi-0.2.2/src/wildmidi_lib.c	2007-07-14 16:54:28.000000000 +0200
+@@ -845,7 +845,7 @@ WM_LoadConfig (const char *config_file) 
+ 			}
+ 			continue;
+ 		} else if (strncasecmp(line_buffer, "source ", 7) == 0) {
+-			if (config_dir != NULL) {
++			if (config_dir != NULL && line_buffer[7] != '/') {
+ 				new_config = malloc(strlen(config_dir) + strlen(&line_buffer[7]) + 1);
+ 				if (new_config == NULL) {
+ 					WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to parse config", errno);
+@@ -1013,7 +1013,7 @@ WM_LoadConfig (const char *config_file) 
+ 				*chr_ptr = '\0';
+ 			}
+ 			if (strncasecmp(&line_buffer[(line_ptr + strlen(&line_buffer[line_ptr]) - 5)], ".pat", 4) != 0) {
+-				if (config_dir != NULL) {
++				if (config_dir != NULL && line_buffer[line_ptr] != '/') {
+ 					tmp_patch->filename = malloc(strlen(config_dir) + strlen(&line_buffer[line_ptr]) + 5);
+ 					if (tmp_patch->filename == NULL) {
+ 						WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0);
+@@ -1041,7 +1041,7 @@ WM_LoadConfig (const char *config_file) 
+ 				}
+ 				strcat(tmp_patch->filename, ".pat");
+ 			} else {
+-				if (config_dir != NULL) {
++				if (config_dir != NULL && line_buffer[line_ptr] != '/') {
+ 					tmp_patch->filename = malloc(strlen(config_dir) + strlen(&line_buffer[line_ptr]) + 1);
+ 					if (tmp_patch->filename == NULL) {
+ 						WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, NULL, 0);
diff --git a/zbeta/wildmidi/wildmidi-0.2.2-opt.patch b/zbeta/wildmidi/wildmidi-0.2.2-opt.patch
new file mode 100644
index 0000000..2169319
--- /dev/null
+++ b/zbeta/wildmidi/wildmidi-0.2.2-opt.patch
@@ -0,0 +1,24 @@
+diff -up wildmidi-0.2.2/configure.ac.opt wildmidi-0.2.2/configure.ac
+--- wildmidi-0.2.2/configure.ac.opt	2007-07-14 15:21:57.000000000 +0200
++++ wildmidi-0.2.2/configure.ac	2007-07-14 15:22:03.000000000 +0200
+@@ -226,6 +226,8 @@ AC_ARG_WITH(arch,
+ )
+ 
+ case "$arch" in
++	no)
++		;;
+ 	auto)
+ 		case "${host_cpu}" in
+ 			i?86)
+diff -up wildmidi-0.2.2/configure.opt wildmidi-0.2.2/configure
+--- wildmidi-0.2.2/configure.opt	2007-07-14 15:21:54.000000000 +0200
++++ wildmidi-0.2.2/configure	2007-07-14 15:22:52.000000000 +0200
+@@ -19966,6 +19966,8 @@ else
+ fi;
+ 
+ case "$arch" in
++	no)
++		;;
+ 	auto)
+ 		case "${host_cpu}" in
+ 			i?86)
diff --git a/zbeta/wildmidi/wildmidi-0.2.2-pulseaudio.patch b/zbeta/wildmidi/wildmidi-0.2.2-pulseaudio.patch
new file mode 100644
index 0000000..2a7ffdf
--- /dev/null
+++ b/zbeta/wildmidi/wildmidi-0.2.2-pulseaudio.patch
@@ -0,0 +1,147 @@
+diff -up wildmidi-0.2.2/src/wildmidi.c.pa wildmidi-0.2.2/src/wildmidi.c
+--- wildmidi-0.2.2/src/wildmidi.c.pa	2004-01-28 19:13:46.000000000 +0100
++++ wildmidi-0.2.2/src/wildmidi.c	2008-02-09 14:54:58.000000000 +0100
+@@ -402,12 +402,8 @@ close_mm_output ( void ) {
+ #else
+ #ifdef HAVE_ALSA
+ 
+-void *buffer;
+-int bps;
+ int alsa_first_time = 1;
+ static snd_pcm_t  *pcm;
+-static snd_pcm_uframes_t alsa_period_size;
+-static snd_pcm_channel_area_t *areas;
+ 
+ int write_alsa_output (char * output_data, int output_size);
+ void close_alsa_output ( void );
+@@ -417,9 +413,8 @@ open_alsa_output(void) {
+ 	snd_pcm_hw_params_t     *hw;
+ 	snd_pcm_sw_params_t     *sw;
+ 	int err;
+-	int alsa_buffer_time, bits_per_sample;
++	int alsa_buffer_time;
+ 	unsigned int alsa_period_time;
+-	snd_pcm_uframes_t alsa_buffer_size;
+ 	
+ 	if (!pcmname)
+ 		pcmname = "default";
+@@ -437,7 +432,7 @@ open_alsa_output(void) {
+ 		return -1;
+ 	}
+ 
+-	if ((err = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) {
++	if ((err = snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
+ 		printf("Cannot set mmap'ed mode: %s.\n", snd_strerror(-err));
+ 		return -1;
+ 	}
+@@ -491,28 +486,6 @@ open_alsa_output(void) {
+ 		return -1;
+ 	}
+ 
+-#ifdef ALSA_NEW
+-	if ((err = snd_pcm_hw_params_get_buffer_size(hw, &alsa_buffer_size)) < 0)
+-#else
+-	if ((err = snd_pcm_hw_params_get_buffer_size(hw)) < 0)
+-#endif
+-	{
+-		printf ("snd_pcm_hw_params_get_buffer_size() failed: %s\n", snd_strerror(-err));
+-		return -1;
+-	}
+-#ifdef ALSA_NEW
+-	if ((err = snd_pcm_hw_params_get_period_size(hw, &alsa_period_size, 0)) < 0)	
+-#else
+-	alsa_buffer_size = err;
+-	if ((err = snd_pcm_hw_params_get_period_size(hw, 0)) < 0)
+-#endif
+-	{
+-		printf ("snd_pcm_hw_params_get_period_size() failed: %s\n", snd_strerror(-err));
+-		return -1;
+-	}
+-#ifndef ALSA_NEW
+-	alsa_period_size = err;
+-#endif	
+ 	snd_pcm_sw_params_alloca(&sw);
+ 	snd_pcm_sw_params_current(pcm, sw);
+ 	if (snd_pcm_sw_params(pcm, sw) < 0)
+@@ -521,19 +494,6 @@ open_alsa_output(void) {
+ 		return -1;
+ 	}
+ 	
+-	bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16);
+-	bps = (rate * bits_per_sample * 2) / 8000;
+-
+-	buffer = malloc(alsa_period_size * bits_per_sample / 8 * 2);
+-	areas = malloc(2 * sizeof(snd_pcm_channel_area_t));
+-
+-	areas[0].addr = buffer;
+-	areas[0].first = 0;
+-	areas[0].step = 2 * bits_per_sample;
+-	areas[1].addr = buffer;
+-        areas[1].first = bits_per_sample;
+-        areas[1].step = 2 * bits_per_sample;
+-	
+ 	send_output = write_alsa_output;
+ 	close_output = close_alsa_output;
+ 	return 0;			
+@@ -541,45 +501,23 @@ open_alsa_output(void) {
+ 
+ int 
+ write_alsa_output (char * output_data, int output_size) {
+-	int cnt = 0, err;
+-	snd_pcm_uframes_t offset, frames;
+-	snd_pcm_sframes_t avail;
+-	const snd_pcm_channel_area_t *chan_areas = areas;
++	int err;
++	snd_pcm_uframes_t frames;
+ 	
+ 	while (output_size > 0) {
+-		avail = snd_pcm_avail_update(pcm);
+-		if (avail == -EPIPE) {
+-			if (snd_pcm_state(pcm) == SND_PCM_STATE_XRUN) {
+-				if ((err = snd_pcm_prepare(pcm)) < 0)
+-					printf("snd_pcm_prepare() failed.\n");
+-				alsa_first_time = 1;
+-			}
+-		} else if (avail < 0) {
+-			printf("snd_pcm_avail_update() failed: %s\n", snd_strerror(-avail));
+-			avail = 0;
+-		}
+-		if (avail < alsa_period_size) {
+-			usleep(500);
+-			continue;
+-		}
+ 		frames = snd_pcm_bytes_to_frames(pcm, output_size);
+-		if ((err = snd_pcm_mmap_begin(pcm, &chan_areas, &offset, &frames)) < 0) {
+-			printf("snd_pcm_mmap_begin() failed: %s\n", snd_strerror(-err));
+-		}
+-		cnt = snd_pcm_frames_to_bytes(pcm, frames);
+-		memcpy((char*) chan_areas[0].addr + snd_pcm_frames_to_bytes(pcm, offset), output_data, cnt);
+-		if ((err = snd_pcm_mmap_commit(pcm, offset, frames)) < 0) {
++		if ((err = snd_pcm_writei(pcm, output_data, frames)) < 0) {
+ 			if (snd_pcm_state(pcm) == SND_PCM_STATE_XRUN) {
+ 				if ((err = snd_pcm_prepare(pcm)) < 0)
+ 					printf("snd_pcm_prepare() failed.\n");
+ 				alsa_first_time = 1;
++				continue;
+ 			}
++			return err;
+ 		}
+-		if (err != frames)
+-			printf("snd_pcm_mmap_commit returned %d, expected %d\n", err, (int)frames);
+ 		
+-		output_size -= cnt;
+-		output_data += cnt;
++		output_size -= snd_pcm_frames_to_bytes(pcm, err);
++		output_data += snd_pcm_frames_to_bytes(pcm, err);
+ 		if (alsa_first_time) {
+ 			alsa_first_time = 0;
+ 			snd_pcm_start(pcm);
+@@ -591,8 +529,6 @@ write_alsa_output (char * output_data, i
+ void 
+ close_alsa_output ( void ) {
+ 	snd_pcm_close (pcm);
+-	free(areas);
+-	free(buffer);
+ }
+ 
+ #else


More information about the Lunar-commits mailing list