Skip to content

Commit

Permalink
Code update
Browse files Browse the repository at this point in the history
  • Loading branch information
sadko4u committed Aug 19, 2023
1 parent e73218b commit 085909b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions include/lsp-plug.in/dsp-units/util/FFTCrossover.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ namespace lsp
*/
void process(const float *in, size_t samples);

/**
* Clear internal memory
*/
inline void clear() { sSplitter.clear(); }

/**
* Dump the state
* @param dumper dumper
Expand Down
5 changes: 5 additions & 0 deletions include/lsp-plug.in/dsp-units/util/SpectralSplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ namespace lsp
*/
void process(const float *src, size_t count);

/**
* Clear internal memory and buffers
*/
void clear();

/**
* Dump the state
* @param dumper dumper
Expand Down
19 changes: 12 additions & 7 deletions src/main/util/SpectralSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,22 @@ namespace lsp
nRank = lsp_min(nRank, nMaxRank);
nChunkRank = (nUserChunkRank > 0) ? lsp_limit(nUserChunkRank, 5, ssize_t(nRank)) : nRank;

size_t buf_size = 1 << nRank;
size_t frame_size = 1 << (nChunkRank - 1);

// Clear buffers and reset pointers
windows::sqr_cosine(vWnd, frame_size * 2);
clear();

nFrameSize = frame_size * (fPhase * 0.5f);
nInOffset = 0;

// Mark settings applied
bUpdate = false;
}

void SpectralSplitter::clear()
{
size_t buf_size = 1 << nRank;
dsp::fill_zero(vInBuf, buf_size * BUFFER_MULTIPLIER);
dsp::fill_zero(vFftBuf, buf_size*2);

Expand All @@ -247,12 +258,6 @@ namespace lsp
if (h->pSink != NULL)
dsp::fill_zero(h->vOutBuf, buf_size * BUFFER_MULTIPLIER);
}

nFrameSize = frame_size * (fPhase * 0.5f);
nInOffset = 0;

// Mark settings applied
bUpdate = false;
}

void SpectralSplitter::set_phase(float phase)
Expand Down

0 comments on commit 085909b

Please sign in to comment.