Skip to content

Commit ebcbf85

Browse files
committed
fix(zlp::controller): update window and resize working space
1 parent 2ea848b commit ebcbf85

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

source/PluginProcessor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void PluginProcessor::processBlockInternal(juce::AudioBuffer<float>& buffer, con
205205
if (buffer.getNumSamples() == 0) {
206206
return; // ignore empty blocks
207207
}
208+
controller_.prepareBuffer();
208209
const auto ext_side = controller_.getExtSide();
209210
const auto num_samples = static_cast<size_t>(buffer.getNumSamples());
210211
switch (channel_layout_) {

source/zlp/controller.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ namespace zlp {
531531

532532
void Controller::resizeWorkingSpace() {
533533
fft_size_ = static_cast<size_t>(1) << fft_order_;
534+
fft_hop_size_ = fft_size_ / 4;
534535
num_bin_ = fft_size_ / 2 + 1;
535536
num_bin_effective_ = fft_size_ / 2;
536537
ws_.resize(num_bin_effective_);
@@ -539,6 +540,33 @@ namespace zlp {
539540
window2_.resize(fft_size_);
540541
window_bypass_.resize(fft_size_);
541542

543+
zldsp::fft::createPeriodicHanning(std::span{window1_.data(), window1_.size()}, 2.f / static_cast<float>(fft_size_));
544+
const auto v_window2_scale = hn::Set(d, static_cast<float>(fft_size_) / 3.f);
545+
const auto v_bypass_scale = hn::Set(d, 4.f / 3.f);
546+
for (size_t i = 0; i < fft_size_; i += lanes) {
547+
const auto v_window1 = hn::Load(d, window1_.data() + i);
548+
const auto v_window2 = hn::Mul(v_window1, v_window2_scale);
549+
hn::Store(v_window2, d, window2_.data() + i);
550+
const auto v_window_bypass = hn::Mul(hn::Mul(v_window1, v_window1), v_bypass_scale);
551+
hn::Store(v_window_bypass, d, window_bypass_.data() + i);
552+
}
553+
554+
for (auto& fifo : input_fifos_) {
555+
fifo.resize(fft_size_);
556+
}
557+
for (auto& fifo : output_fifos_) {
558+
fifo.resize(fft_size_);
559+
}
560+
for (auto& fifo : fft_ins_) {
561+
fifo.resize(fft_size_);
562+
}
563+
for (auto& fifo : fft_out_reals_) {
564+
fifo.resize(num_bin_);
565+
}
566+
for (auto& fifo : fft_out_imags_) {
567+
fifo.resize(num_bin_);
568+
}
569+
542570
for (auto& response : spec_response_) {
543571
response.prepare(fft_size_);
544572
}

0 commit comments

Comments
 (0)