From 1e61bb681c189491f5462ae2a04f6e3e9e59f2a5 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 28 Dec 2003 08:52:36 +0000 Subject: [PATCH] Attempt to use Mix_SetMusicPosition to speed up MOD music. (Not very good) SVN-Revision: 55 --- src/gameloop.c | 20 ++++++++++++++++++++ src/sound.c | 17 ++++++++++++++++- src/sound.h | 3 ++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/gameloop.c b/src/gameloop.c index f8ed6e50a..e65180ee7 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -123,6 +123,8 @@ char song_title[20]; char levelname[20]; char leveltheme[20]; char str[10]; +int sound_pos; + /* Local function prototypes: */ @@ -1121,10 +1123,28 @@ int game_action(void) current_music = LEVEL_MUSIC; halt_music(); } + if (!playing_music()) + { play_music( level_song, 1 ); + sound_pos = 0; + } + if (tux_invincible_time > 0) tux_invincible_time--; + + if (current_music == LEVEL_MUSIC && time_left < 250) + { + if ((frame % 10) == 0) + { + set_music_position(sound_pos); + sound_pos++; + } + } + else + { + sound_pos = 0; + } } diff --git a/src/sound.c b/src/sound.c index cab95662a..81ef26287 100644 --- a/src/sound.c +++ b/src/sound.c @@ -7,7 +7,7 @@ bill@newbreedsoftware.com http://www.newbreedsoftware.com/supertux/ - April 22, 2000 - July 15, 2002 + April 22, 2000 - December 27, 2003 */ /* @@ -30,6 +30,8 @@ #ifndef NOSOUND +#include + /* --- OPEN THE AUDIO DEVICE --- */ int open_audio (int frequency, Uint16 format, int channels, int chunksize) @@ -135,6 +137,19 @@ int play_music(Mix_Music *music, int loops) } +void set_music_position(int pos) +{ + if ((use_music == YES) && (audio_device == YES)) + { + if (Mix_PlayingMusic()) + { + Mix_SetMusicPosition(pos); + } + } +} + + + void free_music(Mix_Music *music) { if ( music != NULL ) diff --git a/src/sound.h b/src/sound.h index 6e57880ba..0de07e4c7 100644 --- a/src/sound.h +++ b/src/sound.h @@ -7,7 +7,7 @@ bill@newbreedsoftware.com http://www.newbreedsoftware.com/supertux/ - April 22, 2000 - July 15, 2002 + April 22, 2000 - December 27, 2003 Current maintainer: Duong-Khang NGUYEN @@ -53,6 +53,7 @@ Mix_Music * load_song(char * file); int playing_music(void); int halt_music(void); int play_music(Mix_Music*music, int loops); +void set_music_position(int pos); void free_music(Mix_Music*music); void free_chunk(Mix_Chunk*chunk); -- 2.11.0