Audacity 3.2.0
CompressorInstance.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 CompressorInstance.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "CompressorProcessor.h"
15#include "EffectInterface.h"
16#include "Observer.h"
17#include "PerTrackEffect.h"
18#include <memory>
19#include <optional>
20#include <vector>
21
25
26class BUILTIN_EFFECTS_API CompressorInstance final :
31{
32public:
33 explicit CompressorInstance(const PerTrackEffect& effect);
34 explicit CompressorInstance(CompressorInstance&& other);
35
36 const std::optional<double>& GetSampleRate() const;
37 float GetLatencyMs() const;
38 void SetOutputQueue(std::weak_ptr<DynamicRangeProcessorOutputPacketQueue>);
39 void SetMeterValuesQueue(
40 std::weak_ptr<DynamicRangeProcessorMeterValuesQueue> queue);
41
42private:
45 ChannelNames chanMap) override;
46
47 bool ProcessFinalize() noexcept override;
48
49 size_t ProcessBlock(
50 EffectSettings& settings, const float* const* inBlock,
51 float* const* outBlock, size_t blockLen) override;
52
53 bool
55
56 bool RealtimeResume() override;
57
59 EffectSettings& settings, EffectOutputs* pOutputs, unsigned numChannels,
60 float sampleRate) override;
61
62 bool RealtimeFinalize(EffectSettings& settings) noexcept override;
63
64 size_t RealtimeProcess(
65 size_t group, EffectSettings& settings, const float* const* inbuf,
66 float* const* outbuf, size_t numSamples) override;
67
69 size_t group, EffectSettings& settings, const float* const* inbuf,
70 size_t numSamples) override;
71
72 void InstanceInit(
73 EffectSettings& settings, CompressorInstance& instance, int numChannels,
74 float sampleRate);
75
76 size_t InstanceProcess(
78 const float* const* inBlock, float* const* outBlock, size_t blockLen);
79
81 GetLatency(const EffectSettings& settings, double sampleRate) const override;
82
83 unsigned GetAudioInCount() const override;
84 unsigned GetAudioOutCount() const override;
85
86 std::unique_ptr<CompressorProcessor> mCompressor;
87 std::vector<CompressorInstance> mSlaves;
88 long long mSampleCounter = 0;
89 std::optional<double> mSampleRate;
90 std::weak_ptr<DynamicRangeProcessorOutputPacketQueue> mOutputQueue;
91 std::weak_ptr<DynamicRangeProcessorMeterValuesQueue> mCompressionValueQueue;
92};
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
std::weak_ptr< DynamicRangeProcessorMeterValuesQueue > mCompressionValueQueue
std::optional< double > mSampleRate
std::weak_ptr< DynamicRangeProcessorOutputPacketQueue > mOutputQueue
std::unique_ptr< CompressorProcessor > mCompressor
std::vector< CompressorInstance > mSlaves
virtual unsigned GetAudioInCount() const =0
How many input buffers to allocate at once.
virtual bool RealtimeAddProcessor(EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
virtual bool RealtimeResume()
virtual bool RealtimeInitialize(EffectSettings &settings, double sampleRate)
virtual bool RealtimeFinalize(EffectSettings &settings) noexcept
virtual SampleCount GetLatency(const EffectSettings &settings, double sampleRate) const
virtual unsigned GetAudioOutCount() const =0
How many output buffers to allocate at once.
virtual void RealtimePassThrough(size_t group, EffectSettings &settings, const float *const *inBuf, size_t numSamples)
Called instead of RealtimeProcess when the effect is bypassed. Default implementation does nothing.
uint64_t SampleCount
virtual size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
Inherit to add a state variable to an EffectInstance subclass.
Hold values to send to effect output meters.
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
bool ProcessFinalize() noexcept override
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
Base class for many of the effects in Audacity.
Externalized state of a plug-in.