Added support for 32-bits samples in WAV files

This commit is contained in:
Laurent Gomila 2015-03-21 13:45:54 +01:00 committed by Lukas Dürrenberger
parent ce16554763
commit 3ca6e0f346

View File

@ -65,6 +65,17 @@ namespace
return true;
}
bool decode(sf::InputStream& stream, sf::Int32& value)
{
unsigned char bytes[sizeof(value)];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
return false;
value = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
return true;
}
bool decode(sf::InputStream& stream, sf::Uint32& value)
{
unsigned char bytes[sizeof(value)];
@ -157,6 +168,16 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
return count;
break;
}
case 4:
{
Int32 sample = 0;
if (decode(*m_stream, sample))
*samples++ = sample >> 16;
else
return count;
break;
}
}
++count;