Mercurial > otakunoraifu
diff music2/music.cc @ 26:f45da03ca631
* Corrected --disable-vorbis in configure.ac
* Added sound configuration
* Added misc functions
author | thib |
---|---|
date | Sun, 01 Mar 2009 19:08:02 +0000 |
parents | 4d7486cb20a9 |
children | f88d47a4bf87 |
line wrap: on
line diff
--- a/music2/music.cc +++ b/music2/music.cc @@ -43,9 +43,6 @@ using namespace std; -#define MUSIC_VOLUME 0.2 -#define MUSIC_VOLUME 1 - int pcm_enable = 0; Mix_Chunk *play_chunk[MIX_PCM_SIZE]; @@ -60,11 +57,12 @@ MuSys::MuSys(AyuSysConfig& _config) : co // #define delete fprintf(stderr,"smus.cc: %d.",__LINE__), delete -void bgm_start(const char* path, int loop_pt); -void effec_start(int chn, const char* path, int loop, int fadein_time); +void bgm_start(const char* path, int loop_pt, int * volmod); +void effec_start(int chn, const char* path, int loop, int fadein_time, int * volmod); void bgm_fadeout(int time); void MuSys::PlayCDROM(char* name, int play_count) { + config.GetParam("#VOLMOD", 4, &volmod[0], &volmod[1], &volmod[2], &volmod[3]); char wave[128]; wave[127] = '\0'; wave[0] = '\0'; strcpy(cdrom_track, name); @@ -83,9 +81,9 @@ void MuSys::PlayCDROM(char* name, int pl // BGM 再生 if (!pcm_enable) return; if (play_count == 0) - bgm_start(wave, -1); + bgm_start(wave, -1, volmod); else - bgm_start(wave, config.track_name.TrackStart(name)); + bgm_start(wave, config.track_name.TrackStart(name), volmod); return; } @@ -99,16 +97,16 @@ void MuSys::StopCDROM(int time) void MuSys::PlaySE(const char* se, int loop_flag, int channel) { if (! pcm_enable) return; if (loop_flag) - effec_start(MIX_PCM_EFFEC, se, 10000, 0); + effec_start(MIX_PCM_EFFEC, se, 10000, 0, volmod); else - effec_start(MIX_PCM_EFFEC, se, 0, 0); + effec_start(MIX_PCM_EFFEC, se, 0, 0, volmod); return; } void MuSys::PlaySE(int number) { if (! pcm_enable) return; const char* se_name = config.track_name.SETrack(number); if (se_name == 0) return; - effec_start(MIX_PCM_EFFEC, se_name, 0, 0); + effec_start(MIX_PCM_EFFEC, se_name, 0, 0, volmod); return; } void MuSys::StopSE(int time) { @@ -175,6 +173,7 @@ void MuSys::FinalizeMusic(void) struct WavChunk { WAVFILE* wav; int loop_pt; + int *volmod; static void callback(void* userdata, Uint8* stream, int len); }; WavChunk wav_playing; @@ -202,7 +201,7 @@ void WavChunk::callback(void *userdata, } } - int cur_vol = MUSIC_VOLUME*SDL_MIX_MAXVOLUME; + int cur_vol = (*chunk->volmod)*SDL_MIX_MAXVOLUME/255; if (fadetime_total) { // 音楽を停止中 (fade out) @@ -233,7 +232,7 @@ void bgm_fadeout(int time) { static SDL_RWops* OpenSDLRW(const char* path); static WAVFILE* OpenWaveFile(const char* path); -void bgm_start(const char* path, int loop_pt) { +void bgm_start(const char* path, int loop_pt, int * volmod) { if (! pcm_enable) return; fprintf(stderr,"bgm start %s\n",path); WAVFILE* wav = OpenWaveFile(path); @@ -248,14 +247,14 @@ fprintf(stderr,"bgm start %s\n",path); } wav_playing.wav = wav; wav_playing.loop_pt = loop_pt; + wav_playing.volmod = &volmod[0]; fadetime_total = 0; fadecount = 0; Mix_HookMusic( &(WavChunk::callback), (void*)&wav_playing); - Mix_VolumeMusic(MUSIC_VOLUME*MIX_MAX_VOLUME); return; } -void effec_start(int chn, const char* path, int loop, int fadein_time) { +void effec_start(int chn, const char* path, int loop, int fadein_time, int * volmod) { if (! pcm_enable) return; SDL_RWops* op = OpenSDLRW(path); if (op == 0) { // ファイルが見付からない @@ -268,10 +267,10 @@ void effec_start(int chn, const char* pa } play_chunk[chn] = Mix_LoadWAV_RW(op, 1); if (fadein_time <= 0) { - Mix_Volume(chn, 128); + Mix_Volume(chn, volmod[3]*SDL_MIX_MAXVOLUME/255); Mix_PlayChannel(chn, play_chunk[chn],loop); } else { - Mix_Volume(chn, 128); + Mix_Volume(chn, volmod[3]*SDL_MIX_MAXVOLUME/255); Mix_FadeInChannel(chn, play_chunk[chn],loop,fadein_time); } return; @@ -304,7 +303,7 @@ void MuSys::PlayKoe(const char* path) { if (playing_koedata == 0) { return; } - Mix_Volume(chn, 128); + Mix_Volume(chn, volmod[1]*SDL_MIX_MAXVOLUME/255); play_chunk[chn] = Mix_LoadWAV_RW(SDL_RWFromMem(playing_koedata, len+0x2c), 1); Mix_PlayChannel(chn, play_chunk[chn],0); return;