bypass system reworked

main
pio 3 days ago
parent 58bb5d5d12
commit bcc0ad0c59
  1. 41
      src/HxFx_memcpy.h
  2. 3
      src/basic_DSPutils.h
  3. 70
      src/basic_bypassStereo_F32.cpp
  4. 31
      src/basic_bypassStereo_F32.h
  5. 1
      src/basic_components.h
  6. 44
      src/effect_delaystereo_F32.cpp
  7. 7
      src/effect_delaystereo_F32.h
  8. 2
      src/effect_gainStereo_F32.h
  9. 83
      src/effect_platereverb_F32.cpp
  10. 11
      src/effect_platereverb_F32.h
  11. 80
      src/effect_reverbsc_F32.cpp
  12. 10
      src/effect_reverbsc_F32.h
  13. 42
      src/effect_springreverb_F32.cpp
  14. 12
      src/effect_springreverb_F32.h
  15. 2
      src/filter_equalizer_F32.cpp
  16. 2
      src/filter_equalizer_F32.h
  17. 38
      src/filter_ir_cabsim_F32.cpp
  18. 13
      src/filter_ir_cabsim_F32.h
  19. 20
      src/filter_ir_cabsim_irs.cpp

@ -1,41 +0,0 @@
#ifndef _HX_MEMCPY_H
#define _HX_MEMCPY_H
/**
* @brief combine two separate buffers into interleaved one
* @param sz - samples per output buffer (divisible by 2)
* @param dst - pointer to source buffer
* @param srcA - pointer to A source buffer (even samples)
* @param srcB - pointer to B source buffer (odd samples)
* @retval none
*/
inline void memcpyInterleave_f32(float32_t *srcA, float32_t *srcB, float32_t *dst, int16_t sz)
{
while(sz)
{
*dst++ = *srcA++;
*dst++ = *srcB++;
sz--;
*dst++ = *srcA++;
*dst++ = *srcB++;
sz--;
}
}
inline void memcpyInterleave_f32(float32_t *srcA, float32_t *srcB, float32_t *dst, int16_t sz);
inline void memcpyDeinterleave_f32(float32_t *src, float32_t *dstA, float32_t *dstB, int16_t sz)
{
while(sz)
{
*dstA++ = *src++;
*dstB++ = *src++;
sz--;
*dstA++ = *src++;
*dstB++ = *src++;
sz--;
}
}
inline void memcpyDeinterleave_f32(float32_t *src, float32_t *dstA, float32_t *dstB, int16_t sz);
#endif // _HX_MEMCPY_H

@ -6,6 +6,9 @@
#define F32_TO_I32_NORM_FACTOR (2147483647) // which is 2^31-1 #define F32_TO_I32_NORM_FACTOR (2147483647) // which is 2^31-1
#define I32_TO_F32_NORM_FACTOR (4.656612875245797e-10) //which is 1/(2^31 - 1) #define I32_TO_F32_NORM_FACTOR (4.656612875245797e-10) //which is 1/(2^31 - 1)
#define I24_TO_F32_NORM_FACTOR (1.1920930376163766e-07) // 1/(2^23 - 1)
#define I16_TO_F32_NORM_FACTOR (3.051850947599719e-05)
static inline void mix_pwr(float32_t mix, float32_t *wetMix, float32_t *dryMix); static inline void mix_pwr(float32_t mix, float32_t *wetMix, float32_t *dryMix);
static inline void mix_pwr(float32_t mix, float32_t *wetMix, float32_t *dryMix) static inline void mix_pwr(float32_t mix, float32_t *wetMix, float32_t *dryMix)

@ -0,0 +1,70 @@
#include "basic_bypassStereo_F32.h"
bool bypass_process(audio_block_f32_t** p_blockL, audio_block_f32_t** p_blockR, bypass_mode_t mode, bool state)
{
bool result = false;
/**
* @brief bypass mode PASS can be used to validate the incoming audio blocks, create silence blocks if the input ones
* are not available (NULL).
*/
if (!state) mode = BYPASS_MODE_PASS;
switch(mode)
{
/**
* @brief TRAILS mode is the same as OFF with the different the component "update" function does not return
* and processes the incoming data, which is silence. Used in reverb/delays to let them naturally
* fade out
*/
case BYPASS_MODE_TRAILS:
/**
* @brief bypass mode OFF sends silence on both outputs. Used with components placed in an effect loop with separate
* dry path. Classic example is a parallel effect loop used for delays and reverbs:
* input ------------> |0 |---> output
* |--->reverb --> |1 mixer|
*/
case BYPASS_MODE_OFF:
if (*p_blockL) AudioStream_F32::release(*p_blockL); // discard both input blocks
if (*p_blockR) AudioStream_F32::release(*p_blockR);
*p_blockL = NULL;
*p_blockR = NULL;
// no break - let it run through the next switch case, with input blocks as NULL it will emit silence on both channels
/**
* @brief PASS mode connects the input signal directly to the output
* in case one of the blocks is not available, it tries to allocate a new block and make it silent
* returns false if allocation is not possbile due to not enoufg audio memory (increase AudioMemory_F32(xx);)
* Used in components connected in series.
*/
case BYPASS_MODE_PASS:
if(!*p_blockL) // no channel left available
{
*p_blockL = AudioStream_F32::allocate_f32(); // try to allocate a new block
if( !*p_blockL)
{
if (*p_blockR) AudioStream_F32::release(*p_blockR); // if the Rch is present, release/discard it
result = false;
break; // operation failed due to no audio memory left
}
memset(&(*p_blockL)->data[0], 0, (*p_blockL)->length*sizeof(float32_t)); // zero the data block to make it silent
}
if(!*p_blockR) // no channel right available
{
*p_blockR = AudioStream_F32::allocate_f32();
if( !*p_blockR) // no memory for a new block, but we might have L channel zeroed
{
if (*p_blockL) AudioStream_F32::release(*p_blockL); // blockL is available and contains audio. Discard it
result = false;
break; // and sigbnal failed operation
}
memset(&(*p_blockR)->data[0], 0, (*p_blockR)->length*sizeof(float32_t));
}
result = true; // audio data on L and R is avaialble
break;
default:
break;
}
return result;
}

@ -0,0 +1,31 @@
#ifndef _BASIC_BYPASSSTEREO_F32_H_
#define _BASIC_BYPASSSTEREO_F32_H_
#include "Arduino.h"
#include "AudioStream_F32.h"
typedef enum
{
BYPASS_MODE_PASS, // pass the input signal to the output
BYPASS_MODE_OFF, // mute the output
BYPASS_MODE_TRAILS // mutes the input only
}bypass_mode_t;
/**
* @brief Stereo bypass handling and validating the input audio blocks
* The main component has to provide the pointers to audio blocks received inside the "update" function
* This function checks whether they are avaiable and genereates silence where needed (null block received)
* With the bypass OFF (state=false) it can be used to validate the input blocks before processing.
*
* @param p_blockL pointer to an audio_block_f32_t pointer received/allocated in the main compontnt, channel L
* @param p_blockR pointer to an audio_block_f32_t pointer received/allocated in the main compontnt, channel R
* @param mode one of the bypass models defined in bypass_mode_t enum
* @param state bypass state, true = effect OFF, false = effect ON
* @return true operation succesful, blocks are available for further processing
* @return false fail, some of the blocks are not available, do not process the data
*/
bool bypass_process(audio_block_f32_t** p_blockL, audio_block_f32_t** p_blockR, bypass_mode_t mode, bool state);
#endif // _BASIC_BYPASSSTEREO_F32_H_

@ -8,5 +8,6 @@
#include "basic_pitch.h" #include "basic_pitch.h"
#include "basic_DSPutils.h" #include "basic_DSPutils.h"
#include "basic_tempBuffer.h" #include "basic_tempBuffer.h"
#include "basic_bypassStereo_F32.h"
#endif // _BASIC_COMPONENTS_H_ #endif // _BASIC_COMPONENTS_H_

@ -84,6 +84,11 @@ void AudioEffectDelayStereo_F32::update()
uint32_t mod_int; uint32_t mod_int;
static float32_t dly_time_flt = 0.0f; static float32_t dly_time_flt = 0.0f;
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!bypass_process(&blockL, &blockR, bp_mode, bp))
return;
if (bp) if (bp)
{ {
// mem cleanup not required in TRAILS mode // mem cleanup not required in TRAILS mode
@ -94,51 +99,22 @@ void AudioEffectDelayStereo_F32::update()
tap_counter = 0; tap_counter = 0;
} }
if (infinite) freeze(false); if (infinite) freeze(false);
switch(bp_mode) if (bp_mode != BYPASS_MODE_TRAILS)
{ {
case BYPASS_MODE_PASS:
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
AudioStream_F32::transmit(blockL, 0); AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1); AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL); AudioStream_F32::release(blockL);
AudioStream_F32::release(blockR); AudioStream_F32::release(blockR);
return; return;
break; }
case BYPASS_MODE_OFF: else
blockL = AudioStream_F32::allocate_f32(); {
if (!blockL) return;
memset(&blockL->data[0], 0, blockL->length*sizeof(float32_t));
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockL, 1);
AudioStream_F32::release(blockL);
return;
break;
case BYPASS_MODE_TRAILS:
inputGainSet = 0.0f; inputGainSet = 0.0f;
tap_active = false; // reset tap tempo tap_active = false; // reset tap tempo
tap_counter = 0; tap_counter = 0;
break;
default:
break;
} }
} }
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!blockL || !blockR)
{
if (blockL)
AudioStream_F32::release(blockL);
if (blockR)
AudioStream_F32::release(blockR);
return;
}
cleanup_done = false; cleanup_done = false;
for (i=0; i < blockL->length; i++) for (i=0; i < blockL->length; i++)

@ -209,12 +209,7 @@ public:
lfo.setDepth(d); lfo.setDepth(d);
__enable_irq(); __enable_irq();
} }
typedef enum
{
BYPASS_MODE_PASS, // pass the input signal to the output
BYPASS_MODE_OFF, // mute the output
BYPASS_MODE_TRAILS // mutes the input only
}bypass_mode_t;
void bypass_setMode(bypass_mode_t m) void bypass_setMode(bypass_mode_t m)
{ {
if (m <= BYPASS_MODE_TRAILS) bp_mode = m; if (m <= BYPASS_MODE_TRAILS) bp_mode = m;

@ -96,7 +96,7 @@ public:
} }
private: private:
audio_block_f32_t *inputQueueArray_f32[2]; // memory pointer for the input to this module audio_block_f32_t *inputQueueArray_f32[2];
float32_t gain = 1.0f; // default value float32_t gain = 1.0f; // default value
float32_t gainL, gainR, gainLset, gainRset; float32_t gainL, gainR, gainLset, gainRset;
float32_t pan, panL, panR; float32_t pan, panL, panR;

@ -121,12 +121,18 @@ void AudioEffectPlateReverb_F32::update()
{ {
#if defined(__IMXRT1062__) #if defined(__IMXRT1062__)
if (!initialised) return; if (!initialised) return;
audio_block_f32_t *blockL, *blockR, *blockSilent; audio_block_f32_t *blockL, *blockR;
int16_t i; int16_t i;
float acc; float acc;
float rv_time; float rv_time;
uint32_t offset; uint32_t offset;
float lfo_fr; float lfo_fr;
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!bypass_process(&blockL, &blockR, bp_mode, (bool)flags.bypass))
return;
// handle bypass, 1st call will clean the buffers to avoid continuing the previous reverb tail // handle bypass, 1st call will clean the buffers to avoid continuing the previous reverb tail
if (flags.bypass) if (flags.bypass)
{ {
@ -150,86 +156,13 @@ void AudioEffectPlateReverb_F32::update()
lp_dly4.reset(); lp_dly4.reset();
flags.cleanup_done = 1; flags.cleanup_done = 1;
} }
switch(bp_mode) if (bp_mode != BYPASS_MODE_TRAILS)
{
case BYPASS_MODE_PASS:
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{
// preapare silent block
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) // no memory,
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
if (blockL)
{
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::release(blockL);
}
else
{
AudioStream_F32::transmit(blockSilent, 0);
}
if (blockR)
{
AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockR);
}
else
{ {
AudioStream_F32::transmit(blockSilent, 1);
}
AudioStream_F32::release(blockSilent);
return;
}
AudioStream_F32::transmit(blockL, 0); AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1); AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL); AudioStream_F32::release(blockL);
AudioStream_F32::release(blockR); AudioStream_F32::release(blockR);
return; return;
break;
case BYPASS_MODE_OFF:
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) return;
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
AudioStream_F32::transmit(blockSilent, 0);
AudioStream_F32::transmit(blockSilent, 1);
AudioStream_F32::release(blockSilent);
return;
break;
case BYPASS_MODE_TRAILS:
default:
break;
}
}
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!blockL || !blockR)
{
// preapare silent block
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) // no memory,
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
if (!blockL)
{
blockL = blockSilent;
}
if (!blockR)
{
blockR = blockSilent;
} }
} }

@ -72,6 +72,11 @@ public:
inputGainSet = 0.5f; inputGainSet = 0.5f;
__enable_irq(); __enable_irq();
} }
void time(float n)
{
size(n);
}
/** /**
* @brief returns the set reverb time * @brief returns the set reverb time
* *
@ -256,12 +261,6 @@ public:
*/ */
bool freeze_get() {return flags.freeze;} bool freeze_get() {return flags.freeze;}
typedef enum
{
BYPASS_MODE_PASS, // pass the input signal to the output
BYPASS_MODE_OFF, // mute the output
BYPASS_MODE_TRAILS // mutes the input only
}bypass_mode_t;
/** /**
* @brief sets the bypass mode (see above) * @brief sets the bypass mode (see above)
* *

@ -44,7 +44,7 @@ AudioEffectReverbSc_F32::AudioEffectReverbSc_F32(bool use_psram) : AudioStream_F
flags.freeze = 0; flags.freeze = 0;
flags.cleanup_done = 1; flags.cleanup_done = 1;
flags.memsetup_done = 0; flags.memsetup_done = 0;
bp_mode = BYPASS_MODE_PASS;
int i, n_bytes = 0; int i, n_bytes = 0;
n_bytes = 0; n_bytes = 0;
if (use_psram) if (use_psram)
@ -67,9 +67,13 @@ AudioEffectReverbSc_F32::AudioEffectReverbSc_F32(bool use_psram) : AudioStream_F
else else
{ {
aux_ = (float32_t *) malloc(aux_size_bytes); aux_ = (float32_t *) malloc(aux_size_bytes);
flags.memsetup_done = 1; //flags.memsetup_done = 1;
}
if (!aux_)
{
flags.mem_fail = 1;
return;
} }
if (!aux_) return;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
@ -169,76 +173,24 @@ void AudioEffectReverbSc_F32::update()
if (!initialised) return; if (!initialised) return;
// special case if memory allocation failed, pass the input signal directly to the output // special case if memory allocation failed, pass the input signal directly to the output
if (flags.mem_fail) if (flags.mem_fail) bp_mode = BYPASS_MODE_PASS;
{
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL);
AudioStream_F32::release(blockR);
return;
}
if ( !flags.memsetup_done) blockL = AudioStream_F32::receiveWritable_f32(0);
{ blockR = AudioStream_F32::receiveWritable_f32(1);
flags.memsetup_done = memCleanup();
if (!bypass_process(&blockL, &blockR, bp_mode, (bool)flags.bypass))
return; return;
}
if (flags.bypass) if (flags.bypass || !flags.memsetup_done)
{
if (!flags.cleanup_done && bp_mode != BYPASS_MODE_TRAILS)
{
flags.cleanup_done = memCleanup();
}
switch(bp_mode)
{
case BYPASS_MODE_PASS:
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{ {
if (blockL) AudioStream_F32::release(blockL); if ( !flags.memsetup_done) flags.memsetup_done = memCleanup();
if (blockR) AudioStream_F32::release(blockR);
return;
}
AudioStream_F32::transmit(blockL, 0); AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1); AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL); AudioStream_F32::release(blockL);
AudioStream_F32::release(blockR); AudioStream_F32::release(blockR);
return; return;
break;
case BYPASS_MODE_OFF:
blockL = AudioStream_F32::allocate_f32();
if (!blockL) return;
memset(&blockL->data[0], 0, blockL->length*sizeof(float32_t));
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockL, 1);
AudioStream_F32::release(blockL);
return;
break;
case BYPASS_MODE_TRAILS:
break;
default:
break;
}
}
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!blockL || !blockR)
{
if (blockL)
AudioStream_F32::release(blockL);
if (blockR)
AudioStream_F32::release(blockR);
return;
} }
flags.cleanup_done = 0; flags.cleanup_done = 0;
for (i = 0; i < blockL->length; i++) for (i = 0; i < blockL->length; i++)
{ {

@ -22,6 +22,7 @@
#include "AudioStream_F32.h" #include "AudioStream_F32.h"
#include "arm_math.h" #include "arm_math.h"
#include "basic_DSPutils.h" #include "basic_DSPutils.h"
#include "basic_bypassStereo_F32.h"
#define REVERBSC_DLYBUF_SIZE 98936 #define REVERBSC_DLYBUF_SIZE 98936
@ -103,12 +104,6 @@ public:
void freeze(bool state); void freeze(bool state);
bool freeze_tgl() {freeze(flags.freeze^1); return flags.freeze;} bool freeze_tgl() {freeze(flags.freeze^1); return flags.freeze;}
bool freeze_get() {return flags.freeze;} bool freeze_get() {return flags.freeze;}
typedef enum
{
BYPASS_MODE_PASS, // pass the input signal to the output
BYPASS_MODE_OFF, // mute the output
BYPASS_MODE_TRAILS // mutes the input only
}bypass_mode_t;
void bypass_setMode(bypass_mode_t m) void bypass_setMode(bypass_mode_t m)
{ {
if (m <= BYPASS_MODE_TRAILS) if (m <= BYPASS_MODE_TRAILS)
@ -149,11 +144,12 @@ private:
unsigned cleanup_done: 1; unsigned cleanup_done: 1;
unsigned memsetup_done: 1; unsigned memsetup_done: 1;
unsigned mem_fail: 1; unsigned mem_fail: 1;
}flags = {0, 0, 0}; }flags;
bypass_mode_t bp_mode; bypass_mode_t bp_mode;
audio_block_f32_t *inputQueueArray_f32[2]; audio_block_f32_t *inputQueueArray_f32[2];
void NextRandomLineseg(ReverbScDl_t *lp, int n); void NextRandomLineseg(ReverbScDl_t *lp, int n);
void InitDelayLine(ReverbScDl_t *lp, int n); void InitDelayLine(ReverbScDl_t *lp, int n);
//void bypass_process();
float32_t feedback_, feedback_tmp; float32_t feedback_, feedback_tmp;
float32_t lpfreq_; float32_t lpfreq_;
float32_t i_pitch_mod_; float32_t i_pitch_mod_;

@ -92,6 +92,12 @@ void AudioEffectSpringReverb_F32::update()
uint32_t offset; uint32_t offset;
float lfo_fr; float lfo_fr;
if (!initialized) return; if (!initialized) return;
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!bypass_process(&blockL, &blockR, bp_mode, bp))
return;
if (bp) if (bp)
{ {
if (!cleanup_done && bp_mode != BYPASS_MODE_TRAILS) if (!cleanup_done && bp_mode != BYPASS_MODE_TRAILS)
@ -112,49 +118,17 @@ void AudioEffectSpringReverb_F32::update()
memset(&sp_chrp_alp4_buf[0], 0, SPRVB_CHIRP_AMNT*SPRVB_CHIRP4_LEN*sizeof(float)); memset(&sp_chrp_alp4_buf[0], 0, SPRVB_CHIRP_AMNT*SPRVB_CHIRP4_LEN*sizeof(float));
cleanup_done = true; cleanup_done = true;
} }
if (bp_mode != BYPASS_MODE_TRAILS)
switch(bp_mode)
{
case BYPASS_MODE_PASS:
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{ {
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
AudioStream_F32::transmit(blockL, 0); AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1); AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL); AudioStream_F32::release(blockL);
AudioStream_F32::release(blockR); AudioStream_F32::release(blockR);
return; return;
break;
case BYPASS_MODE_OFF:
blockL = AudioStream_F32::allocate_f32();
if (!blockL) return;
memset(&blockL->data[0], 0, blockL->length*sizeof(float32_t));
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockL, 1);
AudioStream_F32::release(blockL);
return;
break;
case BYPASS_MODE_TRAILS:
default:
break;
} }
} }
cleanup_done = false; cleanup_done = false;
blockL = AudioStream_F32::receiveWritable_f32(0);
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!blockL || !blockR)
{
if (blockL)
AudioStream_F32::release(blockL);
if (blockR)
AudioStream_F32::release(blockR);
return;
}
rv_time = rv_time_k; rv_time = rv_time_k;
for (i=0; i < blockL->length; i++) for (i=0; i < blockL->length; i++)
{ {

@ -121,12 +121,12 @@ public:
} }
float32_t get_size(void) {return rv_time_k;} float32_t get_size(void) {return rv_time_k;}
typedef enum // typedef enum
{ // {
BYPASS_MODE_PASS, // pass the input signal to the output // BYPASS_MODE_PASS, // pass the input signal to the output
BYPASS_MODE_OFF, // mute the output // BYPASS_MODE_OFF, // mute the output
BYPASS_MODE_TRAILS // mutes the input only // BYPASS_MODE_TRAILS // mutes the input only
}bypass_mode_t; // }bypass_mode_t;
void bypass_setMode(bypass_mode_t m) void bypass_setMode(bypass_mode_t m)
{ {
if (m <= BYPASS_MODE_TRAILS) bp_mode = m; if (m <= BYPASS_MODE_TRAILS) bp_mode = m;

@ -175,7 +175,7 @@ AudioFilterEqualizer_HX_F32::eq_result_t AudioFilterEqualizer_HX_F32::equalizerN
} }
// And fill in the members of fir_inst // And fill in the members of fir_inst
arm_fir_init_f32(&fir_inst, nFIR, (float32_t *)cf32f, &StateF32[0], (uint32_t)block_size); arm_fir_init_f32(&fir_inst, nFIR, (float32_t *)cf32f, &StateF32[0], (uint32_t)block_size);
return EQ_ERSULT_OK; return EQ_RESULT_OK;
} }
/* Calculate response in dB. Leave nFreq point result in array rdb[] supplied /* Calculate response in dB. Leave nFreq point result in array rdb[] supplied

@ -151,7 +151,7 @@ public:
bool bypass_tgl() {bp ^=1; return bp;} bool bypass_tgl() {bp ^=1; return bp;}
typedef enum typedef enum
{ {
EQ_ERSULT_OK = 0, EQ_RESULT_OK = 0,
EQ_RESULT_ERR_BANDS, EQ_RESULT_ERR_BANDS,
EQ_RESULT_ERR_SIDELOBES, EQ_RESULT_ERR_SIDELOBES,
EQ_RESULT_ERR_NFIR EQ_RESULT_ERR_NFIR

@ -21,7 +21,6 @@
* If not, see <https://www.gnu.org/licenses/>." * If not, see <https://www.gnu.org/licenses/>."
*/ */
#include "filter_ir_cabsim_F32.h" #include "filter_ir_cabsim_F32.h"
#include "HxFx_memcpy.h"
AudioFilterIRCabsim_F32::AudioFilterIRCabsim_F32() : AudioStream_F32(2, inputQueueArray_f32) AudioFilterIRCabsim_F32::AudioFilterIRCabsim_F32() : AudioStream_F32(2, inputQueueArray_f32)
{ {
@ -56,30 +55,6 @@ void AudioFilterIRCabsim_F32::update()
if (blockR) AudioStream_F32::release(blockR); if (blockR) AudioStream_F32::release(blockR);
return; return;
} }
#ifdef USE_IR_ISR_LOAD
switch(ir_loadState)
{
case IR_LOAD_START:
ptr_fmask = &fmask[0][0];
ptr_fftout = &fftout[0];
memset(ptr_fftout, 0, nfor*512*4); // clear fftout array
memset(fftin, 0, 512 * 4); // clear fftin array
ir_loadState = IR_LOAD_STEP1;
break;
case IR_LOAD_STEP1:
init_partitioned_filter_masks(irPtrTable[ir_idx]);
ir_loadState = IR_LOAD_STEP2;
break;
case IR_LOAD_STEP2:
delay.reset();
ir_loaded = 1;
ir_loadState = IR_LOAD_FINISHED;
break;
case IR_LOAD_FINISHED:
default: break;
}
#endif
if (!ir_loaded) // ir not loaded yet or bypass mode if (!ir_loaded) // ir not loaded yet or bypass mode
{ {
// bypass clean signal // bypass clean signal
@ -197,16 +172,6 @@ void AudioFilterIRCabsim_F32::ir_load(uint8_t idx)
{ {
return; return;
} }
#ifdef USE_IR_ISR_LOAD
nc = newIrPtr[0];
uint32_t _nfor = nc / IR_BUFFER_SIZE;
if (_nfor > nforMax) _nfor = nforMax;
__disable_irq()
nfor = _nfor;
ir_loadState = IR_LOAD_START;
__enable_irq();
ir_length_ms = (1000.0f * nfor * (float32_t)AUDIO_BLOCK_SAMPLES) / AUDIO_SAMPLE_RATE_EXACT;
#else
AudioNoInterrupts(); AudioNoInterrupts();
nc = newIrPtr[0]; nc = newIrPtr[0];
@ -222,11 +187,8 @@ void AudioFilterIRCabsim_F32::ir_load(uint8_t idx)
delay.reset(); delay.reset();
ir_loaded = 1; ir_loaded = 1;
ir_loadState = IR_LOAD_FINISHED;
AudioInterrupts(); AudioInterrupts();
#endif
} }

@ -32,6 +32,7 @@
#include "basic_allpass.h" #include "basic_allpass.h"
#include "basic_delay.h" #include "basic_delay.h"
#include "basic_shelvFilter.h" #include "basic_shelvFilter.h"
#include "basic_DSPutils.h"
#include <arm_const_structs.h> #include <arm_const_structs.h>
@ -42,8 +43,6 @@
#define IR_MAX_REG_NUM 11 // max number of registered IRs #define IR_MAX_REG_NUM 11 // max number of registered IRs
#define USE_IR_ISR_LOAD
class AudioFilterIRCabsim_F32 : public AudioStream_F32 class AudioFilterIRCabsim_F32 : public AudioStream_F32
{ {
public: public:
@ -160,16 +159,6 @@ private:
-0.0834295526f, -0.0470990688f, 0.0108086104f, 0.0319586769f, 0.0158470348f, -0.00560652791f, -0.0834295526f, -0.0470990688f, 0.0108086104f, 0.0319586769f, 0.0158470348f, -0.00560652791f,
-0.0112718018f, -0.00476867426f, 0.0013392308f, 0.00207542209f, 0.000503875781f, 0.0f }; -0.0112718018f, -0.00476867426f, 0.0013392308f, 0.00207542209f, 0.000503875781f, 0.0f };
typedef enum
{
IR_LOAD_START,
IR_LOAD_STEP1,
IR_LOAD_STEP2,
IR_LOAD_FINISHED
}ir_loadState_t;
ir_loadState_t ir_loadState = IR_LOAD_FINISHED;
}; };

@ -21,7 +21,7 @@
// table[0] is the data length, table[1] = audio gain // table[0] is the data length, table[1] = audio gain
const float32_t ir_1_guitar[3330] = PROGMEM const float32_t ir_1_guitar[3330] =
{ {
3328.0, 0.3f, 3328.0, 0.3f,
@ -443,7 +443,7 @@ const float32_t ir_1_guitar[3330] =
-0.001617, -0.000916, 0.000397, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 -0.001617, -0.000916, 0.000397, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_2_guitar[3842] = PROGMEM const float32_t ir_2_guitar[3842] =
{ {
3840.0, 0.3f, 3840.0, 0.3f,
0.059999, 0.260842, 0.583056, 0.878048, 0.988556, 0.853420, 0.490127, -0.019318, 0.059999, 0.260842, 0.583056, 0.878048, 0.988556, 0.853420, 0.490127, -0.019318,
@ -1413,7 +1413,7 @@ const float32_t ir_3_guitar[3842] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_4_guitar[6274] = PROGMEM const float32_t ir_4_guitar[6274] =
{ {
6272.0, 0.3f, 6272.0, 0.3f,
0.062410, 0.289254, 0.622059, 0.888211, 0.988556, 0.850551, 0.454848, -0.052858, 0.062410, 0.289254, 0.622059, 0.888211, 0.988556, 0.850551, 0.454848, -0.052858,
@ -2201,7 +2201,7 @@ const float32_t ir_4_guitar[6274] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_5_guitar[3458] = PROGMEM const float32_t ir_5_guitar[3458] =
{ {
3456.0, 0.3f, 3456.0, 0.3f,
0.033631, 0.177648, 0.447432, 0.748100, 0.961760, 0.988556, 0.769982, 0.345714, 0.033631, 0.177648, 0.447432, 0.748100, 0.961760, 0.988556, 0.769982, 0.345714,
@ -2638,7 +2638,7 @@ const float32_t ir_5_guitar[3458] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_6_guitar[3842] = PROGMEM const float32_t ir_6_guitar[3842] =
{ {
3840.0, 0.3f, 3840.0, 0.3f,
0.067476, 0.307443, 0.670705, 0.946989, 0.988556, 0.790246, 0.417615, -0.026582, 0.067476, 0.307443, 0.670705, 0.946989, 0.988556, 0.790246, 0.417615, -0.026582,
@ -3121,7 +3121,7 @@ const float32_t ir_6_guitar[3842] =
-0.000977, -0.000336, 0.000031, 0.000244, -0.000061, -0.000305, -0.000549, -0.000397 -0.000977, -0.000336, 0.000031, 0.000244, -0.000061, -0.000305, -0.000549, -0.000397
}; };
const float32_t ir_7_bass[6274] = PROGMEM const float32_t ir_7_bass[6274] =
{ {
6272.0, 0.2f, 6272.0, 0.2f,
0.276818, 0.778804, 0.988553, 0.785373, 0.531643, 0.437141, 0.405113, 0.371809, 0.276818, 0.778804, 0.988553, 0.785373, 0.531643, 0.437141, 0.405113, 0.371809,
@ -3910,7 +3910,7 @@ const float32_t ir_7_bass[6274] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_8_bass[2946] = PROGMEM const float32_t ir_8_bass[2946] =
{ {
2944.0, 0.3, 2944.0, 0.3,
@ -4284,7 +4284,7 @@ const float32_t ir_8_bass[2946] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_9_bass[6402] = PROGMEM const float32_t ir_9_bass[6402] =
{ {
6400.0, 0.3, 6400.0, 0.3,
@ -5092,7 +5092,7 @@ const float32_t ir_9_bass[6402] =
}; };
const float32_t ir_10_guitar[1410] = PROGMEM const float32_t ir_10_guitar[1410] =
{ {
1408.0, 0.3f, 1408.0, 0.3f,
@ -5274,7 +5274,7 @@ const float32_t ir_10_guitar[1410] =
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
}; };
const float32_t ir_11_guitar[1666] = PROGMEM const float32_t ir_11_guitar[1666] =
{ {
1664.0, 0.3f, 1664.0, 0.3f,

Loading…
Cancel
Save