I tried using your suggested syntax for a static function in PluginProcessor, which I also need to access in my SynthVoice, but I am getting some strange errors. FYI the function is a distortion which I would like to be able to apply either on a unison or voice level within SynthVoice, or in PluginProcessor on a Tone Generator (all voices) or Global level (all tone generators). My code looks this, first PluginProcessor.h (Note I do not use SynthSound at all);
#include "../JuceLibraryCode/JuceHeader.h"
//#include "SynthSound.h"
#include "SynthVoice.h"
//==============================================================================
/**
*/
class MutineerAudioProcessor : public AudioProcessor
{
public:
//==============================================================================
MutineerAudioProcessor();
~MutineerAudioProcessor();
// All the normal processor functions
static void distortion ();
Then in PluginProcessor.cpp I got;
#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "Common.h"
#include "WaveTables.h"
//==============================================================================
MutineerAudioProcessor::MutineerAudioProcessor ()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties ()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo (), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo (), true)
#endif
)
#endif
{
// Initializing stuff
}
MutineerAudioProcessor::~MutineerAudioProcessor ()
{
mutineer.clearSounds ();
mutineer.clearVoices ();
}
void MutineerAudioProcessor::distortion ()
{
// To do
}
Then in SynthVoice.h I got;
#include "../JuceLibraryCode/JuceHeader.h"
#include "SynthSound.h"
#include "gbEditorVoice.h"
#include "WaveTables.h"
#include "PluginProcessor.h"
class SynthVoice : public SynthesiserVoice {
public:
SynthVoice ()
{
// Initializing variables
}
void renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples)
{
// Usual suspects here
// Just calling to check if I can
MutineerAudioProcessor::distortion ();
// Usual suspects here
}
VS 2019 editor shows no errors, until I try to compile, and then I get;
Build started…
1>------ Build started: Project: Mutineer_SharedCode, Configuration: Debug x64 ------
1>RandomToneGenerator.cpp
1>CloneToneGenerator.cpp
1>StripEffects.cpp
1>StripToneGenerators.cpp
1>PluginProcessor.cpp
1>PluginEditor.cpp
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\PluginProcessor.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\StripToneGenerators.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\RandomToneGenerator.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\CloneToneGenerator.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\StripToneGenerators.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\CloneToneGenerator.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\RandomToneGenerator.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\PluginProcessor.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\StripEffects.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\StripEffects.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,3): error C2653: ‘MutineerAudioProcessor’: is not a class or namespace name (compiling source file …\Source\PluginEditor.cpp)
1>C:\JUCE\Mutineer\Source\SynthVoice.h(83,27): error C3861: ‘distortion’: identifier not found (compiling source file …\Source\PluginEditor.cpp)
1>Done building project “Mutineer_SharedCode.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
So obviously I am doing something wrong somewhere. If I can’t solve it by having the shared function in PluginProcessor, I guess I could create a new pair of class (h and cpp) file, which I can then include in PluginProcessor and SynthVoice.