diff options
Diffstat (limited to 'drivers/chibi')
-rw-r--r-- | drivers/chibi/cp_player_data.cpp | 2 | ||||
-rw-r--r-- | drivers/chibi/cp_player_data_events.cpp | 16 | ||||
-rw-r--r-- | drivers/chibi/event_stream_chibi.cpp | 20 |
3 files changed, 31 insertions, 7 deletions
diff --git a/drivers/chibi/cp_player_data.cpp b/drivers/chibi/cp_player_data.cpp index 324c3f7c36..99bc4fddd2 100644 --- a/drivers/chibi/cp_player_data.cpp +++ b/drivers/chibi/cp_player_data.cpp @@ -125,7 +125,7 @@ int64_t CPPlayer::get_channel_last_note_time_usec(int p_channel) const { void CPPlayer::set_channel_global_volume(int p_channel,int p_volume) { CP_FAIL_INDEX(p_channel,64); - control.channel[p_channel].channel_global_volume=p_volume; + control.channel[p_channel].channel_global_volume=CLAMP(p_volume,0,255); } diff --git a/drivers/chibi/cp_player_data_events.cpp b/drivers/chibi/cp_player_data_events.cpp index 6f2815211c..32335040bc 100644 --- a/drivers/chibi/cp_player_data_events.cpp +++ b/drivers/chibi/cp_player_data_events.cpp @@ -146,6 +146,7 @@ void CPPlayer::Voice_Control::reset() { void CPPlayer::Channel_Control::reset() { + int prev_gv =channel_global_volume; cp_memzero(this,sizeof(*this)); slave_voice=NULL; @@ -162,6 +163,7 @@ void CPPlayer::Channel_Control::reset() { reserved=false; carry.maybe=false; last_event_usecs=-1; + channel_global_volume=prev_gv; } void CPPlayer::Voice_Control::update_info_from_master_channel() { @@ -316,6 +318,15 @@ void CPPlayer::update_mixer() { } + /*printf("fadeout %i\n",(int)v.fadeout_volume); + printf("channel %i\n",(int)v.channel_volume); + printf("output %i\n",(int)v.output_volume); + printf("env %i\n",(int)tmp_volenv_value); + printf("cgb %i\n",(int)v.master_channel->channel_global_volume); +*/ + + + int cv=v.master_channel->channel_global_volume; tmpvol=(uint64_t)v.fadeout_volume; /* max 1024 - 10 bits */ tmpvol*=(uint64_t)v.channel_volume; /* * max 64 - 6 bits */ @@ -341,6 +352,7 @@ void CPPlayer::update_mixer() { v.total_volume=tmpvol; + if ((v.master_channel!=NULL) && song->is_channel_mute( v.master_channel_index ) && !v.master_channel->reserved) { mixer->set_voice_volume(i,0); @@ -518,7 +530,7 @@ void CPPlayer::update_mixer() { } } - + switch(song->get_reverb_mode()) { case CPSong::REVERB_MODE_ROOM: { @@ -569,6 +581,8 @@ void CPPlayer::update_mixer() { } mixer->set_chorus_params(song->get_chorus_delay_ms(),song->get_chorus_separation_ms(),song->get_chorus_depth_ms10(),song->get_chorus_speed_hz10() ); + + } diff --git a/drivers/chibi/event_stream_chibi.cpp b/drivers/chibi/event_stream_chibi.cpp index a9106d6d78..2deb83e2bc 100644 --- a/drivers/chibi/event_stream_chibi.cpp +++ b/drivers/chibi/event_stream_chibi.cpp @@ -372,6 +372,7 @@ void CPMixerImpl::set_voice_panning(int p_voice_index,int p_pan) { void CPMixerImpl::set_voice_volume(int p_voice_index,int p_vol) { + Voice &v=voices[p_voice_index]; ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL); float vol = p_vol/512.0; @@ -488,8 +489,9 @@ void CPMixerImpl::process_usecs(int p_usec,float p_volume,float p_pitch_scale,fl p_usec-=callback_timeout; callback_timeout=0; - if (callback) + if (callback) { callback(userdata); + } callback_timeout=callback_interval*(1.0/p_tempo_scale); } else { @@ -704,6 +706,9 @@ float EventStreamPlaybackChibi::get_tempo_scale() const{ void EventStreamPlaybackChibi::set_channel_volume(int p_channel,float p_volume) { + + if (p_channel>=64) + return; player->set_channel_global_volume(p_channel,p_volume*256); } @@ -784,28 +789,33 @@ RES ResourceFormatLoaderChibi::load(const String &p_path,const String& p_origina Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); CPLoader_IT loader(&f); - loader.load_song(p_path.utf8().get_data(),&esc->song,false); + CPLoader::Error err = loader.load_song(p_path.utf8().get_data(),&esc->song,false); + ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); + return esc; } else if (el=="xm") { Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); CPLoader_XM loader(&f); - loader.load_song(p_path.utf8().get_data(),&esc->song,false); + CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); + ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); return esc; } else if (el=="s3m") { Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); CPLoader_S3M loader(&f); - loader.load_song(p_path.utf8().get_data(),&esc->song,false); + CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); + ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); return esc; } else if (el=="mod") { Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) ); CPLoader_MOD loader(&f); - loader.load_song(p_path.utf8().get_data(),&esc->song,false); + CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false); + ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES()); return esc; } |