Files
UnrealEngineUWP/Engine/Source/Runtime/SignalProcessing/Public/DSP/FoldbackDistortion.h
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

63 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "DSP/Osc.h"
namespace Audio
{
// Foldback distortion effect
// https://en.wikipedia.org/wiki/Foldback_(power_supply_design)
class SIGNALPROCESSING_API FFoldbackDistortion
{
public:
// Constructor
FFoldbackDistortion();
// Destructor
~FFoldbackDistortion();
// Initialize the equalizer
void Init(const float InSampleRate, const int32 InNumChannels);
// Sets the foldback distortion threshold
void SetThresholdDb(const float InThresholdDb);
// Sets the input gain
void SetInputGainDb(const float InInputGainDb);
// Sets the output gain
void SetOutputGainDb(const float InOutputGainDb);
// Processes a single audio sample
float ProcessAudioSample(const float InSample);
// Processes a mono stream
void ProcessAudioFrame(const float* InFrame, float* OutFrame);
// Processes a stereo stream
void ProcessAudio(const float* InBuffer, const int32 InNumSamples, float* OutBuffer);
private:
// Threshold to check before folding audio back on itself
float Threshold;
// Threshold times 2
float Threshold2;
// Threshold time 4
float Threshold4;
// Input gain used to force hitting the threshold
float InputGain;
// A final gain scaler to apply to the output
float OutputGain;
// How many channels we expect the audio intput to be.
int32 NumChannels;
};
}