summaryrefslogtreecommitdiff
path: root/drivers/chibi/event_stream_chibi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/chibi/event_stream_chibi.cpp')
-rw-r--r--drivers/chibi/event_stream_chibi.cpp20
1 files changed, 15 insertions, 5 deletions
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;
}