mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-07 14:28:12 +03:00
Refactor audio to enable bgm looping
SDL_mixer reads loop information from WAV files if you use the Mix_Music interface, but NOT the Mix_Chunk interface. So bgm now uses the Mix_Music interface to get proper looping. There's also some code here for reading bgi files (taken from xsystem35) but it's not actually used. There doesn't seem to be a simple way to set up custom loops with SDL_mixer.
This commit is contained in:
+35
-32
@@ -19,40 +19,43 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
enum audio_type {
|
||||
AUDIO_MUSIC,
|
||||
AUDIO_SOUND
|
||||
};
|
||||
|
||||
void audio_init(void);
|
||||
void audio_fini(void);
|
||||
|
||||
bool audio_exists(enum audio_type type, int no);
|
||||
int audio_prepare(enum audio_type type, int channel, int no);
|
||||
int audio_unprepare(enum audio_type type, int channel);
|
||||
int audio_play(enum audio_type type, int channel);
|
||||
int audio_stop(enum audio_type type, int channel);
|
||||
bool audio_is_playing(enum audio_type type, int channel);
|
||||
int audio_set_loop_count(enum audio_type type, int channel, int count);
|
||||
int audio_get_loop_count(enum audio_type type, int channel);
|
||||
int audio_set_loop_start_pos(enum audio_type type, int channel, int pos);
|
||||
int audio_set_loop_end_pos(enum audio_type type, int channel, int pos);
|
||||
int audio_fade(enum audio_type type, int channel, int time, int volume, bool stop);
|
||||
int audio_stop_fade(enum audio_type type, int channel);
|
||||
bool audio_is_fading(enum audio_type type, int channel);
|
||||
int audio_pause(enum audio_type type, int channel);
|
||||
int audio_restart(enum audio_type type, int channel);
|
||||
bool audio_is_paused(enum audio_type type, int channel);
|
||||
int audio_get_pos(enum audio_type type, int channel);
|
||||
int audio_get_length(enum audio_type type, int channel);
|
||||
int audio_get_sample_pos(enum audio_type type, int channel);
|
||||
int audio_get_sample_length(enum audio_type type, int channel);
|
||||
int audio_seek(enum audio_type type, int channel, int pos);
|
||||
int audio_get_unused_channel(enum audio_type type);
|
||||
int audio_reverse_LR(enum audio_type type, int channel);
|
||||
int audio_get_volume(enum audio_type type, int channel);
|
||||
int audio_get_time_length(enum audio_type type, int channel);
|
||||
int audio_get_group_num(enum audio_type type, int channel);
|
||||
int audio_prepare_from_file(enum audio_type type, int channel, char *filename);
|
||||
bool wav_exists(int no);
|
||||
bool bgm_exists(int no);
|
||||
int wav_prepare(int ch, int no);
|
||||
int bgm_prepare(int ch, int no);
|
||||
int wav_unprepare(int ch);
|
||||
int bgm_unprepare(int ch);
|
||||
int wav_play(int ch);
|
||||
int bgm_play(int ch);
|
||||
int wav_stop(int ch);
|
||||
int bgm_stop(int ch);
|
||||
bool wav_is_playing(int ch);
|
||||
bool bgm_is_playing(int ch);
|
||||
//int audio_set_loop_count(enum audio_type type, int channel, int count);
|
||||
//int audio_get_loop_count(enum audio_type type, int channel);
|
||||
//int audio_set_loop_start_pos(enum audio_type type, int channel, int pos);
|
||||
//int audio_set_loop_end_pos(enum audio_type type, int channel, int pos);
|
||||
int wav_fade(int ch, int time, int volume, bool stop);
|
||||
int bgm_fade(int ch, int time, int volume, bool stop);
|
||||
//int audio_stop_fade(enum audio_type type, int channel);
|
||||
//bool audio_is_fading(enum audio_type type, int channel);
|
||||
//int audio_pause(enum audio_type type, int channel);
|
||||
//int audio_restart(enum audio_type type, int channel);
|
||||
//bool audio_is_paused(enum audio_type type, int channel);
|
||||
//int audio_get_pos(enum audio_type type, int channel);
|
||||
//int audio_get_length(enum audio_type type, int channel);
|
||||
//int audio_get_sample_pos(enum audio_type type, int channel);
|
||||
//int audio_get_sample_length(enum audio_type type, int channel);
|
||||
//int audio_seek(enum audio_type type, int channel, int pos);
|
||||
int wav_get_unused_channel(void);
|
||||
int bgm_get_unused_channel(void);
|
||||
//int audio_reverse_LR(enum audio_type type, int channel);
|
||||
//int audio_get_volume(enum audio_type type, int channel);
|
||||
int wav_get_time_length(int ch);
|
||||
//int audio_get_group_num(enum audio_type type, int channel);
|
||||
//int audio_prepare_from_file(enum audio_type type, int channel, char *filename);
|
||||
|
||||
#endif /* SYSTEM4_AUDIO_H */
|
||||
|
||||
@@ -29,6 +29,9 @@ struct config {
|
||||
char *home_dir;
|
||||
int view_width;
|
||||
int view_height;
|
||||
|
||||
char *bgi_path;
|
||||
char *wai_path;
|
||||
};
|
||||
|
||||
struct config config;
|
||||
|
||||
Reference in New Issue
Block a user