diff --git a/src/gb/gbSound.cpp b/src/gb/gbSound.cpp index 3f57496b..a1209c6c 100644 --- a/src/gb/gbSound.cpp +++ b/src/gb/gbSound.cpp @@ -121,6 +121,13 @@ static void reset_apu() static void remake_stereo_buffer() { + // APU + if ( !gb_apu ) + { + gb_apu = new Gb_Apu; // TODO: handle errors + reset_apu(); + } + // Stereo_Buffer delete stereo_buffer; stereo_buffer = 0; @@ -128,20 +135,15 @@ static void remake_stereo_buffer() stereo_buffer = new Simple_Effects_Buffer; // TODO: handle out of memory if ( stereo_buffer->set_sample_rate( soundSampleRate ) ) { } // TODO: handle out of memory stereo_buffer->clock_rate( gb_apu->clock_rate ); - - // APU + + // Multi_Buffer static int const chan_types [chan_count] = { Multi_Buffer::wave_type+1, Multi_Buffer::wave_type+2, Multi_Buffer::wave_type+3, Multi_Buffer::mixed_type+1 }; if ( stereo_buffer->set_channel_count( chan_count, chan_types ) ) { } // TODO: handle errors - if ( !gb_apu ) - { - gb_apu = new Gb_Apu; // TODO: handle errors - reset_apu(); - } - + // Volume Level apply_effects(); apply_volume(); } diff --git a/src/gba/Sound.cpp b/src/gba/Sound.cpp index e8f7523f..441573d1 100644 --- a/src/gba/Sound.cpp +++ b/src/gba/Sound.cpp @@ -446,6 +446,13 @@ static void remake_stereo_buffer() pcm [0].pcm.init(); pcm [1].pcm.init(); + // APU + if ( !gb_apu ) + { + gb_apu = new Gb_Apu; // TODO: handle out of memory + reset_apu(); + } + // Stereo_Buffer delete stereo_buffer; stereo_buffer = 0; @@ -459,13 +466,7 @@ static void remake_stereo_buffer() pcm [1].which = 1; apply_filtering(); - // APU - if ( !gb_apu ) - { - gb_apu = new Gb_Apu; // TODO: handle out of memory - reset_apu(); - } - + // Volume Level apply_muting(); apply_volume(); }