Fixed all errors.

This commit is contained in:
2023-12-18 02:13:20 -08:00
parent 3acb78f247
commit 0a6f5533ee
37 changed files with 950 additions and 1090 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "BaseObj.h"
#include "DataType.h"
#include "Str.h"
#include "Serializer.h"
@@ -10,10 +11,12 @@
namespace ehs
{
class Audio : public Resource
class Audio : public BaseObj
{
private:
static Array<AudioCodec> codecs;
UInt_64 hashId;
Str_8 id;
UInt_64 sampleRate;
DataType dataType;
UInt_8 byteDepth;
@@ -24,29 +27,31 @@ namespace ehs
Byte* peak;
public:
static bool HasCodec(const UInt_64 hashExt);
static bool HasCodec(UInt_64 hashExt);
static bool HasCodec(const Str_8& ext);
static bool AddCodec(AudioCodec codec);
static const AudioCodec* GetCodec(const UInt_64 hashExt);
static const AudioCodec* GetCodec(UInt_64 hashExt);
static const AudioCodec* GetCodec(const Str_8& ext);
~Audio() override;
~Audio();
Audio();
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames, const Byte* const data);
Audio(Str_8 id);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Serializer<UInt_64>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Vector<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Serializer<UInt_64>& data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Array<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Vector<Byte>& data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Array<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames);
Audio(Audio&& audio) noexcept;
@@ -60,6 +65,14 @@ namespace ehs
operator Byte*();
void Release();
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
UInt_64 GetSampleRate() const;
DataType GetDataType() const;
@@ -78,23 +91,23 @@ namespace ehs
float GetLength() const;
Array<Byte> FrameAsMono(const UInt_64 frameIndex) const;
Array<Byte> FrameAsMono(UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(const UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(UInt_64 frameIndex) const;
Array<Byte> FrameAsFive_One(const UInt_64 frameIndex) const;
Array<Byte> FrameAsFive_One(UInt_64 frameIndex) const;
Array<Byte> FrameAsSeven_One(const UInt_64 frameIndex) const;
Array<Byte> FrameAsSeven_One(UInt_64 frameIndex) const;
SInt_8 SampleAsSInt_8(const UInt_64 sampleIndex) const;
SInt_8 SampleAsSInt_8(UInt_64 sampleIndex) const;
SInt_16 SampleAsSInt_16(const UInt_64 sampleIndex) const;
SInt_16 SampleAsSInt_16(UInt_64 sampleIndex) const;
float SampleAsFloat(const UInt_64 sampleIndex) const;
float SampleAsFloat(UInt_64 sampleIndex) const;
SInt_32 SampleAsSInt_32(const UInt_64 sampleIndex) const;
SInt_32 SampleAsSInt_32(UInt_64 sampleIndex) const;
SInt_64 SampleAsSInt_64(const UInt_64 sampleIndex) const;
SInt_64 SampleAsSInt_64(UInt_64 sampleIndex) const;
SInt_8 PeakAsSInt_8() const;
@@ -106,17 +119,17 @@ namespace ehs
SInt_64 PeakAsSInt_64() const;
void SetPeak(const UInt_64 size, const Byte* newPeak);
void SetPeak(UInt_64 size, const Byte* newPeak);
const Byte* GetPeak() const;
void ToDataType(const DataType newDataType);
void ToDataType(DataType newDataType);
Audio GetAsDataType(const DataType newDataType) const;
Audio GetAsDataType(DataType newDataType) const;
void ToChannels(const UInt_8 newChannels);
void ToChannels(UInt_8 newChannels);
Audio GetAsChannels(const UInt_8 newChannels) const;
Audio GetAsChannels(UInt_8 newChannels) const;
bool ToFile(const Str_8& filePath) const;
@@ -124,32 +137,32 @@ namespace ehs
static Audio* FromFile_Heap(const Str_8& filePath);
static Audio FromFile(const Str_8& filePath, const DataType required);
static Audio FromFile(const Str_8& filePath, DataType required);
static Audio* FromFile_Heap(const Str_8& filePath, const DataType required);
static Audio* FromFile_Heap(const Str_8& filePath, DataType required);
static Audio FromData(const Str_8& ext, const Str_8& id, Serializer<UInt_64>& data);
static Audio FromData(Str_8 id, const Str_8& ext, Serializer<UInt_64>& data);
private:
void ToMono(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void ToMono(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Five_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Five_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Seven_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Seven_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Stereo_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Stereo_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Seven_One_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Seven_One_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Stereo_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Stereo_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Five_One_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Five_One_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
// To SInt_8
void SInt_16_to_SInt_8(Byte* newData, Byte* newPeak) const;