Sam Lantinga Wed Feb 12 21:03:57 PST 2003
authorSam Lantinga <slouken@libsdl.org>
Wed, 12 Feb 2003 05:40:57 +0000
changeset 214ab571e095c22
parent 213 0cab09308739
child 215 7d16b8c11a2b
Sam Lantinga Wed Feb 12 21:03:57 PST 2003
* Fixed volume control on WAVE music chunks
CHANGES
playmus.c
wavestream.c
     1.1 --- a/CHANGES	Wed Feb 12 05:07:12 2003 +0000
     1.2 +++ b/CHANGES	Wed Feb 12 05:40:57 2003 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4  1.2.5:
     1.5 +Sam Lantinga Wed Feb 12 21:03:57 PST 2003
     1.6 + * Fixed volume control on WAVE music chunks
     1.7  Ben Nason - Mon, 10 Feb 2003 11:50:27 -0800
     1.8   * Fixed volume control on MOD music chunks
     1.9  Patrice Mandin - Fri, 31 Jan 2003 15:17:30 +0100
     2.1 --- a/playmus.c	Wed Feb 12 05:07:12 2003 +0000
     2.2 +++ b/playmus.c	Wed Feb 12 05:40:57 2003 +0000
     2.3 @@ -57,7 +57,7 @@
     2.4  
     2.5  void Usage(char *argv0)
     2.6  {
     2.7 -	fprintf(stderr, "Usage: %s [-i] |-l] [-8] [-r rate] [-b buffers] [-s] <musicfile>\n", argv0);
     2.8 +	fprintf(stderr, "Usage: %s [-i] [-l] [-8] [-r rate] [-b buffers] [-v N] <musicfile>\n", argv0);
     2.9  }
    2.10  
    2.11  void Menu(void)
    2.12 @@ -97,6 +97,7 @@
    2.13  	Uint16 audio_format;
    2.14  	int audio_channels;
    2.15  	int audio_buffers;
    2.16 +	int audio_volume = MIX_MAX_VOLUME;
    2.17  	int looping = 0;
    2.18  	int interactive = 0;
    2.19  	int i;
    2.20 @@ -117,6 +118,10 @@
    2.21  			++i;
    2.22  			audio_buffers = atoi(argv[i]);
    2.23  		} else
    2.24 +		if ( (strcmp(argv[i], "-v") == 0) && argv[i+1] ) {
    2.25 +			++i;
    2.26 +			audio_volume = atoi(argv[i]);
    2.27 +		} else
    2.28  		if ( strcmp(argv[i], "-m") == 0 ) {
    2.29  			audio_channels = 1;
    2.30  		} else
    2.31 @@ -160,6 +165,9 @@
    2.32  	}
    2.33  	audio_open = 1;
    2.34  
    2.35 +	/* Set the music volume */
    2.36 +	Mix_VolumeMusic(audio_volume);
    2.37 +
    2.38  	/* Set the external music player, if any */
    2.39  	Mix_SetMusicCMD(getenv("MUSIC_CMD"));
    2.40  
     3.1 --- a/wavestream.c	Wed Feb 12 05:07:12 2003 +0000
     3.2 +++ b/wavestream.c	Wed Feb 12 05:40:57 2003 +0000
     3.3 @@ -92,6 +92,7 @@
     3.4  
     3.5  /* This is the format of the audio mixer data */
     3.6  static SDL_AudioSpec mixer;
     3.7 +static int wavestream_volume = MIX_MAX_VOLUME;
     3.8  
     3.9  /* Function to load the WAV/AIFF stream */
    3.10  static FILE *LoadWAVStream (const char *file, SDL_AudioSpec *spec,
    3.11 @@ -108,13 +109,13 @@
    3.12  	return(0);
    3.13  }
    3.14  
    3.15 -/* Unimplemented */
    3.16 -extern void WAVStream_SetVolume(int volume)
    3.17 +void WAVStream_SetVolume(int volume)
    3.18  {
    3.19 +	wavestream_volume = volume;
    3.20  }
    3.21  
    3.22  /* Load a WAV stream from the given file */
    3.23 -extern WAVStream *WAVStream_LoadSong(const char *file, const char *magic)
    3.24 +WAVStream *WAVStream_LoadSong(const char *file, const char *magic)
    3.25  {
    3.26  	WAVStream *wave;
    3.27  	SDL_AudioSpec wavespec;
    3.28 @@ -148,7 +149,7 @@
    3.29  }
    3.30  
    3.31  /* Start playback of a given WAV stream */
    3.32 -extern void WAVStream_Start(WAVStream *wave)
    3.33 +void WAVStream_Start(WAVStream *wave)
    3.34  {
    3.35  	clearerr(wave->wavefp);
    3.36  	fseek(wave->wavefp, wave->start, SEEK_SET);
    3.37 @@ -156,7 +157,7 @@
    3.38  }
    3.39  
    3.40  /* Play some of a stream previously started with WAVStream_Start() */
    3.41 -extern void WAVStream_PlaySome(Uint8 *stream, int len)
    3.42 +void WAVStream_PlaySome(Uint8 *stream, int len)
    3.43  {
    3.44  	long pos;
    3.45  
    3.46 @@ -192,7 +193,7 @@
    3.47  			}
    3.48  			music->cvt.len = original_len;
    3.49  			SDL_ConvertAudio(&music->cvt);
    3.50 -			memcpy(stream, music->cvt.buf, music->cvt.len_cvt);
    3.51 +			SDL_MixAudio(stream, music->cvt.buf, music->cvt.len_cvt, wavestream_volume);
    3.52  		} else {
    3.53  			if ( (music->stop - pos) < len ) {
    3.54  				len = (music->stop - pos);
    3.55 @@ -203,13 +204,13 @@
    3.56  }
    3.57  
    3.58  /* Stop playback of a stream previously started with WAVStream_Start() */
    3.59 -extern void WAVStream_Stop(void)
    3.60 +void WAVStream_Stop(void)
    3.61  {
    3.62  	music = NULL;
    3.63  }
    3.64  
    3.65  /* Close the given WAV stream */
    3.66 -extern void WAVStream_FreeSong(WAVStream *wave)
    3.67 +void WAVStream_FreeSong(WAVStream *wave)
    3.68  {
    3.69  	if ( wave ) {
    3.70  		/* Clean up associated data */
    3.71 @@ -224,7 +225,7 @@
    3.72  }
    3.73  
    3.74  /* Return non-zero if a stream is currently playing */
    3.75 -extern int WAVStream_Active(void)
    3.76 +int WAVStream_Active(void)
    3.77  {
    3.78  	int active;
    3.79