Skip to content

Commit

Permalink
<M-}>Ryan C. Gordon - Tue, 5 Jun 2001 11:01:51
Browse files Browse the repository at this point in the history
 * Added VOC sound file support
  • Loading branch information
Sam Lantinga committed Jun 10, 2001
1 parent 77f369c commit f762ee5
Show file tree
Hide file tree
Showing 6 changed files with 514 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,5 +1,7 @@

1.2.1:
Ryan C. Gordon - Tue, 5 Jun 2001 11:01:51
* Added VOC sound file support
Guillaume Cottenceau - Thu May 10 11:17:55 PDT 2001
* Fixed crashes when API used with audio not initialized
Paul Jenner - Sat, 14 Apr 2001 09:20:38 -0700 (PDT)
Expand Down
3 changes: 2 additions & 1 deletion Makefile.am
Expand Up @@ -18,7 +18,8 @@ libSDL_mixer_la_SOURCES = \
music_ogg.h \
wave.h \
wavestream.c \
wavestream.h
wavestream.h \
voc.c

if USE_MIKMOD
MIKMOD_LIB = mikmod/libmikmod.la
Expand Down
8 changes: 4 additions & 4 deletions README
Expand Up @@ -12,10 +12,10 @@ libraries.
See the header file SDL_mixer.h and the examples playwave.c and playmus.c
for documentation on this mixer library.

The mixer can currently load Microsoft WAVE files as audio samples
and can load MIDI files via Timidity and the following music formats
via MikMod: .MOD .S3M .IT .XM. It can also load MP3 music using the
SMPEG library.
The mixer can currently load Microsoft WAVE files and Creative Labs VOC
files as audio samples, and can load MIDI files via Timidity and the
following music formats via MikMod: .MOD .S3M .IT .XM. It can also load
MP3 music using the SMPEG library.

The process of mixing MIDI files to wave output is very CPU intensive,
so if playing regular WAVE files sound great, but playing MIDI files
Expand Down
15 changes: 12 additions & 3 deletions configure.in
Expand Up @@ -36,13 +36,13 @@ AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

dnl Setup for automake
AM_INIT_AUTOMAKE(SDL_mixer, $VERSION)

dnl Detect the canonical host and target build environment
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

dnl Setup for automake
AM_INIT_AUTOMAKE(SDL_mixer, $VERSION)

dnl Check for tools

AC_PROG_MAKE_SET
Expand Down Expand Up @@ -80,6 +80,15 @@ dnl Matt Campbell (matt@campbellhome.dhs.org)
CFLAGS="$CFLAGS -DUSE_RWOPS"

dnl Check command-line options

dnl rcg06052001 VOC file support by Ryan C. Gordon (icculus@linuxgames.com).
AC_ARG_ENABLE(samples-voc,
[ --enable-samples-voc enable support for VOC samples [default=yes]],
, enable_samples_voc=yes)
if test x$enable_samples_voc = xyes; then
CFLAGS="$CFLAGS -DVOC_SAMPLES"
fi

AC_ARG_ENABLE(music-cmd,
[ --enable-music-cmd support an external music player [default=yes]],
, enable_music_cmd=yes)
Expand Down
27 changes: 27 additions & 0 deletions mixer.c
Expand Up @@ -270,6 +270,17 @@ int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels)
return(audio_opened);
}


/*
* !!! FIXME: Ideally, we want a Mix_LoadSample_RW(), which will handle the
* generic setup, then call the correct file format loader.
*/

#ifdef VOC_SAMPLES
SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
#endif

/* Load a wave file */
Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
{
Expand All @@ -278,6 +289,12 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
SDL_AudioCVT wavecvt;
int samplesize;

/* rcg06012001 Make sure src is valid */
if ( ! src ) {
SDL_SetError("Mix_LoadWAV_RW with NULL SDL_RWops");
return(NULL);
}

/* Make sure audio has been opened */
if ( ! audio_opened ) {
SDL_SetError("Audio device hasn't been opened");
Expand All @@ -297,12 +314,22 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
return(NULL);
}

/* rcg06012001 Handle Creative Labs .VOC format chunks. */
#ifdef VOC_SAMPLES
if ( Mix_LoadVOC_RW(src, 0,
&wavespec, (Uint8 **)&chunk->abuf, &chunk->alen) == NULL ) {
#endif
/* Load the WAV file into the chunk */
if ( SDL_LoadWAV_RW(src, freesrc,
&wavespec, (Uint8 **)&chunk->abuf, &chunk->alen) == NULL ) {
free(chunk);
return(NULL);
}

#ifdef VOC_SAMPLES
}
#endif

#if 0
PrintFormat("Audio device", &mixer);
PrintFormat("-- Wave file", &wavespec);
Expand Down

0 comments on commit f762ee5

Please sign in to comment.