You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Up to CL8320930 from DevOnline and 8311605 Merge Down from Main - skipped some Fortnite content/plugins/code where it tried to reintegrate files that had been moved pending investigation #rb none [CL 8321295 by Josh Markiewicz in Main branch]
102 lines
2.4 KiB
C++
102 lines
2.4 KiB
C++
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
namespace Audio
|
|
{
|
|
// Wavetable oscillator types
|
|
namespace EWaveTable
|
|
{
|
|
enum Type
|
|
{
|
|
None,
|
|
SineWaveTable,
|
|
SawWaveTable,
|
|
TriangleWaveTable,
|
|
SquareWaveTable,
|
|
BandLimitedSawWaveTable,
|
|
BandLimitedTriangleWaveTable,
|
|
BandLimitedSquareWaveTable,
|
|
Custom
|
|
};
|
|
}
|
|
|
|
class FWaveTableOsc;
|
|
|
|
|
|
// A wave table oscillator class
|
|
class SIGNALPROCESSING_API FWaveTableOsc
|
|
{
|
|
public:
|
|
// Constructor
|
|
FWaveTableOsc();
|
|
|
|
// Virtual Destructor
|
|
virtual ~FWaveTableOsc();
|
|
|
|
// Initialize the wave table oscillator
|
|
void Init(const float InSampleRate, const float InFrequencyHz);
|
|
|
|
// Sets the sample rate of the oscillator.
|
|
void SetSampleRate(const float InSampleRate);
|
|
|
|
// Resets the wave table read indices.
|
|
void Reset();
|
|
|
|
// Sets the amount to scale and add to the output of the wave table
|
|
void SetScaleAdd(const float InScale, const float InAdd);
|
|
|
|
// Returns the type of the wave table oscillator.
|
|
EWaveTable::Type GetType() const { return WaveTableType; }
|
|
|
|
// Sets the frequency of the wave table oscillator.
|
|
void SetFrequencyHz(const float InFrequencyHz);
|
|
|
|
// Returns the frequency of the wave table oscillator.
|
|
float GetFrequencyHz() const { return FrequencyHz; }
|
|
|
|
// Returns the internal table used in the wave table.
|
|
TArray<float>& GetTable();
|
|
const TArray<float>& GetTable() const;
|
|
|
|
// Processes the wave table, outputs the normal and quad phase (optional) values
|
|
void Generate(float* OutputNormalPhase, float* OutputQuadPhase = nullptr);
|
|
|
|
// Creates a wave table using internal factories for standard wave tables or uses custom wave table factor if it exists.
|
|
static TSharedPtr<FWaveTableOsc> CreateWaveTable(const EWaveTable::Type WaveTableType, const int32 WaveTableSize = 1024);
|
|
|
|
protected:
|
|
void UpdateFrequency();
|
|
|
|
// The wave table buffer
|
|
TArray<float> WaveTableBuffer;
|
|
|
|
// The frequency of the output (given the sample rate)
|
|
float FrequencyHz;
|
|
|
|
// The sample rate of the oscillator
|
|
float SampleRate;
|
|
|
|
// Normal phase read index
|
|
float NormalPhaseReadIndex;
|
|
|
|
// The quad-phase read index
|
|
float QuadPhaseReadIndex;
|
|
|
|
// The phase increment (based on frequency)
|
|
float PhaseIncrement;
|
|
|
|
// Amount to scale the output by
|
|
float OutputScale;
|
|
|
|
// Amount to add to the output
|
|
float OutputAdd;
|
|
|
|
// The wave table oscillator type
|
|
EWaveTable::Type WaveTableType;
|
|
};
|
|
|
|
}
|