Skip to content

Commit

Permalink
Fix poly handling for EXT PM
Browse files Browse the repository at this point in the history
  • Loading branch information
ndonald2 committed Oct 16, 2022
1 parent 2b4333c commit 1b0b2a8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/WarpCore/WarpCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ struct WarpCore : Module {
void process(const ProcessArgs& args) override {

const int numChannels = std::max(inputs[PITCH_CV_INPUT].getChannels(), 1);
const int numExtInChannels = std::max(inputs[EXT_PM_INPUT].getChannels(), 1);

if (needsSampleRateUpdate) {
if (needsSampleRateUpdate || (numChannels != numOutputChannels)) {
for (int c = 0; c < kMaxChannels; c++) {
osc[c].SetSampleRate(srConfig.sampleRate * srConfig.oversampling);
extPMBuffers[c].clear();
}
outputBuffer.clear();
numOutputChannels = numChannels;
needsSampleRateUpdate = false;
}

Expand All @@ -149,10 +151,14 @@ struct WarpCore : Module {
const int ovsBlockSize = kBlockSize * oversampling;

// Accumulate ext PM input (needs to be processed at audio rate despite buffering)
for (int c = 0; c < numChannels; c++) {
float extpm = inputs[EXT_PM_INPUT].getPolyVoltage(c);
for (int i = 0; i < oversampling; i++) {
extPMBuffers[c].push(extpm);
for (int c = 0; c < kMaxChannels; c++) {
if (c < numChannels) {
// EXT PM may not have the same channel count as the input, in which case
// the fallback is to round-robin assign EXT PM channels to voices
float extpm = inputs[EXT_PM_INPUT].getPolyVoltage(c % numExtInChannels);
for (int i = 0; i < oversampling; i++) {
extPMBuffers[c].push(extpm);
}
}
}

Expand Down Expand Up @@ -322,6 +328,7 @@ struct WarpCore : Module {

infrasonic::PhaseDistortionOscillator::Patch patch;
infrasonic::PhaseDistortionOscillator osc[kMaxChannels];
int numOutputChannels = 1;

dsp::BooleanTrigger algo1Trigger, algo2Trigger;
dsp::SampleRateConverter<kMaxChannels * 2> outputSrc;
Expand Down

0 comments on commit 1b0b2a8

Please sign in to comment.