Before, music was always played in loop mode, even if it was defined
with option "<music>.mode_loop: false".
Now, disabling loop mode for music in config files will indeed cause
music to be played only once.
Note: This commit changed the behaviour of the existing function
"PlayMusic()" (which always played music in loop mode before), which
will now play music only once, while a new function "PlayMusicLoop()"
was added, which always plays music in loop mode.
if (!setup.sound_music)
return;
if (!setup.sound_music)
return;
+ if (IS_LOOP_MUSIC(music))
+ PlayMusicLoop(music);
+ else
+ PlayMusic(music);
#if 0
printf("::: PLAY MUSIC %d.%d.%d: %d\n",
#if 0
printf("::: PLAY MUSIC %d.%d.%d: %d\n",
char *next_music = getMusicInfoEntryFilename(music_nr);
if (!strEqual(curr_music, next_music))
char *next_music = getMusicInfoEntryFilename(music_nr);
if (!strEqual(curr_music, next_music))
+ PlayMusicLoop(music_nr);
}
void PlayLevelSound_EM(int xx, int yy, int element_em, int sample)
}
void PlayLevelSound_EM(int xx, int yy, int element_em, int sample)
#define SOUND_VOLUME_LOOPS(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_loops)
#define SOUND_VOLUME_MUSIC(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_music)
#define SOUND_VOLUME_LOOPS(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_loops)
#define SOUND_VOLUME_MUSIC(v) SOUND_VOLUME_FROM_PERCENT(v, setup.volume_music)
-#define SETUP_SOUND_VOLUME(v,s) ((s) == SND_CTRL_PLAY_MUSIC ? \
+#define SETUP_SOUND_VOLUME(v,s) ((s) & SND_CTRL_MUSIC ? \
SOUND_VOLUME_MUSIC(v) : \
SOUND_VOLUME_MUSIC(v) : \
- (s) == SND_CTRL_PLAY_LOOP ? \
+ (s) & SND_CTRL_LOOP ? \
SOUND_VOLUME_LOOPS(v) : \
SOUND_VOLUME_SIMPLE(v))
SOUND_VOLUME_LOOPS(v) : \
SOUND_VOLUME_SIMPLE(v))
if (mixer[audio.music_channel].type != MUS_TYPE_WAV)
{
if (mixer[audio.music_channel].type != MUS_TYPE_WAV)
{
+ int loops = (IS_LOOP(mixer[audio.music_channel]) ? -1 : 1);
+
// use short fade-in to prevent "plop" sound for certain music files
// (this may happen when switching on music while playing the game)
Mix_VolumeMusic(mixer[audio.music_channel].volume);
// use short fade-in to prevent "plop" sound for certain music files
// (this may happen when switching on music while playing the game)
Mix_VolumeMusic(mixer[audio.music_channel].volume);
- Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, -1, 100);
+ Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, loops, 100);
#if defined(PLATFORM_WIN32)
// playing MIDI music is broken since Windows Vista, as it sets the volume
#if defined(PLATFORM_WIN32)
// playing MIDI music is broken since Windows Vista, as it sets the volume
+void PlayMusicLoop(int nr)
+{
+ if (!audio.music_available)
+ return;
+
+ PlaySoundMusicLoop(nr);
+}
+
void PlaySound(int nr)
{
if (!setup.sound_simple)
void PlaySound(int nr)
{
if (!setup.sound_simple)
PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC);
}
PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC);
}
+void PlaySoundMusicLoop(int nr)
+{
+ if (!setup.sound_music)
+ return;
+
+ PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC_LOOP);
+}
+
void PlaySoundExt(int nr, int volume, int stereo_position, int state)
{
SoundControl snd_ctrl;
void PlaySoundExt(int nr, int volume, int stereo_position, int state)
{
SoundControl snd_ctrl;
#define SND_CTRL_PLAY_SOUND (SND_CTRL_NONE)
#define SND_CTRL_PLAY_LOOP (SND_CTRL_LOOP)
#define SND_CTRL_PLAY_SOUND (SND_CTRL_NONE)
#define SND_CTRL_PLAY_LOOP (SND_CTRL_LOOP)
-#define SND_CTRL_PLAY_MUSIC (SND_CTRL_LOOP | SND_CTRL_MUSIC)
+#define SND_CTRL_PLAY_MUSIC (SND_CTRL_MUSIC)
+#define SND_CTRL_PLAY_MUSIC_LOOP (SND_CTRL_MUSIC | SND_CTRL_LOOP)
#define SND_CTRL_FADE_SOUND (SND_CTRL_FADE)
#define SND_CTRL_FADE_MUSIC (SND_CTRL_FADE | SND_CTRL_MUSIC)
#define SND_CTRL_FADE_SOUND (SND_CTRL_FADE)
#define SND_CTRL_FADE_MUSIC (SND_CTRL_FADE | SND_CTRL_MUSIC)
/* sound client functions */
void PlayMusic(int);
/* sound client functions */
void PlayMusic(int);
+void PlayMusicLoop(int);
void PlaySound(int);
void PlaySoundStereo(int, int);
void PlaySoundLoop(int);
void PlaySoundMusic(int);
void PlaySound(int);
void PlaySoundStereo(int, int);
void PlaySoundLoop(int);
void PlaySoundMusic(int);
+void PlaySoundMusicLoop(int);
void PlaySoundExt(int, int, int, int);
void FadeMusic(void);
void FadeSound(int);
void PlaySoundExt(int, int, int, int);
void FadeMusic(void);
void FadeSound(int);
#define IS_NEXT_FRAME(f, g) (IS_NEW_FRAME(f, g) && (f) > 0)
#define IS_LOOP_SOUND(s) (sound_info[s].loop)
#define IS_NEXT_FRAME(f, g) (IS_NEW_FRAME(f, g) && (f) > 0)
#define IS_LOOP_SOUND(s) (sound_info[s].loop)
+#define IS_LOOP_MUSIC(s) (music_info[s].loop)
#define IS_SPECIAL_GFX_ARG(a) ((a) >= 0 && (a) < NUM_SPECIAL_GFX_ARGS)
#define IS_SPECIAL_GFX_ARG(a) ((a) >= 0 && (a) < NUM_SPECIAL_GFX_ARGS)
- PlayMusic(list->music);
+ int music = list->music;
+
+ if (music_info[music].loop)
+ PlayMusicLoop(music);
+ else
+ PlayMusic(music);
DrawTextSCentered(ystart, font_title, "The Game Background Music:");
}
DrawTextSCentered(ystart, font_title, "The Game Background Music:");
}
if (!setup.sound_music)
return;
if (!setup.sound_music)
return;
+ if (IS_LOOP_MUSIC(music))
+ PlayMusicLoop(music);
+ else
+ PlayMusic(music);