tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_VolumeAndPan.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
18{
19public:
20 VolumeAndPanPlugin (Edit&, const juce::ValueTree&, bool isMasterVolumeNode);
21 VolumeAndPanPlugin (PluginCreationInfo, bool isMasterVolumeNode = false);
22 ~VolumeAndPanPlugin() override;
23
25
26 static const char* getPluginName() { return NEEDS_TRANS("Volume and Pan"); }
27 static juce::ValueTree create();
28
29 bool isMasterVolAndPan() { return isMasterVolume; }
30 bool canBeAddedToRack() override { return ! isMasterVolume; }
31
32 //==============================================================================
33 float getVolumeDb() const;
34 float getSliderPos() const { return volParam->getCurrentValue(); }
35 void setVolumeDb (float vol);
36 void setSliderPos (float pos);
37
38 float getPan() const { return panParam->getCurrentValue(); }
39 void setPan (float pan);
40
41 void setPanLaw (PanLaw newPanLaw) { panLaw = (int) newPanLaw; }
42 PanLaw getPanLaw() const noexcept;
43
44 void setAppliedToMidiVolumes (bool);
45 bool isAppliedToMidiVolumes() const { return applyToMidi; }
46
47 void muteOrUnmute();
48
49 bool shoulMeasureCpuUsage() const noexcept final { return false; }
50
51 //==============================================================================
52 static const char* xmlTypeName;
53
54 juce::String getName() const override { return TRANS("Volume & Pan Plugin"); }
55 juce::String getPluginType() override { return xmlTypeName; }
56 juce::String getShortName (int) override { return "VolPan"; }
58 bool needsConstantBufferSize() override { return false; }
59
60 void initialise (const PluginInitialisationInfo&) override;
62 void deinitialise() override;
63 void applyToBuffer (const PluginRenderContext&) override;
64 int getNumOutputChannelsGivenInputs (int numInputs) override { return juce::jmax (2, numInputs); }
65 bool canBeMoved() override { return ! isMasterVolume; }
66
67 void restorePluginStateFromValueTree (const juce::ValueTree&) override;
68
69 //==============================================================================
70 juce::CachedValue<float> volume, pan;
71 juce::CachedValue<bool> applyToMidi, ignoreVca, polarity;
73
74 // NB the units used here are slider position
75 AutomatableParameter::Ptr volParam, panParam;
76
77private:
78 float lastGainL = 0.0f, lastGainR = 0.0f, lastGainS = 0.0f, lastVolumeBeforeMute = 0.0f;
79
80 RealTimeSpinLock vcaTrackLock;
82 const bool isMasterVolume = false;
83
84 void refreshVCATrack();
85
87};
88
89}} // namespace tracktion { inline namespace engine
The Tracktion Edit class!
The built-in Tracktion volume/pan plugin.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
void deinitialise() override
Called after play stops to release resources.
int getNumOutputChannelsGivenInputs(int numInputs) override
This must return the number of output channels that the plugin will produce, given a number of input ...
bool shoulMeasureCpuUsage() const noexcept final
Plugins can return false if they want to avoid the overhead of measuring the CPU usage.
juce::String getName() const override
The name of the type, e.g.
void initialiseWithoutStopping(const PluginInitialisationInfo &) override
Tells the plugin that the audio graph has changed but the plugin isn't being re-initialised - i....
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
A basic spin lock that uses an atomic_flag to store the locked state so should never result in a syst...
#define TRANS(stringLiteral)
#define NEEDS_TRANS(stringLiteral)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
typedef int
constexpr Type jmax(Type a, Type b)
PanLaw
All laws have been designed to be equal-power, excluding linear respectively.
Passed into Plugins when they are being initialised, to give them useful contextual information that ...
The context passed to plugin render methods to provide it with buffers to fill.