-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "Convolver.h" | ||
|
||
zones::Convolver::Convolver (juce::dsp::AudioBlock<const float> ir_block, | ||
const juce::dsp::ProcessSpec & process_spec, | ||
const zones::Convolver::ConvolverSpec & convolver_spec) | ||
: process_spec_ (process_spec) | ||
, convolver_spec_ (convolver_spec) | ||
{ | ||
num_convolution_channels_ = ir_block.getNumChannels (); | ||
auto max_block_size = process_spec_.maximumBlockSize; | ||
auto sample_rate = process_spec_.sampleRate; | ||
|
||
routing_buffer_.setSize (num_convolution_channels_, max_block_size); | ||
|
||
time_distributed_nupc_ = std::make_unique<TimeDistributedNUPC> ( | ||
ir_block, | ||
juce::dsp::ProcessSpec { | ||
.sampleRate = sample_rate, | ||
.maximumBlockSize = max_block_size, | ||
.numChannels = static_cast<uint> (num_convolution_channels_), | ||
}); | ||
} | ||
|
||
void zones::Convolver::Process (const juce::dsp::ProcessContextReplacing<float> & replacing) | ||
{ | ||
auto output_block = replacing.getOutputBlock (); | ||
|
||
juce::dsp::AudioBlock<float> routing_block {routing_buffer_}; | ||
routing_block.clear (); | ||
|
||
for (auto convolution_channel = 0; convolution_channel < num_convolution_channels_; | ||
++convolution_channel) | ||
{ | ||
auto input_routing_channel = convolver_spec_.input_routing [convolution_channel]; | ||
auto input_routing_block = output_block.getSingleChannelBlock (input_routing_channel); | ||
routing_block.getSingleChannelBlock (convolution_channel).copyFrom (input_routing_block); | ||
} | ||
|
||
time_distributed_nupc_->Process ( | ||
{routing_block}); // THIS NEEDS TO HANDLE SMALLER AND LARGER BLOCKS... | ||
|
||
output_block.clear (); | ||
for (auto convolution_channel = 0; convolution_channel < num_convolution_channels_; | ||
++convolution_channel) | ||
{ | ||
auto output_routing_channel = convolver_spec_.output_routing [convolution_channel]; | ||
auto output_routing_block = output_block.getSingleChannelBlock (output_routing_channel); | ||
output_routing_block.add (routing_block.getSingleChannelBlock (convolution_channel)); | ||
} | ||
} | ||
|
||
void zones::Convolver::Reset () | ||
{ | ||
time_distributed_nupc_->Reset (); | ||
routing_buffer_.clear (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "time_distributed/TimeDistributedNUPC.h" | ||
|
||
namespace zones | ||
{ | ||
class Convolver | ||
{ | ||
public: | ||
struct ConvolverSpec | ||
{ | ||
std::vector<int> input_routing; | ||
std::vector<int> output_routing; | ||
}; | ||
|
||
Convolver (juce::dsp::AudioBlock<const float> ir_block, | ||
const juce::dsp::ProcessSpec & process_spec, | ||
const ConvolverSpec & convolver_spec); | ||
void Process (const juce::dsp::ProcessContextReplacing<float> & replacing); | ||
void Reset (); | ||
|
||
private: | ||
juce::AudioBuffer<float> routing_buffer_; | ||
std::unique_ptr<TimeDistributedNUPC> time_distributed_nupc_; | ||
|
||
juce::dsp::ProcessSpec process_spec_; | ||
ConvolverSpec convolver_spec_; | ||
int num_convolution_channels_; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters