Skip to content

Commit

Permalink
- fix multichannel issue introduced with previous commits
Browse files Browse the repository at this point in the history
- added HISE_BACKEND_AS_FX flag to simulate FX processing in HISE
  • Loading branch information
Christoph Hart committed Jan 14, 2023
1 parent 088e363 commit d151991
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
8 changes: 7 additions & 1 deletion hi_backend/backend/BackendEditor.cpp
Expand Up @@ -466,8 +466,12 @@ void MainTopBar::paint(Graphics& g)

String infoText;

#if HISE_BACKEND_AS_FX
infoText << "FX Build";
#endif

#if JUCE_DEBUG
infoText << "DEBUG Build";
infoText << " (DEBUG)";
#endif

#if HISE_INCLUDE_FAUST
Expand All @@ -479,6 +483,8 @@ void MainTopBar::paint(Graphics& g)
infoText << "Faust enabled";
#endif



g.setFont(GLOBAL_BOLD_FONT());
g.setColour(Colours::white.withAlpha(0.2f));
g.drawText(infoText, b.toFloat(), Justification::right);
Expand Down
2 changes: 2 additions & 0 deletions hi_backend/backend/BackendProcessor.cpp
Expand Up @@ -196,7 +196,9 @@ void BackendProcessor::refreshExpansionType()

void BackendProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
#if !HISE_BACKEND_AS_FX
buffer.clear();
#endif

auto processChunk = [this](float** channels, AudioSampleBuffer& original, MidiBuffer& mb, int offset, int numThisTime)
{
Expand Down
12 changes: 12 additions & 0 deletions hi_core/hi_core.h
Expand Up @@ -131,6 +131,14 @@ Set this to 1 to disable the creation of the Expansions folder at init (i.e. for
#define DONT_CREATE_EXPANSIONS_FOLDER 0
#endif

/** Config: HISE_BACKEND_AS_FX
Set this to 1 in order to use HISE as a effect plugin. This will simulate the processing setup of an FX plugin (so child sound generators will not be processed etc).
*/
#ifndef HISE_BACKEND_AS_FX
#define HISE_BACKEND_AS_FX 1
#endif

/** Config: USE_COPY_PROTECTION
If true, then the copy protection will be used
Expand Down Expand Up @@ -174,8 +182,12 @@ Use the Intel Performance Primitives Library for the convolution reverb.
If set to 1, the compiled plugin will be a effect (stereo in / out).
*/
#ifndef FRONTEND_IS_PLUGIN
#if USE_BACKEND
#define FRONTEND_IS_PLUGIN HISE_BACKEND_AS_FX
#else
#define FRONTEND_IS_PLUGIN 0
#endif
#endif


/** Config: PROCESS_SOUND_GENERATORS_IN_FX_PLUGIN
Expand Down
11 changes: 9 additions & 2 deletions hi_core/hi_core/MainController.cpp
Expand Up @@ -575,7 +575,7 @@ void MainController::processMidiOutBuffer(MidiBuffer& mb, int numSamples)

bool MainController::shouldUseSoftBypassRamps() const noexcept
{
#if USE_BACKEND || !FRONTEND_IS_PLUGIN
#if (USE_BACKEND && !HISE_BACKEND_AS_FX) || !FRONTEND_IS_PLUGIN
return true;
#else
return allowSoftBypassRamps;
Expand Down Expand Up @@ -1092,7 +1092,14 @@ void MainController::processBlockCommon(AudioSampleBuffer &buffer, MidiBuffer &m
#if FORCE_INPUT_CHANNELS
jassert(thisMultiChannelBuffer.getNumSamples() >= buffer.getNumSamples());
jassert(thisMultiChannelBuffer.getNumChannels() >= buffer.getNumChannels());
thisMultiChannelBuffer.makeCopyOf(buffer, true);

for(int i = 0; i < buffer.getNumChannels(); i++)
{
FloatVectorOperations::copy(thisMultiChannelBuffer.getWritePointer(i),
buffer.getReadPointer(i), buffer.getNumSamples());
}


#else
thisMultiChannelBuffer.clear();
#endif
Expand Down
17 changes: 13 additions & 4 deletions hi_dsp/modules/ModulatorSynthChain.cpp
Expand Up @@ -194,7 +194,9 @@ void ModulatorSynthChain::renderNextBlockWithModulators(AudioSampleBuffer &buffe

ADD_GLITCH_DETECTOR(this, DebugLogger::Location::SynthChainRendering);

if (getMainController()->getMainSynthChain() == this && !activeChannels.areAllChannelsEnabled())
auto isRoot = getMainController()->getMainSynthChain() == this;

if (isRoot && !activeChannels.areAllChannelsEnabled())
{
HiseEventBuffer::Iterator it(inputMidiBuffer);

Expand Down Expand Up @@ -249,8 +251,15 @@ void ModulatorSynthChain::renderNextBlockWithModulators(AudioSampleBuffer &buffe
internalBuffer.setSize(getMatrix().getNumSourceChannels(), numSamples, true, false, true);

#if FORCE_INPUT_CHANNELS
if(internalBuffer.getNumChannels() == buffer.getNumChannels())
internalBuffer.makeCopyOf(buffer);
if(isRoot)
{
for(int i = 0; i < buffer.getNumChannels(); i++)
{
FloatVectorOperations::copy(internalBuffer.getWritePointer(i),
buffer.getReadPointer(i), numSamples);
}
}

#endif

// Process the Synths and add store their output in the internal buffer
Expand Down Expand Up @@ -297,7 +306,7 @@ void ModulatorSynthChain::renderNextBlockWithModulators(AudioSampleBuffer &buffe
}
else // save some cycles on non multichannel buffers...
{
#if FORCE_INPUT_CHANNELS
#if !FORCE_INPUT_CHANNELS
FloatVectorOperations::copyWithMultiply(buffer.getWritePointer(0, 0), internalBuffer.getReadPointer(0, 0), getGain() * getBalance(false), numSamples);
FloatVectorOperations::copyWithMultiply(buffer.getWritePointer(1, 0), internalBuffer.getReadPointer(1, 0), getGain() * getBalance(true), numSamples);
#else
Expand Down

0 comments on commit d151991

Please sign in to comment.