Files
UnrealEngineUWP/Engine/Source/Runtime/SignalProcessing/Public/DSP/BitCrusher.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

53 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "DSP/Osc.h"
namespace Audio
{
// Bit crushing effect
// https://en.wikipedia.org/wiki/Bitcrusher
class SIGNALPROCESSING_API FBitCrusher
{
public:
// Constructor
FBitCrusher();
// Destructor
~FBitCrusher();
// Initialize the equalizer
void Init(const float InSampleRate, const int32 InNumChannels);
// The amount to reduce the sample rate of the audio stream.
void SetSampleRateCrush(const float InFrequency);
// The amount to reduce the bit depth of the audio stream.
void SetBitDepthCrush(const float InBitDepth);
// Processes audio
void ProcessAudioFrame(const float* InFrame, float* OutFrame);
void ProcessAudio(const float* InBuffer, const int32 InNumSamples, float* OutBuffer);
private:
// i.e. 8 bit, etc. But can be float!
float SampleRate;
float BitDepth;
float BitDelta;
// The current phase of the bit crusher
float Phase;
// The amount of phase to increment each sample
float PhaseDelta;
// Used to sample+hold the last output
float LastOutput[2];
int32 NumChannels;
};
}