Files
UnrealEngineUWP/Engine/Source/Runtime/SignalProcessing/Public/DSP/EnvelopeFollower.h
aaron mcleran 0c4ee1466f Audio bus feature
- Audio bus is a new asset type that allows audio to be routed around to effects, etc.
- Extracts the underlying logic from source buses and changes source bus semantics to be a sonification of audio buses. Audio buses do not render to be audible on their own.
- Main use-case is side-chaining audio effects (e.g. side chain compression, auto-wah filters, etc).

#rb Ethan.Geller, Rob.Gay, Maxwell.Hayes, Phil.Popp, Ryan.Mangin
#jira UE-88494


#ROBOMERGE-SOURCE: CL 11449969 via CL 11450113
#ROBOMERGE-BOT: (v654-11333218)

[CL 11450145 by aaron mcleran in Main branch]
2020-02-14 16:51:07 -05:00

81 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
namespace Audio
{
// Different modes for the envelope follower
namespace EPeakMode
{
enum Type
{
MeanSquared,
RootMeanSquared,
Peak,
Count
};
}
// A simple utility that returns a smoothed value given audio input using an RC circuit.
// Used for following the envelope of an audio stream.
class SIGNALPROCESSING_API FEnvelopeFollower
{
public:
FEnvelopeFollower();
FEnvelopeFollower(const float InSampleRate, const float InAttackTimeMsec = 10.0f, const float InReleaseTimeMSec = 100.0f, const EPeakMode::Type InMode = EPeakMode::Peak, const bool bInIsAnalg = true);
virtual ~FEnvelopeFollower();
// Initialize the envelope follower
void Init(const float InSampleRate, const float InAttackTimeMsec = 10.0f, const float InReleaseTimeMSec = 100.0f, const EPeakMode::Type InMode = EPeakMode::Peak, const bool bInIsAnalg = true);
// Resets the state of the envelope follower
void Reset();
// Sets whether or not to use analog or digital time constants
void SetAnalog(const bool bInIsAnalog);
// Sets the envelope follower attack time (how fast the envelope responds to input)
void SetAttackTime(const float InAttackTimeMsec);
// Sets the envelope follower release time (how slow the envelope dampens from input)
void SetReleaseTime(const float InReleaseTimeMsec);
// Sets the output mode of the envelope follower
void SetMode(const EPeakMode::Type InMode);
// Processes the input audio stream and returns the envelope value.
float ProcessAudio(const float InAudioSample);
// Process the input audio buffer and returns the last envelope value
float ProcessAudio(const float* InAudioBuffer, float* OutAudioBuffer, int32 InNumSamples);
// Process the input audio buffer and returns the last envelope value
float ProcessAudio(const float* InAudioBuffer, int32 InNumSamples);
// Processes the input audio stream and returns the envelope value.
float ProcessAudioNonClamped(const float InAudioSample);
// Process the input audio stream in int16 format
int16 ProcessAudio(const int16 InAudioSample);
// Gets the current envelope value
float GetCurrentValue() const;
protected:
EPeakMode::Type EnvMode;
float SampleRate;
float AttackTimeMsec;
float AttackTimeSamples;
float ReleaseTimeMsec;
float ReleaseTimeSamples;
float CurrentEnvelopeValue;
bool bIsAnalog;
};
}