Attempt to use Mix_SetMusicPosition to speed up MOD music. (Not very good)
authorBill Kendrick <nbs@sonic.net>
Sun, 28 Dec 2003 08:52:36 +0000 (08:52 +0000)
committerBill Kendrick <nbs@sonic.net>
Sun, 28 Dec 2003 08:52:36 +0000 (08:52 +0000)
SVN-Revision: 55

src/gameloop.c
src/sound.c
src/sound.h

index f8ed6e5..e65180e 100644 (file)
@@ -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;
+      }
     }
 
 
index cab9566..81ef262 100644 (file)
@@ -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 <SDL_mixer.h>
+
 /* --- 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 )
index 6e57880..0de07e4 100644 (file)
@@ -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 <neoneurone@users.sf.net>
@@ -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);