Guillaume Cottenceau - Wed Dec 19 08:59:05 PST 2001
authorSam Lantinga <slouken@libsdl.org>
Wed, 19 Dec 2001 17:11:40 +0000
changeset 154f1a9d3e178d3
parent 153 df0dd5b0a001
child 155 53f259dae79d
Guillaume Cottenceau - Wed Dec 19 08:59:05 PST 2001
* Added an API for seeking in music files (implemented for MOD files)
Mix_FadeInMusicPos(), Mix_SetMusicPosition()
* Exposed the mikmod synchro value for music synchronization
Mix_SetSynchroValue(), Mix_GetSynchroValue()
CHANGES
SDL_mixer.h
configure.in
mikmod/load_xm.c
mikmod/mikmod.h
mikmod/mikmod_internals.h
mikmod/mplayer.c
mikmod/munitrk.c
music.c
     1.1 --- a/CHANGES	Tue Dec 18 21:48:30 2001 +0000
     1.2 +++ b/CHANGES	Wed Dec 19 17:11:40 2001 +0000
     1.3 @@ -1,3 +1,10 @@
     1.4 +
     1.5 +1.2.2:
     1.6 +Guillaume Cottenceau - Wed Dec 19 08:59:05 PST 2001
     1.7 + * Added an API for seeking in music files (implemented for MOD files)
     1.8 +	Mix_FadeInMusicPos(), Mix_SetMusicPosition()
     1.9 + * Exposed the mikmod synchro value for music synchronization
    1.10 +	Mix_SetSynchroValue(), Mix_GetSynchroValue()
    1.11  
    1.12  1.2.1:
    1.13  Yi-Huang Han - Wed Oct 24 21:55:47 PDT 2001
     2.1 --- a/SDL_mixer.h	Tue Dec 18 21:48:30 2001 +0000
     2.2 +++ b/SDL_mixer.h	Wed Dec 19 17:11:40 2001 +0000
     2.3 @@ -41,7 +41,7 @@
     2.4  */
     2.5  #define MIX_MAJOR_VERSION	1
     2.6  #define MIX_MINOR_VERSION	2
     2.7 -#define MIX_PATCHLEVEL		1
     2.8 +#define MIX_PATCHLEVEL		2
     2.9  
    2.10  /* This macro can be used to fill a version structure with the compile-time
    2.11   * version of the SDL_mixer library.
    2.12 @@ -460,6 +460,7 @@
    2.13  
    2.14  /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
    2.15  extern DECLSPEC int Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
    2.16 +extern DECLSPEC int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, int position);
    2.17  #define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
    2.18  extern DECLSPEC int Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
    2.19  
    2.20 @@ -506,6 +507,12 @@
    2.21  extern DECLSPEC void Mix_RewindMusic(void);
    2.22  extern DECLSPEC int  Mix_PausedMusic(void);
    2.23  
    2.24 +/* Set the current position in the music stream.
    2.25 +   This returns 0 if successful, or -1 if it failed or isn't implemented.
    2.26 +   This function is only implemented for MOD music formats at the moment.
    2.27 +*/
    2.28 +extern DECLSPEC int Mix_SetMusicPosition(int position);
    2.29 +
    2.30  /* Check the status of a specific channel.
    2.31     If the specified channel is -1, check all channels.
    2.32  */
    2.33 @@ -515,6 +522,10 @@
    2.34  /* Stop music and set external music playback command */
    2.35  extern DECLSPEC int Mix_SetMusicCMD(const char *command);
    2.36  
    2.37 +/* Synchro value is set by MikMod from modules while playing */
    2.38 +extern DECLSPEC int Mix_SetSynchroValue(int value);
    2.39 +extern DECLSPEC int Mix_GetSynchroValue(void);
    2.40 +
    2.41  /* Get the Mix_Chunk currently associated with a mixer channel
    2.42      Returns NULL if it's an invalid channel, or there's no chunk associated.
    2.43  */
     3.1 --- a/configure.in	Tue Dec 18 21:48:30 2001 +0000
     3.2 +++ b/configure.in	Wed Dec 19 17:11:40 2001 +0000
     3.3 @@ -13,9 +13,9 @@
     3.4  
     3.5  MAJOR_VERSION=1
     3.6  MINOR_VERSION=2
     3.7 -MICRO_VERSION=1
     3.8 -INTERFACE_AGE=1
     3.9 -BINARY_AGE=1
    3.10 +MICRO_VERSION=2
    3.11 +INTERFACE_AGE=0
    3.12 +BINARY_AGE=2
    3.13  VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
    3.14  
    3.15  AC_SUBST(MAJOR_VERSION)
     4.1 --- a/mikmod/load_xm.c	Tue Dec 18 21:48:30 2001 +0000
     4.2 +++ b/mikmod/load_xm.c	Wed Dec 19 17:11:40 2001 +0000
     4.3 @@ -286,6 +286,9 @@
     4.4  						break;
     4.5  				}
     4.6  				break;
     4.7 +			case 'Z'-55: /* Z - synchro */
     4.8 +				UniEffect(UNI_XMEFFECTZ,dat);
     4.9 +				break;
    4.10  			default:
    4.11  				if(eff<=0xf) {
    4.12  					/* the pattern jump destination is written in decimal,
     5.1 --- a/mikmod/mikmod.h	Tue Dec 18 21:48:30 2001 +0000
     5.2 +++ b/mikmod/mikmod.h	Wed Dec 19 17:11:40 2001 +0000
     5.3 @@ -550,6 +550,8 @@
     5.4  MIKMODAPI extern void    Player_ToggleMute(SLONG,...);
     5.5  MIKMODAPI extern int     Player_GetChannelVoice(UBYTE);
     5.6  MIKMODAPI extern UWORD   Player_GetChannelPeriod(UBYTE);
     5.7 +MIKMODAPI extern void    Player_SetSynchroValue(int);
     5.8 +MIKMODAPI extern int     Player_GetSynchroValue(void);
     5.9  
    5.10  typedef void (MikMod_player)(void);
    5.11  typedef MikMod_player *MikMod_player_t;
     6.1 --- a/mikmod/mikmod_internals.h	Tue Dec 18 21:48:30 2001 +0000
     6.2 +++ b/mikmod/mikmod_internals.h	Wed Dec 19 17:11:40 2001 +0000
     6.3 @@ -336,6 +336,7 @@
     6.4  	UNI_MEDEFFECTF1,   /* play note twice */
     6.5  	UNI_MEDEFFECTF2,   /* delay note */
     6.6  	UNI_MEDEFFECTF3,   /* play note three times */
     6.7 +	UNI_XMEFFECTZ,     /* XM Z synchro */
     6.8  
     6.9  	UNI_LAST
    6.10  };
     7.1 --- a/mikmod/mplayer.c	Tue Dec 18 21:48:30 2001 +0000
     7.2 +++ b/mikmod/mplayer.c	Wed Dec 19 17:11:40 2001 +0000
     7.3 @@ -1806,6 +1806,9 @@
     7.4  			case UNI_MEDEFFECTF3:
     7.5  				DoEEffects(0x90|(pf->sngspd/3));
     7.6  				break;
     7.7 +			case UNI_XMEFFECTZ:
     7.8 +				Player_SetSynchroValue(UniGetByte());
     7.9 +				break;
    7.10  			default:
    7.11  				a->sliding=oldsliding;
    7.12  				UniSkipOpcode(c);
    7.13 @@ -2897,4 +2900,16 @@
    7.14  	MUTEX_UNLOCK(vars);
    7.15  }
    7.16  
    7.17 +static int _pl_synchro_value;
    7.18 +void Player_SetSynchroValue(int i)
    7.19 +{
    7.20 +	_pl_synchro_value = i;
    7.21 +}
    7.22 +
    7.23 +int Player_GetSynchroValue(void)
    7.24 +{
    7.25 +	return _pl_synchro_value;
    7.26 +}
    7.27 +	
    7.28 +
    7.29  /* ex:set ts=4: */
     8.1 --- a/mikmod/munitrk.c	Tue Dec 18 21:48:30 2001 +0000
     8.2 +++ b/mikmod/munitrk.c	Wed Dec 19 17:11:40 2001 +0000
     8.3 @@ -98,7 +98,8 @@
     8.4  	2, /* UNI_MEDSPEED */
     8.5  	0, /* UNI_MEDEFFECTF1 */
     8.6  	0, /* UNI_MEDEFFECTF2 */
     8.7 -	0  /* UNI_MEDEFFECTF3 */
     8.8 +	0, /* UNI_MEDEFFECTF3 */
     8.9 +	1  /* UNI_XMEFFECTZ */
    8.10  };
    8.11  
    8.12  /* Sparse description of the internal module format
     9.1 --- a/music.c	Tue Dec 18 21:48:30 2001 +0000
     9.2 +++ b/music.c	Wed Dec 19 17:11:40 2001 +0000
     9.3 @@ -679,8 +679,26 @@
     9.4  	return(0);
     9.5  }
     9.6  
     9.7 +int Mix_SetMusicPosition(int position)
     9.8 +{
     9.9 +	if ( music_playing && !music_stopped ) {
    9.10 +		switch ( music_playing->type ) {
    9.11 +#ifdef MOD_MUSIC
    9.12 +		case MUS_MOD:
    9.13 +			Player_SetPosition(position);
    9.14 +			return(0);
    9.15 +			break;
    9.16 +#endif
    9.17 +		default:
    9.18 +			/* TODO: Implement this for other music backends */
    9.19 +			return(-1);
    9.20 +			break;
    9.21 +		}
    9.22 +	}
    9.23 +}
    9.24 +
    9.25  /* Fade in a music over "ms" milliseconds */
    9.26 -int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
    9.27 +int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, int position)
    9.28  {
    9.29  	if ( music && music_volume > 0 ) { /* No need to fade if we can't hear it */
    9.30  		music->fade_volume = music_volume;
    9.31 @@ -688,6 +706,12 @@
    9.32  		if ( Mix_PlayMusic(music, loops) < 0 ) {
    9.33  			return(-1);
    9.34  		}
    9.35 +		if ( position ) {
    9.36 +			if ( Mix_SetMusicPosition(position) < 0 ) {
    9.37 +				Mix_HaltMusic();
    9.38 +				return(-1);
    9.39 +			}
    9.40 +		}
    9.41  		music_playing->fade_step = 0;
    9.42  		music_playing->fade_steps = ms/ms_per_step;
    9.43  		music_playing->fading = MIX_FADING_IN;
    9.44 @@ -695,6 +719,11 @@
    9.45  	return(0);
    9.46  }
    9.47  
    9.48 +int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
    9.49 +{
    9.50 +	return Mix_FadeInMusicPos(music, loops, ms, 0);
    9.51 +}
    9.52 +
    9.53  /* Set the music volume */
    9.54  int Mix_VolumeMusic(int volume)
    9.55  {
    9.56 @@ -980,6 +1009,50 @@
    9.57  	return(0);
    9.58  }
    9.59  
    9.60 +int Mix_SetSynchroValue(int i)
    9.61 +{
    9.62 +	if ( music_playing && ! music_stopped ) {
    9.63 +		switch (music_playing->type) {
    9.64 +#ifdef MOD_MUSIC
    9.65 +			case MUS_MOD:
    9.66 +				if ( ! Player_Active() ) {
    9.67 +					return(-1);
    9.68 +				}
    9.69 +				Player_SetSynchroValue(i);
    9.70 +				return 0;
    9.71 +				break;
    9.72 +#endif
    9.73 +			default:
    9.74 +				return(-1);
    9.75 +				break;
    9.76 +		}
    9.77 +		return(-1);
    9.78 +	}
    9.79 +	return(-1);
    9.80 +}
    9.81 +
    9.82 +int Mix_GetSynchroValue(void)
    9.83 +{
    9.84 +	if ( music_playing && ! music_stopped ) {
    9.85 +		switch (music_playing->type) {
    9.86 +#ifdef MOD_MUSIC
    9.87 +			case MUS_MOD:
    9.88 +				if ( ! Player_Active() ) {
    9.89 +					return(-1);
    9.90 +				}
    9.91 +				return Player_GetSynchroValue();
    9.92 +				break;
    9.93 +#endif
    9.94 +			default:
    9.95 +				return(-1);
    9.96 +				break;
    9.97 +		}
    9.98 +		return(-1);
    9.99 +	}
   9.100 +	return(-1);
   9.101 +}
   9.102 +
   9.103 +
   9.104  /* Uninitialize the music players */
   9.105  void close_music(void)
   9.106  {