|
|
|
@ -290,6 +290,11 @@ namespace ehs
|
|
|
|
|
return channels * frames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UInt_8 Audio::GetFrameSize() const
|
|
|
|
|
{
|
|
|
|
|
return byteDepth * channels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UInt_64 Audio::GetSize() const
|
|
|
|
|
{
|
|
|
|
|
return byteDepth * channels * frames;
|
|
|
|
@ -300,6 +305,11 @@ namespace ehs
|
|
|
|
|
return length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Byte* Audio::GetFrame(UInt_64 frameIndex) const
|
|
|
|
|
{
|
|
|
|
|
return &data[frameIndex * GetFrameSize()];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Array<Byte> Audio::FrameAsMono(const UInt_64 frameIndex) const
|
|
|
|
|
{
|
|
|
|
|
Array<Byte> result(byteDepth);
|
|
|
|
@ -1743,161 +1753,161 @@ namespace ehs
|
|
|
|
|
void Audio::SInt_16_to_SInt_8(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
newData[a] = (Byte)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
newData[a] = (Byte)((double)((SInt_16*)data)[a] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((double)*(SInt_16*)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::Float_to_SInt_8(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_8*)newData)[a] = (SInt_8)(((float*)data)[a] * (float)EHS_SINT_8_MAX);
|
|
|
|
|
((SInt_8*)newData)[a] = (SInt_8)((double)((float*)data)[a] * (double)EHS_SINT_8_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)(*(float*)peak * (float)EHS_SINT_8_MAX);
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((double)(*(float*)peak) * (double)EHS_SINT_8_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_32_to_SInt_8(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
newData[a] = (Byte)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
newData[a] = (Byte)((double)((SInt_32*)data)[a] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((double)*(SInt_32*)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_64_to_SInt_8(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
newData[a] = (Byte)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
newData[a] = (Byte)((double)((SInt_64*)data)[a] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
|
|
|
|
*(SInt_8*)newPeak = (SInt_8)((double)*(SInt_64*)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_8_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_8_to_SInt_16(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((double)(SInt_8)data[a] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((double)*(SInt_8*)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::Float_to_SInt_16(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)(((float*)data)[a] * (float)EHS_SINT_16_MAX);
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((double)((float*)data)[a] * (double)EHS_SINT_16_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)(*(float*)peak * (float)EHS_SINT_16_MAX);
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((double)(*(float*)peak) * (double)EHS_SINT_16_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_32_to_SInt_16(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((double)((SInt_32*)data)[a] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((double)*(SInt_32*)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_64_to_SInt_16(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
((SInt_16*)newData)[a] = (SInt_16)((double)((SInt_64*)data)[a] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
|
|
|
|
*(SInt_16*)newPeak = (SInt_16)((double)*(SInt_64*)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_16_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_8_to_Float(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((float*)newData)[a] = (float)(((SInt_8*)data)[a]) / (float)EHS_SINT_8_MAX;
|
|
|
|
|
((float*)newData)[a] = (float)((double)(((SInt_8*)data)[a]) / (double)EHS_SINT_8_MAX);
|
|
|
|
|
|
|
|
|
|
*(float*)newPeak = (float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX;
|
|
|
|
|
*(float*)newPeak = (float)((double)*(SInt_8*)peak / (double)EHS_SINT_8_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_16_to_Float(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((float*)newData)[a] = (float)(((SInt_16*)data)[a]) / (float)EHS_SINT_16_MAX;
|
|
|
|
|
((float*)newData)[a] = (float)((double)(((SInt_16*)data)[a]) / (double)EHS_SINT_16_MAX);
|
|
|
|
|
|
|
|
|
|
*(float*)newPeak = (float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX;
|
|
|
|
|
*(float*)newPeak = (float)((double)*(SInt_16*)peak / (double)EHS_SINT_16_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_32_to_Float(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((float*)newData)[a] = (float)(((SInt_32*)data)[a]) / (float)EHS_SINT_32_MAX;
|
|
|
|
|
((float*)newData)[a] = (float)((double)(((SInt_32*)data)[a]) / (double)EHS_SINT_32_MAX);
|
|
|
|
|
|
|
|
|
|
*(float*)newPeak = (float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX;
|
|
|
|
|
*(float*)newPeak = (float)((double)*(SInt_32*)peak / (double)EHS_SINT_32_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_64_to_Float(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((float*)newData)[a] = (float)(((SInt_64*)data)[a]) / (float)EHS_SINT_64_MAX;
|
|
|
|
|
((float*)newData)[a] = (float)((double)(((SInt_64*)data)[a]) / (double)EHS_SINT_64_MAX);
|
|
|
|
|
|
|
|
|
|
*(float*)newPeak = (float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX;
|
|
|
|
|
*(float*)newPeak = (float)((double)*(SInt_64*)peak / (double)EHS_SINT_64_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_8_to_SInt_32(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((double)(SInt_8)data[a] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((double)*(SInt_8*)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_16_to_SInt_32(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((double)((SInt_16*)data)[a] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((double)*(SInt_16*)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::Float_to_SInt_32(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)(((float*)data)[a] * (float)EHS_SINT_32_MAX);
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)(((double*)data)[a] * (double)EHS_SINT_32_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)(*(float*)peak * (float)EHS_SINT_32_MAX);
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)(*(double*)peak * (double)EHS_SINT_32_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_64_to_SInt_32(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
((SInt_32*)newData)[a] = (SInt_32)((double)((SInt_64*)data)[a] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
|
|
|
|
*(SInt_32*)newPeak = (SInt_32)((double)*(SInt_64*)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_32_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_8_to_SInt_64(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((double)(SInt_8)data[a] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((double)*(SInt_8*)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_16_to_SInt_64(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((double)((SInt_16*)data)[a] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((double)*(SInt_16*)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::Float_to_SInt_64(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)(((float*)data)[a] * (float)EHS_SINT_64_MAX);
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)(((double*)data)[a] * (double)EHS_SINT_64_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)(*(float*)peak * (float)EHS_SINT_64_MAX);
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)(*(double*)peak * (double)EHS_SINT_64_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Audio::SInt_32_to_SInt_64(Byte* newData, Byte* newPeak) const
|
|
|
|
|
{
|
|
|
|
|
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
((SInt_64*)newData)[a] = (SInt_64)((double)((SInt_32*)data)[a] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
|
|
|
|
*(SInt_64*)newPeak = (SInt_64)((double)*(SInt_32*)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_64_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EncodeEHA(const ehs::AudioCodec* const codec, ehs::Serializer<ehs::UInt_64>& out, const ehs::Audio* const in)
|
|
|
|
|