69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
#pragma once
|
|
#include "CoreMinimal.h"
|
|
#include "Midi/MidiType.h"
|
|
|
|
class MidiTick;
|
|
|
|
class AudioFrame
|
|
{
|
|
public:
|
|
typedef double ValueType;
|
|
AudioFrame() : Pos(0) {}
|
|
AudioFrame(const double InFrame) : Pos(InFrame) {}
|
|
AudioFrame(const MidiTick& InMidiTicks);
|
|
|
|
template<typename T>
|
|
AudioFrame operator=(const T& InPos) { Pos = InPos; return *this; }
|
|
template<typename T>
|
|
AudioFrame operator+(const T& InFrame) const { return Pos + InFrame; }
|
|
template<typename T>
|
|
AudioFrame operator-(const T& InFrame) const { return Pos - InFrame; }
|
|
template<typename T>
|
|
AudioFrame operator*(const T& InFrame) const { return Pos * InFrame; }
|
|
template<typename T>
|
|
AudioFrame operator/(const T& InFrame) const { return Pos / InFrame; }
|
|
template<typename T>
|
|
AudioFrame& operator+=(const T& InFrame) { Pos += InFrame; return *this; }
|
|
template<typename T>
|
|
AudioFrame& operator-=(const T& InFrame) { Pos -= InFrame; return *this; }
|
|
template<typename T>
|
|
AudioFrame& operator*=(const T& InFrame) { Pos *= InFrame; return *this; }
|
|
template<typename T>
|
|
AudioFrame& operator/=(const T& InFrame) { Pos /= InFrame; return *this; }
|
|
|
|
bool operator==(const AudioFrame& InFrame) const { return Pos == InFrame.Pos; }
|
|
bool operator!=(const AudioFrame& InFrame) const { return Pos != InFrame.Pos; }
|
|
bool operator<(const AudioFrame& InFrame) const { return Pos < InFrame.Pos; }
|
|
bool operator>(const AudioFrame& InFrame) const { return Pos > InFrame.Pos; }
|
|
bool operator<=(const AudioFrame& InFrame) const { return Pos <= InFrame.Pos; }
|
|
bool operator>=(const AudioFrame& InFrame) const { return Pos >= InFrame.Pos; }
|
|
|
|
operator ValueType() const { return Pos; }
|
|
|
|
void SetTick(MidiTick InMidiTicks);
|
|
MidiTick Ticks() const;
|
|
|
|
double Milliseconds() const;
|
|
|
|
static AudioFrame FromFrames(double InFrames, float InFramesPerTick);
|
|
static double FrameToMilliseconds(double InFrame);
|
|
|
|
ValueType Pos;
|
|
};
|
|
|
|
class MidiTick
|
|
{
|
|
public:
|
|
MidiTick() : Ticks(0) {}
|
|
MidiTick(const int64 InMidiTick) : Ticks(InMidiTick) {}
|
|
MidiTick(const AudioFrame& InFrame) : Ticks(InFrame.Ticks()) {}
|
|
|
|
MidiTick operator=(const int64& InTicks) { Ticks = InTicks; return *this; }
|
|
MidiTick operator+(const int64& InTicks) const { return Ticks + InTicks; }
|
|
MidiTick operator-(const int64& InTicks) const { return Ticks - InTicks; }
|
|
|
|
operator int64() const { return Ticks; }
|
|
AudioFrame Frames() const;
|
|
int64 Ticks;
|
|
};
|