Added Audio(const Str_8& filePath, DataType type)
to force a specific data type.
This commit is contained in:
parent
93f881cf03
commit
58f624a18a
@ -41,6 +41,8 @@ namespace ehs
|
||||
|
||||
Audio(const Str_8& filePath);
|
||||
|
||||
Audio(const Str_8& filePath, DataType type);
|
||||
|
||||
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data);
|
||||
|
||||
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Serializer<UInt_64>& data);
|
||||
|
@ -80,6 +80,29 @@ namespace ehs
|
||||
codec->Decode(data, this);
|
||||
}
|
||||
|
||||
Audio::Audio(const Str_8& filePath, DataType type)
|
||||
{
|
||||
AddType("Audio");
|
||||
|
||||
File file(filePath, Mode::READ, Disposition::OPEN);
|
||||
Str_8 ext = file.GetExtension();
|
||||
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
Serializer<UInt_64> data = file.ReadSerializer_64(codec->GetEndianness(), file.Size());
|
||||
|
||||
file.Release();
|
||||
|
||||
codec->Decode(data, this);
|
||||
|
||||
ToDataType(type);
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames, const Byte* const data)
|
||||
: Resource((Str_8&&)id), dataType(dataType), byteDepth(ToByteDepth(dataType)), sampleRate(sampleRate),
|
||||
channels(channels), frames(frames), length((float)frames / (float)sampleRate),
|
||||
|
Loading…
Reference in New Issue
Block a user