Jon Atkins to Sam
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Nov 2009 04:40:54 +0000
changeset 481286c27f54ea1
parent 480 30976a327fd3
child 482 7b0c54eed938
Jon Atkins to Sam

I added libmodplug as a possible music player
defaulted to no in configure for now.
libmodplug has higher quality than mikmod, and it seems to be ported to all the major modern OS's (Linux/Win/OSX).
CHANGES
Makefile.in
SDL_mixer.h
configure.in
music.c
music_modplug.c
music_modplug.h
     1.1 --- a/CHANGES	Sun Nov 15 09:41:26 2009 +0000
     1.2 +++ b/CHANGES	Mon Nov 16 04:40:54 2009 +0000
     1.3 @@ -1,3 +1,7 @@
     1.4 +1.2.12:
     1.5 +Jon Atkins - Sat Nov 14 13:00:18 PST 2009
     1.6 + * Added support for libmodplug (disabled by default)
     1.7 +
     1.8  1.2.11:
     1.9  Sam Lantinga - Sat Nov 14 12:38:01 PST 2009
    1.10   * Fixed initialization error and crashes if MikMod library isn't available
     2.1 --- a/Makefile.in	Sun Nov 15 09:41:26 2009 +0000
     2.2 +++ b/Makefile.in	Mon Nov 16 04:40:54 2009 +0000
     2.3 @@ -38,7 +38,7 @@
     2.4  PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@
     2.5  PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@
     2.6  
     2.7 -DIST = CHANGES COPYING CWProjects.sea.bin MPWmake.sea.bin Makefile.in SDL_mixer.pc.in README SDL_mixer.h SDL_mixer.qpg.in SDL_mixer.spec SDL_mixer.spec.in VisualC.zip Watcom-OS2.zip Xcode.tar.gz acinclude autogen.sh build-scripts configure configure.in dynamic_flac.c dynamic_flac.h dynamic_mod.c dynamic_mod.h dynamic_mp3.c dynamic_mp3.h dynamic_ogg.c dynamic_ogg.h effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h gcc-fat.sh libmikmod-3.1.12.zip load_aiff.c load_aiff.h load_flac.c load_flac.h load_ogg.c load_ogg.h load_voc.c load_voc.h mixer.c music.c music_cmd.c music_cmd.h music_flac.c music_flac.h music_mad.c music_mad.h music_mod.c music_mod.h music_ogg.c music_ogg.h native_midi native_midi_gpl playmus.c playwave.c timidity wavestream.c wavestream.h version.rc
     2.8 +DIST = CHANGES COPYING CWProjects.sea.bin MPWmake.sea.bin Makefile.in SDL_mixer.pc.in README SDL_mixer.h SDL_mixer.qpg.in SDL_mixer.spec SDL_mixer.spec.in VisualC.zip Watcom-OS2.zip Xcode.tar.gz acinclude autogen.sh build-scripts configure configure.in dynamic_flac.c dynamic_flac.h dynamic_mod.c dynamic_mod.h dynamic_mp3.c dynamic_mp3.h dynamic_ogg.c dynamic_ogg.h effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h gcc-fat.sh libmikmod-3.1.12.zip load_aiff.c load_aiff.h load_flac.c load_flac.h load_ogg.c load_ogg.h load_voc.c load_voc.h mixer.c music.c music_cmd.c music_cmd.h music_flac.c music_flac.h music_mad.c music_mad.h music_mod.c music_mod.h music_modplug.c music_modplug.h music_ogg.c music_ogg.h native_midi native_midi_gpl playmus.c playwave.c timidity wavestream.c wavestream.h version.rc
     2.9  
    2.10  LT_AGE      = @LT_AGE@
    2.11  LT_CURRENT  = @LT_CURRENT@
     3.1 --- a/SDL_mixer.h	Sun Nov 15 09:41:26 2009 +0000
     3.2 +++ b/SDL_mixer.h	Mon Nov 16 04:40:54 2009 +0000
     3.3 @@ -122,7 +122,8 @@
     3.4  	MUS_OGG,
     3.5  	MUS_MP3,
     3.6  	MUS_MP3_MAD,
     3.7 -	MUS_FLAC
     3.8 +	MUS_FLAC,
     3.9 +	MUS_MODPLUG
    3.10  } Mix_MusicType;
    3.11  
    3.12  /* The internal format for a music chunk interpreted via mikmod */
    3.13 @@ -586,8 +587,8 @@
    3.14  /* Set the current position in the music stream.
    3.15     This returns 0 if successful, or -1 if it failed or isn't implemented.
    3.16     This function is only implemented for MOD music formats (set pattern
    3.17 -   order number) and for OGG music (set position in seconds), at the
    3.18 -   moment.
    3.19 +   order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set 
    3.20 +   position in seconds), at the moment.
    3.21  */
    3.22  extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
    3.23  
     4.1 --- a/configure.in	Sun Nov 15 09:41:26 2009 +0000
     4.2 +++ b/configure.in	Mon Nov 16 04:40:54 2009 +0000
     4.3 @@ -271,10 +271,30 @@
     4.4          fi
     4.5      else
     4.6          AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
     4.7 -        AC_MSG_WARN([MOD support disabled])
     4.8      fi
     4.9  fi
    4.10  
    4.11 +AC_ARG_ENABLE([music-mod-modplug],
    4.12 +AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=no]]]),
    4.13 +              [], [enable_music_mod_modplug=no])
    4.14 +if test x$enable_music_mod_modplug = xyes; then
    4.15 +	PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.7])
    4.16 +	EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC  $MODPLUG_CFLAGS"
    4.17 +	EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
    4.18 +dnl	AC_TRY_COMPILE([
    4.19 +dnl     #include "modplug.h"
    4.20 +dnl    ],[
    4.21 +dnl    ],[
    4.22 +    have_libmodplug=yes
    4.23 +dnl    ])
    4.24 +else
    4.25 +	have_libmodplug=no
    4.26 +fi
    4.27 +
    4.28 +if test x$have_libmikmod != xyes -a x$have_libmodplug != xyes ; then
    4.29 +	AC_MSG_WARN([MOD support disabled])
    4.30 +fi
    4.31 +
    4.32  AC_ARG_ENABLE([music-midi],
    4.33  AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
    4.34                [], [enable_music_midi=yes])
    4.35 @@ -519,6 +539,7 @@
    4.36          SOURCES="$SOURCES $srcdir/music_mad.c"
    4.37          EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
    4.38          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
    4.39 +        SOURCES="$SOURCES $srcdir/music_modplug.c"
    4.40      else
    4.41          AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
    4.42      fi
     5.1 --- a/music.c	Sun Nov 15 09:41:26 2009 +0000
     5.2 +++ b/music.c	Mon Nov 16 04:40:54 2009 +0000
     5.3 @@ -38,6 +38,9 @@
     5.4  #ifdef WAV_MUSIC
     5.5  #include "wavestream.h"
     5.6  #endif
     5.7 +#ifdef MODPLUG_MUSIC
     5.8 +#include "music_modplug.h"
     5.9 +#endif
    5.10  #ifdef MOD_MUSIC
    5.11  #include "music_mod.h"
    5.12  #endif
    5.13 @@ -88,6 +91,9 @@
    5.14  #ifdef WAV_MUSIC
    5.15  		WAVStream *wave;
    5.16  #endif
    5.17 +#ifdef MODPLUG_MUSIC
    5.18 +		modplug_data *modplug;
    5.19 +#endif
    5.20  #ifdef MOD_MUSIC
    5.21  		struct MODULE *module;
    5.22  #endif
    5.23 @@ -253,6 +259,11 @@
    5.24  				left = WAVStream_PlaySome(stream, len);
    5.25  				break;
    5.26  #endif
    5.27 +#ifdef MODPLUG_MUSIC
    5.28 +			case MUS_MODPLUG:
    5.29 +				left = modplug_playAudio(music_playing->data.modplug, stream, len);
    5.30 +				break;
    5.31 +#endif
    5.32  #ifdef MOD_MUSIC
    5.33  			case MUS_MOD:
    5.34  				left = MOD_playAudio(music_playing->data.module, stream, len);
    5.35 @@ -309,6 +320,13 @@
    5.36  		add_music_decoder("WAVE");
    5.37  	}
    5.38  #endif
    5.39 +#ifdef MODPLUG_MUSIC
    5.40 +	if ( modplug_init(mixer) < 0 ) {
    5.41 +		++music_error;
    5.42 +	} else {
    5.43 +		add_music_decoder("MODPLUG");
    5.44 +	}
    5.45 +#endif
    5.46  #ifdef MOD_MUSIC
    5.47  	if ( MOD_init(mixer) == 0 ) {
    5.48  		add_music_decoder("MIKMOD");
    5.49 @@ -527,6 +545,15 @@
    5.50  		}
    5.51  	} else
    5.52  #endif
    5.53 +#ifdef MODPLUG_MUSIC
    5.54 +	if ( 1 ) {
    5.55 +		music->type = MUS_MODPLUG;
    5.56 +		music->data.modplug = modplug_new(file);
    5.57 +		if ( music->data.modplug == NULL ) {
    5.58 +			music->error = 1;
    5.59 +		}
    5.60 +	} else
    5.61 +#endif
    5.62  #ifdef MOD_MUSIC
    5.63  	if ( 1 ) {
    5.64  		music->type = MUS_MOD;
    5.65 @@ -576,6 +603,11 @@
    5.66  				WAVStream_FreeSong(music->data.wave);
    5.67  				break;
    5.68  #endif
    5.69 +#ifdef MODPLUG_MUSIC
    5.70 +			case MUS_MODPLUG:
    5.71 +				modplug_delete(music->data.modplug);
    5.72 +				break;
    5.73 +#endif
    5.74  #ifdef MOD_MUSIC
    5.75  			case MUS_MOD:
    5.76  				MOD_delete(music->data.module);
    5.77 @@ -671,6 +703,13 @@
    5.78  		WAVStream_Start(music->data.wave);
    5.79  		break;
    5.80  #endif
    5.81 +#ifdef MODPLUG_MUSIC
    5.82 +	    case MUS_MODPLUG:
    5.83 +		/* can't set volume until file is loaded, so finally set it now */
    5.84 +		music_internal_initialize_volume();
    5.85 +		modplug_play(music->data.modplug);
    5.86 +		break;
    5.87 +#endif
    5.88  #ifdef MOD_MUSIC
    5.89  	    case MUS_MOD:
    5.90  		MOD_play(music->data.module);
    5.91 @@ -787,6 +826,11 @@
    5.92  	int retval = 0;
    5.93  
    5.94  	switch (music_playing->type) {
    5.95 +#ifdef MODPLUG_MUSIC
    5.96 +	    case MUS_MODPLUG:
    5.97 +		modplug_jump_to_time(music_playing->data.modplug, position);
    5.98 +		break;
    5.99 +#endif
   5.100  #ifdef MOD_MUSIC
   5.101  	    case MUS_MOD:
   5.102  		MOD_jump_to_time(music_playing->data.module, position);
   5.103 @@ -867,6 +911,11 @@
   5.104  		WAVStream_SetVolume(volume);
   5.105  		break;
   5.106  #endif
   5.107 +#ifdef MODPLUG_MUSIC
   5.108 +	    case MUS_MODPLUG:
   5.109 +		modplug_setvolume(music_playing->data.modplug, volume);
   5.110 +		break;
   5.111 +#endif
   5.112  #ifdef MOD_MUSIC
   5.113  	    case MUS_MOD:
   5.114  		MOD_setvolume(music_playing->data.module, volume);
   5.115 @@ -945,6 +994,11 @@
   5.116  		WAVStream_Stop();
   5.117  		break;
   5.118  #endif
   5.119 +#ifdef MODPLUG_MUSIC
   5.120 +	    case MUS_MODPLUG:
   5.121 +		modplug_stop(music_playing->data.modplug);
   5.122 +		break;
   5.123 +#endif
   5.124  #ifdef MOD_MUSIC
   5.125  	    case MUS_MOD:
   5.126  		MOD_stop(music_playing->data.module);
   5.127 @@ -1091,6 +1145,13 @@
   5.128  		}
   5.129  		break;
   5.130  #endif
   5.131 +#ifdef MODPLUG_MUSIC
   5.132 +	    case MUS_MODPLUG:
   5.133 +		if ( ! modplug_playing(music_playing->data.modplug) ) {
   5.134 +			playing = 0;
   5.135 +		}
   5.136 +		break;
   5.137 +#endif
   5.138  #ifdef MOD_MUSIC
   5.139  	    case MUS_MOD:
   5.140  		if ( ! MOD_playing(music_playing->data.module) ) {
   5.141 @@ -1198,6 +1259,9 @@
   5.142  #ifdef CMD_MUSIC
   5.143  	Mix_SetMusicCMD(NULL);
   5.144  #endif
   5.145 +#ifdef MODPLUG_MUSIC
   5.146 +	modplug_exit();
   5.147 +#endif
   5.148  #ifdef MOD_MUSIC
   5.149  	MOD_exit();
   5.150  #endif
   5.151 @@ -1335,15 +1399,29 @@
   5.152  #endif
   5.153  	} else
   5.154  #endif
   5.155 +#if defined(MODPLUG_MUSIC) || defined(MODPLUG_MUSIC)
   5.156 +	if (1) {
   5.157 +		music->error = 1;
   5.158 +#ifdef MODPLUG_MUSIC
   5.159 +		if ( music->error ) {
   5.160 +			music->type = MUS_MODPLUG;
   5.161 +			music->data.modplug = modplug_new_RW(rw);
   5.162 +			if ( music->data.modplug ) {
   5.163 +				music->error = 0;
   5.164 +			}
   5.165 +		}
   5.166 +#endif
   5.167  #ifdef MOD_MUSIC
   5.168 -	if (1) {
   5.169 -		music->type=MUS_MOD;
   5.170 -		music->data.module = MOD_new_RW(rw);
   5.171 -		if ( music->data.module == NULL ) {
   5.172 -			music->error = 1;
   5.173 +		if ( music->error ) {
   5.174 +			music->type = MUS_MOD;
   5.175 +			music->data.module = MOD_new_RW(rw);
   5.176 +			if ( music->data.module ) {
   5.177 +				music->error = 0;
   5.178 +			}
   5.179  		}
   5.180 +#endif
   5.181  	} else
   5.182 -#endif
   5.183 +#endif /* MODPLUG_MUSIC || MOD_MUSIC */
   5.184  	{
   5.185  		Mix_SetError("Unrecognized music format");
   5.186  		music->error=1;
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/music_modplug.c	Mon Nov 16 04:40:54 2009 +0000
     6.3 @@ -0,0 +1,238 @@
     6.4 +#ifdef MODPLUG_MUSIC
     6.5 +
     6.6 +#include "music_modplug.h"
     6.7 +
     6.8 +static int current_output_channels=0;
     6.9 +static int music_swap8=0;
    6.10 +static int music_swap16=0;
    6.11 +static ModPlug_Settings settings;
    6.12 +
    6.13 +int modplug_init(SDL_AudioSpec *spec)
    6.14 +{
    6.15 +	ModPlug_GetSettings(&settings);
    6.16 +	settings.mFlags=MODPLUG_ENABLE_OVERSAMPLING;
    6.17 +	current_output_channels=spec->channels;
    6.18 +	settings.mChannels=spec->channels>1?2:1;
    6.19 +	settings.mBits=spec->format&0xFF;
    6.20 +
    6.21 +	music_swap8 = 0;
    6.22 +	music_swap16 = 0;
    6.23 +
    6.24 +	switch(spec->format)
    6.25 +	{
    6.26 +		case AUDIO_U8:
    6.27 +		case AUDIO_S8: {
    6.28 +			if ( spec->format == AUDIO_S8 ) {
    6.29 +				music_swap8 = 1;
    6.30 +			}
    6.31 +			settings.mBits=8;
    6.32 +		}
    6.33 +		break;
    6.34 +
    6.35 +		case AUDIO_S16LSB:
    6.36 +		case AUDIO_S16MSB: {
    6.37 +			/* See if we need to correct MikMod mixing */
    6.38 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN
    6.39 +			if ( spec->format == AUDIO_S16MSB ) {
    6.40 +#else
    6.41 +			if ( spec->format == AUDIO_S16LSB ) {
    6.42 +#endif
    6.43 +				music_swap16 = 1;
    6.44 +			}
    6.45 +			settings.mBits=16;
    6.46 +		}
    6.47 +		break;
    6.48 +
    6.49 +		default: {
    6.50 +			Mix_SetError("Unknown hardware audio format");
    6.51 +			return -1;
    6.52 +		}
    6.53 +
    6.54 +	}
    6.55 +
    6.56 +	settings.mFrequency=spec->freq; /*TODO: limit to 11025, 22050, or 44100 ? */
    6.57 +	settings.mResamplingMode=MODPLUG_RESAMPLE_FIR;
    6.58 +	settings.mReverbDepth=0;
    6.59 +	settings.mReverbDelay=100;
    6.60 +	settings.mBassAmount=0;
    6.61 +	settings.mBassRange=50;
    6.62 +	settings.mSurroundDepth=0;
    6.63 +	settings.mSurroundDelay=10;
    6.64 +	settings.mLoopCount=0;
    6.65 +	ModPlug_SetSettings(&settings);
    6.66 +}
    6.67 +
    6.68 +/* Uninitialize the music players */
    6.69 +void modplug_exit()
    6.70 +{
    6.71 +}
    6.72 +
    6.73 +/* Set the volume for a modplug stream */
    6.74 +void modplug_setvolume(modplug_data *music, int volume)
    6.75 +{
    6.76 +	ModPlug_SetMasterVolume(music->file, volume*4);
    6.77 +}
    6.78 +
    6.79 +/* Load a modplug stream from the given file */
    6.80 +modplug_data *modplug_new(const char *file)
    6.81 +{
    6.82 +	SDL_RWops *rw;
    6.83 +
    6.84 +	rw = SDL_RWFromFile(file, "rb");
    6.85 +	if ( rw == NULL ) {
    6.86 +		/* FIXME: Free rw, need to free on delete */
    6.87 +		SDL_SetError("Couldn't open %s", file);
    6.88 +		return NULL;
    6.89 +	}
    6.90 +	return modplug_new_RW(rw);
    6.91 +
    6.92 +}
    6.93 +
    6.94 +/* Load a modplug stream from an SDL_RWops object */
    6.95 +modplug_data *modplug_new_RW(SDL_RWops *rw)
    6.96 +{
    6.97 +	modplug_data *music=NULL;
    6.98 +	long offset,sz;
    6.99 +	char *buf=NULL;
   6.100 +
   6.101 +	offset = SDL_RWtell(rw);
   6.102 +	SDL_RWseek(rw, 0, RW_SEEK_END);
   6.103 +	sz = SDL_RWtell(rw)-offset;
   6.104 +	SDL_RWseek(rw, offset, RW_SEEK_SET);
   6.105 +	buf=(char*)malloc(sz);
   6.106 +	if(!buf)
   6.107 +		return NULL;
   6.108 +	if(SDL_RWread(rw, buf, sz, 1)==1)
   6.109 +	{
   6.110 +		music=(modplug_data*)malloc(sizeof(modplug_data));
   6.111 +		music->playing=0;
   6.112 +		music->file=ModPlug_Load(buf,sz);
   6.113 +		if(!music->file)
   6.114 +		{
   6.115 +			free(music);
   6.116 +			music=NULL;
   6.117 +		}
   6.118 +	}
   6.119 +	free(buf);
   6.120 +	return music;
   6.121 +}
   6.122 +
   6.123 +/* Start playback of a given modplug stream */
   6.124 +void modplug_play(modplug_data *music)
   6.125 +{
   6.126 +	ModPlug_Seek(music->file,0);
   6.127 +	music->playing=1;
   6.128 +}
   6.129 +
   6.130 +/* Return non-zero if a stream is currently playing */
   6.131 +int modplug_playing(modplug_data *music)
   6.132 +{
   6.133 +	return music && music->playing;
   6.134 +}
   6.135 +
   6.136 +/* Play some of a stream previously started with modplug_play() */
   6.137 +int modplug_playAudio(modplug_data *music, Uint8 *stream, int len)
   6.138 +{
   6.139 +	if (current_output_channels > 2) {
   6.140 +		int small_len = 2 * len / current_output_channels;
   6.141 +		int i;
   6.142 +		Uint8 *src, *dst;
   6.143 +
   6.144 +		i=ModPlug_Read(music->file, stream, small_len);
   6.145 +		if(i<small_len)
   6.146 +		{
   6.147 +			memset(stream+i,0,small_len-i);
   6.148 +			music->playing=0;
   6.149 +		}
   6.150 +		/* and extend to len by copying channels */
   6.151 +		src = stream + small_len;
   6.152 +		dst = stream + len;
   6.153 +
   6.154 +		switch (settings.mBits) {
   6.155 +			case 8:
   6.156 +				for ( i=small_len/2; i; --i ) {
   6.157 +					src -= 2;
   6.158 +					dst -= current_output_channels;
   6.159 +					dst[0] = src[0];
   6.160 +					dst[1] = src[1];
   6.161 +					dst[2] = src[0];
   6.162 +					dst[3] = src[1];
   6.163 +					if (current_output_channels == 6) {
   6.164 +						dst[4] = src[0];
   6.165 +						dst[5] = src[1];
   6.166 +					}
   6.167 +				}
   6.168 +				break;
   6.169 +			case 16:
   6.170 +				for ( i=small_len/4; i; --i ) {
   6.171 +					src -= 4;
   6.172 +					dst -= 2 * current_output_channels;
   6.173 +					dst[0] = src[0];
   6.174 +					dst[1] = src[1];
   6.175 +					dst[2] = src[2];
   6.176 +					dst[3] = src[3];
   6.177 +					dst[4] = src[0];
   6.178 +					dst[5] = src[1];
   6.179 +					dst[6] = src[2];
   6.180 +					dst[7] = src[3];
   6.181 +					if (current_output_channels == 6) {
   6.182 +						dst[8] = src[0];
   6.183 +						dst[9] = src[1];
   6.184 +						dst[10] = src[2];
   6.185 +						dst[11] = src[3];
   6.186 +					}
   6.187 +				}
   6.188 +				break;
   6.189 +		}
   6.190 +	} else {
   6.191 +		int i=ModPlug_Read(music->file, stream, len);
   6.192 +		if(i<len)
   6.193 +		{
   6.194 +			memset(stream+i,0,len-i);
   6.195 +			music->playing=0;
   6.196 +		}
   6.197 +	}
   6.198 +	if ( music_swap8 ) {
   6.199 +		Uint8 *dst;
   6.200 +		int i;
   6.201 +
   6.202 +		dst = stream;
   6.203 +		for ( i=len; i; --i ) {
   6.204 +			*dst++ ^= 0x80;
   6.205 +		}
   6.206 +	} else
   6.207 +	if ( music_swap16 ) {
   6.208 +		Uint8 *dst, tmp;
   6.209 +		int i;
   6.210 +
   6.211 +		dst = stream;
   6.212 +		for ( i=(len/2); i; --i ) {
   6.213 +			tmp = dst[0];
   6.214 +			dst[0] = dst[1];
   6.215 +			dst[1] = tmp;
   6.216 +			dst += 2;
   6.217 +		}
   6.218 +	}
   6.219 +	return 0;
   6.220 +}
   6.221 +
   6.222 +/* Stop playback of a stream previously started with modplug_play() */
   6.223 +void modplug_stop(modplug_data *music)
   6.224 +{
   6.225 +	music->playing=0;
   6.226 +}
   6.227 +
   6.228 +/* Close the given modplug stream */
   6.229 +void modplug_delete(modplug_data *music)
   6.230 +{
   6.231 +	ModPlug_Unload(music->file);
   6.232 +	free(music);
   6.233 +}
   6.234 +
   6.235 +/* Jump (seek) to a given position (time is in seconds) */
   6.236 +void modplug_jump_to_time(modplug_data *music, double time)
   6.237 +{
   6.238 +	ModPlug_Seek(music->file,(int)(time*1000));
   6.239 +}
   6.240 +
   6.241 +#endif
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/music_modplug.h	Mon Nov 16 04:40:54 2009 +0000
     7.3 @@ -0,0 +1,45 @@
     7.4 +#ifdef MODPLUG_MUSIC
     7.5 +
     7.6 +#include "modplug.h"
     7.7 +#include "SDL_rwops.h"
     7.8 +#include "SDL_audio.h"
     7.9 +#include "SDL_mixer.h"
    7.10 +
    7.11 +typedef struct {
    7.12 +	ModPlugFile *file;
    7.13 +	int playing;
    7.14 +} modplug_data;
    7.15 +
    7.16 +int modplug_init(SDL_AudioSpec *mixer);
    7.17 +
    7.18 +/* Uninitialize the music players */
    7.19 +void modplug_exit(void);
    7.20 +
    7.21 +/* Set the volume for a modplug stream */
    7.22 +void modplug_setvolume(modplug_data *music, int volume);
    7.23 +
    7.24 +/* Load a modplug stream from the given file */
    7.25 +modplug_data *modplug_new(const char *file);
    7.26 +
    7.27 +/* Load a modplug stream from an SDL_RWops object */
    7.28 +modplug_data *modplug_new_RW(SDL_RWops *rw);
    7.29 +
    7.30 +/* Start playback of a given modplug stream */
    7.31 +void modplug_play(modplug_data *music);
    7.32 +
    7.33 +/* Return non-zero if a stream is currently playing */
    7.34 +int modplug_playing(modplug_data *music);
    7.35 +
    7.36 +/* Play some of a stream previously started with modplug_play() */
    7.37 +int modplug_playAudio(modplug_data *music, Uint8 *stream, int len);
    7.38 +
    7.39 +/* Stop playback of a stream previously started with modplug_play() */
    7.40 +void modplug_stop(modplug_data *music);
    7.41 +
    7.42 +/* Close the given modplug stream */
    7.43 +void modplug_delete(modplug_data *music);
    7.44 +
    7.45 +/* Jump (seek) to a given position (time is in seconds) */
    7.46 +void modplug_jump_to_time(modplug_data *music, double time);
    7.47 +
    7.48 +#endif