diff --git a/src/basic_allpass.h b/src/basic_allpass.h index 3cae772..faff638 100644 --- a/src/basic_allpass.h +++ b/src/basic_allpass.h @@ -16,10 +16,8 @@ template class AudioFilterAllpass { public: - ~AudioFilterAllpass() - { - if (bf) free(bf); - } + AudioFilterAllpass() { bf = NULL; } + ~AudioFilterAllpass() { free(bf); } /** * @brief Allocate the filter buffer in RAM * set the pointer to the allpass coeff @@ -28,6 +26,7 @@ public: */ bool init(float* coeffPtr) { + free(bf); bf = (float *)malloc(N*sizeof(float)); // allocate buffer if (!bf) return false; kPtr = coeffPtr; diff --git a/src/basic_bypassStereo_F32.cpp b/src/basic_bypassStereo_F32.cpp index d895857..c908e57 100644 --- a/src/basic_bypassStereo_F32.cpp +++ b/src/basic_bypassStereo_F32.cpp @@ -56,7 +56,7 @@ bool bypass_process(audio_block_f32_t** p_blockL, audio_block_f32_t** p_blockR, { if (*p_blockL) AudioStream_F32::release(*p_blockL); // blockL is available and contains audio. Discard it result = false; - break; // and sigbnal failed operation + break; // and signal failed operation } memset(&(*p_blockR)->data[0], 0, (*p_blockR)->length*sizeof(float32_t)); } diff --git a/src/basic_delay.h b/src/basic_delay.h index 7c549d6..eb1accd 100644 --- a/src/basic_delay.h +++ b/src/basic_delay.h @@ -23,13 +23,14 @@ class AudioBasicDelay { public: + AudioBasicDelay() { bf = NULL; } ~AudioBasicDelay() { - if(bf) free(bf); + free(bf); } bool init(uint32_t size_samples, bool psram=false) { - if(bf) free(bf); + free(bf); use_psram = psram; size = size_samples; if (use_psram) bf = (float *)extmem_malloc(size * sizeof(float)); // allocate buffer in PSRAM diff --git a/src/basic_pitch.h b/src/basic_pitch.h index c3640df..f5aa8cd 100644 --- a/src/basic_pitch.h +++ b/src/basic_pitch.h @@ -23,8 +23,11 @@ extern const float music_intevals[]; // semitone intervals -1oct to +2oct class AudioBasicPitch { public: + AudioBasicPitch() { bf = NULL; } + ~AudioBasicPitch() { free(bf); } bool init() { + free(bf); outFilter.init(hp_f, (float *)&hp_gain, lp_f, &lp_gain); bf = (float *)malloc(BASIC_PITCH_BUF_SIZE*sizeof(float)); // allocate buffer if (!bf) return false; diff --git a/src/basic_tempBuffer.h b/src/basic_tempBuffer.h index 03ab7f9..d55aadf 100644 --- a/src/basic_tempBuffer.h +++ b/src/basic_tempBuffer.h @@ -16,7 +16,7 @@ public: AudioBasicTempBuffer_F32(const AudioSettings_F32 &settings) : AudioStream_F32(1, inputQueueArray_f32) { blockSize = settings.audio_block_samples; - memset(&data[0], 0, AUDIO_BLOCK_SAMPLES * sizeof(float32_t)); + memset(&data[0], 0, blockSize * sizeof(float32_t)); dataPtr = &data[0]; }; ~AudioBasicTempBuffer_F32(){}; @@ -30,7 +30,7 @@ public: float32_t* dataPtr; private: audio_block_f32_t *inputQueueArray_f32[1]; - uint16_t blockSize = AUDIO_BLOCK_SAMPLES; + uint16_t blockSize; float32_t data[AUDIO_BLOCK_SAMPLES]; }; diff --git a/src/effect_reverbsc_F32.cpp b/src/effect_reverbsc_F32.cpp index 4f4e21c..1aa2328 100644 --- a/src/effect_reverbsc_F32.cpp +++ b/src/effect_reverbsc_F32.cpp @@ -60,6 +60,7 @@ AudioEffectReverbSc_F32::AudioEffectReverbSc_F32(bool use_psram) : AudioStream_F aux_ = (float32_t *) extmem_malloc(aux_size_bytes); #else flags.mem_fail = 1; + flags.memsetup_done = 1; // nothing to setup, make it ready initialised = true; return; #endif @@ -67,7 +68,6 @@ AudioEffectReverbSc_F32::AudioEffectReverbSc_F32(bool use_psram) : AudioStream_F else { aux_ = (float32_t *) malloc(aux_size_bytes); - //flags.memsetup_done = 1; } if (!aux_) { @@ -173,7 +173,11 @@ void AudioEffectReverbSc_F32::update() if (!initialised) return; // special case if memory allocation failed, pass the input signal directly to the output - if (flags.mem_fail) bp_mode = BYPASS_MODE_PASS; + if (flags.mem_fail) + { + bp_mode = BYPASS_MODE_PASS; + flags.bypass = 1; + } blockL = AudioStream_F32::receiveWritable_f32(0); blockR = AudioStream_F32::receiveWritable_f32(1); diff --git a/src/effect_reverbsc_F32.h b/src/effect_reverbsc_F32.h index f01bcaa..dfa458c 100644 --- a/src/effect_reverbsc_F32.h +++ b/src/effect_reverbsc_F32.h @@ -156,7 +156,7 @@ private: float32_t damp_fact_, damp_fact_tmp; bool initialised = false; ReverbScDl_t delay_lines_[8]; - float32_t *aux_; // main delay line storage buffer, placed either in RAM2 or PSRAM + float32_t *aux_ = NULL; // main delay line storage buffer, placed either in RAM2 or PSRAM const uint32_t aux_size_bytes = REVERBSC_DLYBUF_SIZE*sizeof(float32_t); float32_t dry_gain = 0.5f; float32_t wet_gain = 0.5f;