Fixed stereo sound loading

I had already fixed this on the dev branch, backporting because it's gonna take a while until it's released
This commit is contained in:
Juan Pablo Arce
2018-08-08 20:57:00 -03:00
parent 92f3ac5469
commit f1a8db5b47
@@ -39,7 +39,7 @@ namespace Barotrauma.Sounds
using (VorbisReader reader = new VorbisReader(oggFile)) using (VorbisReader reader = new VorbisReader(oggFile))
{ {
int bufferSize = (int)reader.TotalSamples; int bufferSize = (int)reader.TotalSamples * reader.Channels;
float[] buffer = new float[bufferSize]; float[] buffer = new float[bufferSize];
sound.castBuffer = new short[bufferSize]; sound.castBuffer = new short[bufferSize];
@@ -52,6 +52,8 @@ namespace Barotrauma.Sounds
sound.format = reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16; sound.format = reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16;
sound.sampleRate = reader.SampleRate; sound.sampleRate = reader.SampleRate;
ALHelper.Check();
//alSourceId = AL.GenSource(); //alSourceId = AL.GenSource();
AL.BufferData(sound.alBufferId, reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16, sound.castBuffer, AL.BufferData(sound.alBufferId, reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16, sound.castBuffer,
readSamples * sizeof(short), reader.SampleRate); readSamples * sizeof(short), reader.SampleRate);