forked from AndrewJJ/DSP-Testbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaustProcessor.cpp
58 lines (51 loc) · 1.58 KB
/
FaustProcessor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
==============================================================================
FaustProcessor.cpp
Created: 22 Sep 2024 7:50:32pm
Author: Stephane Letz
==============================================================================
*/
#include "FaustProcessor.h"
FaustExample::FaustExample()
: ProcessorHarness (FAUST_ACTIVES)
{
fDSP = std::make_unique<mydsp>();
fDSP->buildUserInterface(&fUI);
}
void FaustExample::prepare (const juce::dsp::ProcessSpec& spec)
{
fDSP->init(spec.sampleRate);
}
void FaustExample::process (const juce::dsp::ProcessContextReplacing<float>& context)
{
// Update controllers
for (int ctrl = 0; ctrl < fUI.getParamsCount(); ctrl++) {
fUI.setParamRatio(ctrl, getControlValue(ctrl));
}
FAUSTFLOAT* inputs[fDSP->getNumInputs()];
for (int chan = 0; chan < fDSP->getNumInputs(); chan++) {
inputs[chan] = (FAUSTFLOAT*)context.getInputBlock().getChannelPointer(chan);
}
FAUSTFLOAT* outputs[fDSP->getNumOutputs()];
for (int chan = 0; chan < fDSP->getNumOutputs(); chan++) {
outputs[chan] = context.getOutputBlock().getChannelPointer(chan);
}
// Compute samples
fDSP->compute(context.getOutputBlock().getNumSamples(), inputs, outputs);
}
void FaustExample::reset()
{
fDSP->init(fDSP->getSampleRate());
}
String FaustExample::getProcessorName()
{
return String ("Faust");
}
String FaustExample::getControlName (const int index)
{
return fUI.getParamAddress(index);
}
double FaustExample::getDefaultControlValue (const int index)
{
return fUI.getParamInit(index);
}