Audio: Fix AudioFormat names (U16 -> I16)
This commit is contained in:
parent
2d16cf81d1
commit
d5c27a756b
|
|
@ -26,22 +26,22 @@ namespace Nz
|
||||||
case AudioFormat::Unknown: //< Just to make the compiler stop complaining
|
case AudioFormat::Unknown: //< Just to make the compiler stop complaining
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AudioFormat::U16_Mono:
|
case AudioFormat::I16_Mono:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case AudioFormat::U16_Stereo:
|
case AudioFormat::I16_Stereo:
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
case AudioFormat::U16_Quad:
|
case AudioFormat::I16_Quad:
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
case AudioFormat::U16_5_1:
|
case AudioFormat::I16_5_1:
|
||||||
return 6;
|
return 6;
|
||||||
|
|
||||||
case AudioFormat::U16_6_1:
|
case AudioFormat::I16_6_1:
|
||||||
return 7;
|
return 7;
|
||||||
|
|
||||||
case AudioFormat::U16_7_1:
|
case AudioFormat::I16_7_1:
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@ namespace Nz
|
||||||
{
|
{
|
||||||
Unknown = -1,
|
Unknown = -1,
|
||||||
|
|
||||||
U16_Mono,
|
I16_Mono,
|
||||||
U16_Stereo,
|
I16_Stereo,
|
||||||
U16_Quad,
|
I16_Quad,
|
||||||
U16_5_1,
|
I16_5_1,
|
||||||
U16_6_1,
|
I16_6_1,
|
||||||
U16_7_1,
|
I16_7_1,
|
||||||
|
|
||||||
Max = U16_7_1
|
Max = I16_7_1
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::size_t AudioFormatCount = static_cast<std::size_t>(AudioFormat::Max) + 1;
|
constexpr std::size_t AudioFormatCount = static_cast<std::size_t>(AudioFormat::Max) + 1;
|
||||||
|
|
|
||||||
|
|
@ -31,22 +31,22 @@ namespace Nz
|
||||||
switch (channelCount)
|
switch (channelCount)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return AudioFormat::U16_Stereo;
|
return AudioFormat::I16_Stereo;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return AudioFormat::U16_Quad;
|
return AudioFormat::I16_Quad;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
return AudioFormat::U16_5_1;
|
return AudioFormat::I16_5_1;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
return AudioFormat::U16_6_1;
|
return AudioFormat::I16_6_1;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
return AudioFormat::U16_7_1;
|
return AudioFormat::I16_7_1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
@ -120,11 +120,11 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.forceMono && format != AudioFormat::U16_Mono)
|
if (parameters.forceMono && format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(wav.channels), wav.totalPCMFrameCount);
|
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(wav.channels), wav.totalPCMFrameCount);
|
||||||
|
|
||||||
format = AudioFormat::U16_Mono;
|
format = AudioFormat::I16_Mono;
|
||||||
sampleCount = wav.totalPCMFrameCount;
|
sampleCount = wav.totalPCMFrameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Nz
|
||||||
AudioFormat GetFormat() const override
|
AudioFormat GetFormat() const override
|
||||||
{
|
{
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
else
|
else
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +220,7 @@ namespace Nz
|
||||||
m_sampleRate = m_decoder.sampleRate;
|
m_sampleRate = m_decoder.sampleRate;
|
||||||
|
|
||||||
// Mixing to mono will be done on the fly
|
// Mixing to mono will be done on the fly
|
||||||
if (forceMono && m_format != AudioFormat::U16_Mono)
|
if (forceMono && m_format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
m_mixToMono = true;
|
m_mixToMono = true;
|
||||||
m_sampleCount = m_decoder.totalPCMFrameCount;
|
m_sampleCount = m_decoder.totalPCMFrameCount;
|
||||||
|
|
|
||||||
|
|
@ -28,22 +28,22 @@ namespace Nz
|
||||||
switch (channelCount)
|
switch (channelCount)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return AudioFormat::U16_Stereo;
|
return AudioFormat::I16_Stereo;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return AudioFormat::U16_Quad;
|
return AudioFormat::I16_Quad;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
return AudioFormat::U16_5_1;
|
return AudioFormat::I16_5_1;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
return AudioFormat::U16_6_1;
|
return AudioFormat::I16_6_1;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
return AudioFormat::U16_7_1;
|
return AudioFormat::I16_7_1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
@ -193,11 +193,11 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.forceMono && format != AudioFormat::U16_Mono)
|
if (parameters.forceMono && format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(info->channels), frameCount);
|
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(info->channels), frameCount);
|
||||||
|
|
||||||
format = AudioFormat::U16_Mono;
|
format = AudioFormat::I16_Mono;
|
||||||
sampleCount = frameCount;
|
sampleCount = frameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,7 +226,7 @@ namespace Nz
|
||||||
AudioFormat GetFormat() const override
|
AudioFormat GetFormat() const override
|
||||||
{
|
{
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
else
|
else
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +300,7 @@ namespace Nz
|
||||||
m_sampleRate = info->rate;
|
m_sampleRate = info->rate;
|
||||||
|
|
||||||
// Mixing to mono will be done on the fly
|
// Mixing to mono will be done on the fly
|
||||||
if (forceMono && m_format != AudioFormat::U16_Mono)
|
if (forceMono && m_format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
m_mixToMono = true;
|
m_mixToMono = true;
|
||||||
m_sampleCount = frameCount;
|
m_sampleCount = frameCount;
|
||||||
|
|
|
||||||
|
|
@ -30,22 +30,22 @@ namespace Nz
|
||||||
switch (channelCount)
|
switch (channelCount)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return AudioFormat::U16_Stereo;
|
return AudioFormat::I16_Stereo;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return AudioFormat::U16_Quad;
|
return AudioFormat::I16_Quad;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
return AudioFormat::U16_5_1;
|
return AudioFormat::I16_5_1;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
return AudioFormat::U16_6_1;
|
return AudioFormat::I16_6_1;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
return AudioFormat::U16_7_1;
|
return AudioFormat::I16_7_1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
@ -135,12 +135,12 @@ namespace Nz
|
||||||
|
|
||||||
UInt32 sampleCount = static_cast<UInt32>(info.samples);
|
UInt32 sampleCount = static_cast<UInt32>(info.samples);
|
||||||
|
|
||||||
if (parameters.forceMono && format != AudioFormat::U16_Mono)
|
if (parameters.forceMono && format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
UInt64 frameCount = UInt64(info.samples / info.channels);
|
UInt64 frameCount = UInt64(info.samples / info.channels);
|
||||||
MixToMono(info.buffer, info.buffer, static_cast<UInt32>(info.channels), frameCount);
|
MixToMono(info.buffer, info.buffer, static_cast<UInt32>(info.channels), frameCount);
|
||||||
|
|
||||||
format = AudioFormat::U16_Mono;
|
format = AudioFormat::I16_Mono;
|
||||||
sampleCount = frameCount;
|
sampleCount = frameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,7 +169,7 @@ namespace Nz
|
||||||
AudioFormat GetFormat() const override
|
AudioFormat GetFormat() const override
|
||||||
{
|
{
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
else
|
else
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ namespace Nz
|
||||||
m_sampleRate = m_decoder.info.hz;
|
m_sampleRate = m_decoder.info.hz;
|
||||||
|
|
||||||
// Mixing to mono will be done on the fly
|
// Mixing to mono will be done on the fly
|
||||||
if (forceMono && m_format != AudioFormat::U16_Mono)
|
if (forceMono && m_format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
m_mixToMono = true;
|
m_mixToMono = true;
|
||||||
m_sampleCount = static_cast<UInt32>(m_decoder.samples / m_decoder.info.channels);
|
m_sampleCount = static_cast<UInt32>(m_decoder.samples / m_decoder.info.channels);
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,22 @@ namespace Nz
|
||||||
switch (channelCount)
|
switch (channelCount)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return AudioFormat::U16_Stereo;
|
return AudioFormat::I16_Stereo;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return AudioFormat::U16_Quad;
|
return AudioFormat::I16_Quad;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
return AudioFormat::U16_5_1;
|
return AudioFormat::I16_5_1;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
return AudioFormat::U16_6_1;
|
return AudioFormat::I16_6_1;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
return AudioFormat::U16_7_1;
|
return AudioFormat::I16_7_1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
@ -121,7 +121,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
// Nous avons besoin du nombre de canaux d'origine pour convertir en mono, nous trichons donc un peu...
|
// Nous avons besoin du nombre de canaux d'origine pour convertir en mono, nous trichons donc un peu...
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
return AudioFormat::U16_Mono;
|
return AudioFormat::I16_Mono;
|
||||||
else
|
else
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +201,7 @@ namespace Nz
|
||||||
sf_command(m_handle, SFC_SET_SCALE_FLOAT_INT_READ, nullptr, SF_TRUE);
|
sf_command(m_handle, SFC_SET_SCALE_FLOAT_INT_READ, nullptr, SF_TRUE);
|
||||||
|
|
||||||
// On mixera en mono lors de la lecture
|
// On mixera en mono lors de la lecture
|
||||||
if (forceMono && m_format != AudioFormat::U16_Mono)
|
if (forceMono && m_format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
m_mixToMono = true;
|
m_mixToMono = true;
|
||||||
m_sampleCount = static_cast<UInt32>(info.frames);
|
m_sampleCount = static_cast<UInt32>(info.frames);
|
||||||
|
|
@ -377,11 +377,11 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to mono if required
|
// Convert to mono if required
|
||||||
if (parameters.forceMono && format != AudioFormat::U16_Mono)
|
if (parameters.forceMono && format != AudioFormat::I16_Mono)
|
||||||
{
|
{
|
||||||
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(info.channels), static_cast<UInt64>(info.frames));
|
MixToMono(samples.get(), samples.get(), static_cast<UInt32>(info.channels), static_cast<UInt64>(info.frames));
|
||||||
|
|
||||||
format = AudioFormat::U16_Mono;
|
format = AudioFormat::I16_Mono;
|
||||||
sampleCount = static_cast<unsigned int>(info.frames);
|
sampleCount = static_cast<unsigned int>(info.frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -440,19 +440,19 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
// We complete the formats table
|
// We complete the formats table
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_Mono)] = AL_FORMAT_MONO16;
|
AudioFormat[UnderlyingCast(AudioFormat::I16_Mono)] = AL_FORMAT_MONO16;
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_Stereo)] = AL_FORMAT_STEREO16;
|
AudioFormat[UnderlyingCast(AudioFormat::I16_Stereo)] = AL_FORMAT_STEREO16;
|
||||||
|
|
||||||
// "The presence of an enum value does not guarantee the applicability of an extension to the current context."
|
// "The presence of an enum value does not guarantee the applicability of an extension to the current context."
|
||||||
if (alIsExtensionPresent("AL_EXT_MCFORMATS"))
|
if (alIsExtensionPresent("AL_EXT_MCFORMATS"))
|
||||||
{
|
{
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_Quad)] = alGetEnumValue("AL_FORMAT_QUAD16");
|
AudioFormat[UnderlyingCast(AudioFormat::I16_Quad)] = alGetEnumValue("AL_FORMAT_QUAD16");
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_5_1)] = alGetEnumValue("AL_FORMAT_51CHN16");
|
AudioFormat[UnderlyingCast(AudioFormat::I16_5_1)] = alGetEnumValue("AL_FORMAT_51CHN16");
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_6_1)] = alGetEnumValue("AL_FORMAT_61CHN16");
|
AudioFormat[UnderlyingCast(AudioFormat::I16_6_1)] = alGetEnumValue("AL_FORMAT_61CHN16");
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_7_1)] = alGetEnumValue("AL_FORMAT_71CHN16");
|
AudioFormat[UnderlyingCast(AudioFormat::I16_7_1)] = alGetEnumValue("AL_FORMAT_71CHN16");
|
||||||
}
|
}
|
||||||
else if (alIsExtensionPresent("AL_LOKI_quadriphonic"))
|
else if (alIsExtensionPresent("AL_LOKI_quadriphonic"))
|
||||||
AudioFormat[UnderlyingCast(AudioFormat::U16_Quad)] = alGetEnumValue("AL_FORMAT_QUAD16_LOKI");
|
AudioFormat[UnderlyingCast(AudioFormat::I16_Quad)] = alGetEnumValue("AL_FORMAT_QUAD16_LOKI");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ SCENARIO("Music", "[AUDIO][MUSIC]")
|
||||||
{
|
{
|
||||||
CHECK(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
|
CHECK(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
|
||||||
CHECK(music.GetDuration() >= 63000);
|
CHECK(music.GetDuration() >= 63000);
|
||||||
CHECK(music.GetFormat() == Nz::AudioFormat::U16_Stereo);
|
CHECK(music.GetFormat() == Nz::AudioFormat::I16_Stereo);
|
||||||
CHECK(music.GetPlayingOffset() == 0);
|
CHECK(music.GetPlayingOffset() == 0);
|
||||||
CHECK(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
|
CHECK(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
|
||||||
CHECK(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
|
CHECK(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue