#endif
}
+#if 0
static void ReloadCustomSounds()
{
int i;
printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current);
#endif
- FreeAllSounds();
+ LoadSoundsInfo();
- InitSoundList(NUM_SOUNDS);
for(i=0; i<NUM_SOUNDS; i++)
LoadSoundToList(sound_name[i], i);
}
LoadCustomMusic();
}
+#endif
static void InitSoundServer()
{
OpenAudio();
+#if 0
SetAudioReloadFunctions(ReloadCustomSounds, ReloadCustomMusic);
+#endif
+ InitSoundList(sound_name, NUM_SOUNDS);
StartSoundserver();
}
#endif
}
+void LoadSoundsInfo()
+{
+#if 0
+ char *filename = getCustomSoundFilename(SOUNDSINFO_FILENAME);
+ struct SetupFileList *setup_file_list = loadSetupFileList(filename);
+
+ if (setup_file_list)
+ {
+#if 0
+ for (i=0; i<NUM_LEVELINFO_TOKENS; i++)
+ setSetupInfo(levelinfo_tokens, i,
+ getTokenValue(setup_file_list, levelinfo_tokens[i].text));
+#endif
+
+ freeSetupFileList(setup_file_list);
+ }
+#endif
+}
+
static void SaveUserLevelInfo()
{
char *filename;
void LoadLevelInfo(void);
void LoadArtworkInfo(void);
+void LoadSoundsInfo(void);
void LoadLevelSetup_LastSeries(void);
void SaveLevelSetup_LastSeries(void);
void LoadLevelSetup_SeriesInfo(void);
static SoundInfo **Sound = NULL;
static MusicInfo **Music = NULL;
static int num_sounds = 0, num_music = 0;
+static char **sound_name;
/* ========================================================================= */
static void SoundServer_StopAllSounds();
#endif
+static void ReloadCustomSounds();
+static void ReloadCustomMusic();
+static void FreeSound(SoundInfo *);
+
#if defined(PLATFORM_UNIX)
static int OpenAudioDevice(char *audio_device_name)
{
if (snd_ctrl.reload_sounds)
{
artwork.sounds_set_current = set_name;
+ ReloadCustomSounds();
+#if 0
audio.func_reload_sounds();
+#endif
}
else
{
artwork.music_set_current = set_name;
+ ReloadCustomMusic();
+#if 0
audio.func_reload_music();
+#endif
}
free(set_name);
if (!audio.sound_available)
return NULL;
+#if 1
+ printf("loading WAV file '%s'\n", filename);
+#endif
+
snd_info = checked_calloc(sizeof(SoundInfo));
#if defined(TARGET_SDL)
return snd_info;
}
-SoundInfo *LoadCustomSound(char *basename)
+static void LoadCustomSound(SoundInfo **snd_info, char *basename)
{
char *filename = getCustomSoundFilename(basename);
- if (filename == NULL)
+ if (filename == NULL) /* (should never happen) */
{
Error(ERR_WARN, "cannot find sound file '%s'", basename);
- return FALSE;
+ return;
}
- return Load_WAV(filename);
+ if (*snd_info && strcmp(filename, (*snd_info)->source_filename) == 0)
+ {
+ /* The old and new sound are the same (have the same filename and path).
+ This usually means that this sound does not exist in this sound set
+ and a fallback to the existing sound is done. */
+
+ return;
+ }
+
+ if (*snd_info)
+ FreeSound(*snd_info);
+
+ *snd_info = Load_WAV(filename);
}
-void InitSoundList(int num_list_entries)
+void InitSoundList(char *sound_name_list[], int num_list_entries)
{
- Sound = checked_calloc(num_list_entries * sizeof(SoundInfo *));
+ if (Sound == NULL)
+ Sound = checked_calloc(num_list_entries * sizeof(SoundInfo *));
+
+ sound_name = sound_name_list;
num_sounds = num_list_entries;
}
if (Sound == NULL || list_pos >= num_sounds)
return;
- if (Sound[list_pos])
- FreeSound(Sound[list_pos]);
-
- Sound[list_pos] = LoadCustomSound(basename);
+ LoadCustomSound(&Sound[list_pos], basename);
}
static MusicInfo *Load_MOD(char *filename)
#endif
}
+static void ReloadCustomSounds()
+{
+ int i;
+
+#if 1
+ printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current);
+#endif
+
+ LoadSoundsInfo();
+
+ for(i=0; i<num_sounds; i++)
+ LoadSoundToList(sound_name[i], i);
+}
+
+static void ReloadCustomMusic()
+{
+#if 1
+ printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
+#endif
+
+ FreeAllMusic();
+
+ LoadCustomMusic();
+}
+
static void InitReloadSoundsOrMusic(char *set_name, int type)
{
#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL)
int fragment_size; /* audio device fragment size in bytes */
};
+#if 0
+struct SoundsInfo
+{
+ int num_sounds;
+ char *sound_name;
+
+#if 0
+ void (*func_reload_sounds)(void);
+ void (*func_reload_music)(void);
+#endif
+}
+#endif
+
struct SampleInfo
{
int type;
void SoundServer(void);
/* sound client functions */
-void ReloadSounds(char *);
-void ReloadMusic(char *);
-SoundInfo *LoadCustomSound(char *);
-void InitSoundList(int);
-void LoadSoundToList(char *, int);
-void LoadCustomMusic(void);
void PlayMusic(int);
void PlaySound(int);
void PlaySoundStereo(int, int);
void StopSound(int);
void StopSounds(void);
void StopSoundExt(int, int);
+void InitSoundList(char **, int);
void InitReloadSounds(char *);
void InitReloadMusic(char *);
-void FreeSound(SoundInfo *);
-void FreeMusic(MusicInfo *);
void FreeAllSounds(void);
void FreeAllMusic(void);
audio.sound_enabled = enabled;
}
+#if 0
inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void),
void (*func_reload_music)(void))
{
audio.func_reload_sounds = func_reload_sounds;
audio.func_reload_music = func_reload_music;
}
+#endif
/* ========================================================================= */
boolean sound_enabled;
boolean sound_deactivated; /* for temporarily disabling sound */
- void (*func_reload_sounds)(void);
- void (*func_reload_music)(void);
-
int soundserver_pipe[2];
int soundserver_pid;
char *device_name;
inline void OpenAudio(void);
inline void CloseAudio(void);
inline void SetAudioMode(boolean);
+#if 0
inline void SetAudioReloadFunctions(void (*func_reload_sounds)(void),
void (*func_reload_music)(void));
+#endif
inline void InitEventFilter(EventFilter);
inline boolean PendingEvent(void);
"gate.wav"
};
+/* sound effects: setup file identifiers and corresponding default filenames */
+struct
+{
+ char *identifier;
+ char *default_filename;
+}
+sound_effect[NUM_SOUND_EFFECTS] =
+{
+ { "collecting_infotron", "infotron.wav" },
+ { "falling_zonk", "zonkdown.wav" },
+ { "pushing_zonk", "zonkpush.wav" }
+};
+
char *element_info[] =
{
"empty space", /* 0 */
#define NUM_SOUNDS 55
+
+/* sound effects */
+#define SND_TEST1 0
+#define SND_TEST2 1
+#define SND_TEST3 2
+
+#define NUM_SOUND_EFFECTS 3
+
+
/* values for game_status */
#define EXITGAME 0
#define MAINMENU 1
-#define COMPILE_DATE_STRING "[2002-04-25 00:14]"
+#define COMPILE_DATE_STRING "[2002-04-28 23:49]"