Skip to content

Commit

Permalink
Refactor: move plug-in rendering functions to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed May 19, 2024
1 parent 291e30f commit 9f0bd9f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ list(APPEND SOURCES
src/core/rendering/midiReactions.cpp
src/core/rendering/midiAdvance.cpp
src/core/rendering/midiOutput.cpp
src/core/rendering/midiRendering.cpp
src/core/rendering/pluginRendering.cpp
src/core/api/mainApi.cpp
src/core/api/channelsApi.cpp
src/core/api/sampleEditorApi.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* -------------------------------------------------------------------------- */

#include "core/rendering/midiRendering.h"
#include "core/rendering/pluginRendering.h"
#include "core/channels/channel.h"
#include "core/plugins/pluginHost.h"

Expand Down Expand Up @@ -58,9 +58,16 @@ const juce::MidiBuffer& prepareMidiBuffer_(ChannelShared& shared)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

void renderMidiChannelPlugins(const Channel& ch, PluginHost& pluginHost)
void renderAudioAndMidiPlugins(const Channel& ch, PluginHost& pluginHost)
{
pluginHost.processStack(ch.shared->audioBuffer, ch.plugins, &prepareMidiBuffer_(*ch.shared));
ch.shared->midiBuffer.clear();
}

/* -------------------------------------------------------------------------- */

void renderAudioPlugins(const Channel& ch, PluginHost& pluginHost)
{
pluginHost.processStack(ch.shared->audioBuffer, ch.plugins, nullptr);
}
} // namespace giada::m::rendering
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*
* -------------------------------------------------------------------------- */

#ifndef G_RENDERING_MIDI_RENDERING_H
#define G_RENDERING_MIDI_RENDERING_H
#ifndef G_RENDERING_PLUGIN_RENDERING_H
#define G_RENDERING_PLUGIN_RENDERING_H

#include "core/channels/channelShared.h"

Expand All @@ -36,7 +36,16 @@ class PluginHost;

namespace giada::m::rendering
{
void renderMidiChannelPlugins(const Channel&, PluginHost&);
/* renderAudioAndMidiPlugins
Renders plug-ins using the shared juce::MidiBuffer for MIDI event rendering. It
renders normal audio plug-ins too. */

void renderAudioAndMidiPlugins(const Channel&, PluginHost&);

/* renderAudioPlugins
Renders audio-only plug-ins. */

void renderAudioPlugins(const Channel&, PluginHost&);
} // namespace giada::m::rendering

#endif
6 changes: 3 additions & 3 deletions src/core/rendering/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "core/rendering/midiAdvance.h"
#include "core/rendering/midiOutput.h"
#include "core/rendering/midiReactions.h"
#include "core/rendering/midiRendering.h"
#include "core/rendering/pluginRendering.h"
#include "core/rendering/sampleAdvance.h"
#include "core/rendering/sampleRendering.h"
#ifdef WITH_AUDIO_JACK
Expand Down Expand Up @@ -245,7 +245,7 @@ void Renderer::renderSampleChannel(const Channel& ch, const mcl::AudioBuffer& in
if (ch.canReceiveAudio())
rendering::renderSampleChannelInput(ch, in); // record "clean" audio first (i.e. not plugin-processed)

rendering::renderSampleChannelPlugins(ch, m_pluginHost);
rendering::renderAudioPlugins(ch, m_pluginHost);
}

/* -------------------------------------------------------------------------- */
Expand All @@ -254,6 +254,6 @@ void Renderer::renderMidiChannel(const Channel& ch) const
{
assert(ch.type == ChannelType::MIDI);

rendering::renderMidiChannelPlugins(ch, m_pluginHost);
rendering::renderAudioAndMidiPlugins(ch, m_pluginHost);
}
} // namespace giada::m::rendering
7 changes: 0 additions & 7 deletions src/core/rendering/sampleRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,6 @@ void renderSampleChannel(const Channel& ch, bool seqIsRunning)

/* -------------------------------------------------------------------------- */

void renderSampleChannelPlugins(const Channel& ch, PluginHost& pluginHost)
{
pluginHost.processStack(ch.shared->audioBuffer, ch.plugins, nullptr);
}

/* -------------------------------------------------------------------------- */

void renderSampleChannelInput(const Channel& ch, const mcl::AudioBuffer& in)
{
ch.shared->audioBuffer.set(in, /*gain=*/1.0f); // add, don't overwrite
Expand Down
1 change: 0 additions & 1 deletion src/core/rendering/sampleRendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ struct ReadResult
};

void renderSampleChannel(const Channel&, bool seqIsRunning);
void renderSampleChannelPlugins(const Channel&, PluginHost&);

/* renderSampleChannelInput
Copies input buffer to channel buffer: this enables the input monitoring. */
Expand Down

0 comments on commit 9f0bd9f

Please sign in to comment.