Skip to content

Commit

Permalink
ZamNoise: Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
zamaudio committed Apr 27, 2024
1 parent 410d600 commit f087f9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion plugins/ZamNoise/Denoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ Denoise::~Denoise() {
FFTW(destroy_plan)(pForNoise);
FFTW(destroy_plan)(pBak);
FFTW(destroy_plan)(pFor);
FFTW(cleanup)();
}

void Denoise::get_noise_sample(float* noisebuffer, fftw_real *noise_min, fftw_real *noise_max)
Expand Down
10 changes: 8 additions & 2 deletions plugins/ZamNoise/ZamNoisePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ZamNoisePlugin::ZamNoisePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
buffer.cbsize = 0;
buffer.cbsizeold = 0;
zamnoise = new Denoise(getSampleRate());
ZamNoisePlugin::init();

Expand All @@ -40,6 +41,7 @@ ZamNoisePlugin::~ZamNoisePlugin()
buffer.cbsize = 0;
delete zamnoise;
free(buffer.cbi);
FFTW(cleanup)();
}

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -129,8 +131,9 @@ void ZamNoisePlugin::loadProgram(uint32_t index)


void ZamNoisePlugin::InstantiateCircularBuffer(CircularBuffer* buf) {
buf->cbi = (float*) calloc(DENOISE_MAX_FFT, sizeof(float));
buf->cbsize = DENOISE_MAX_FFT;
buf->cbsizeold = DENOISE_MAX_FFT;
buf->cbi = (float*) calloc(buf->cbsizeold, sizeof(float));
buf->cbsize = buf->cbsizeold;
}

void ZamNoisePlugin::init (void)
Expand All @@ -144,10 +147,13 @@ void ZamNoisePlugin::init (void)

void ZamNoisePlugin::activate()
{
if (buffer.cbsizeold > 0)
buffer.cbsize = buffer.cbsizeold;
}

void ZamNoisePlugin::deactivate()
{
buffer.cbsize = 0;
}

void ZamNoisePlugin::run(const float** inputs, float** outputs, uint32_t frames)
Expand Down
1 change: 1 addition & 0 deletions plugins/ZamNoise/ZamNoisePlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

typedef struct {
unsigned long cbsize; // size of circular buffer
unsigned long cbsizeold; // old size of circular buffer
float* cbi;
} CircularBuffer;

Expand Down

0 comments on commit f087f9f

Please sign in to comment.