White noise on one channel and distorted on another when loading sounds

Jan 20 at 8:20 AM
Hi Guys,

As the title says I am coming across some issues when I am trying to load in OGG sounds into openAL, I am currently am getting a large amount of white noise in one channel and heavily distorted sound in the other channel.

Here is a the code that I am using to generate the data to pass into "AL.BufferData"
          case Extension.OGG: SoundData = Ogg.LoadOgg(s, out channels, out bits, out sample); break;

                Channels = channels;
                Bits = bits;
                SampleRate = sample;
                switch (channels)
                {
                    case 1:
                        SoundFormat = (bits == 8 ? ALFormat.Mono8 : ALFormat.Mono16);
                        break;

                    case 2:
                        SoundFormat = (bits == 8 ? ALFormat.Stereo8 : ALFormat.Stereo16);
                        break;

                    default:
                        throw new NotSupportedException("The specified sound format is not Supported.");
                }
                BufferID = AL.GenBuffer();
                AL.BufferData(BufferID, SoundFormat, SoundData, SoundData.Length, SampleRate);
internal static Byte[] LoadOgg(Stream stream, out Int32 channels, out Int32 bits, out Int32 rate)
        {
            using (VorbisReader reader = new VorbisReader(stream, false))
            {
                Single[] buffer = new Single[reader.TotalSamples];
                Int16[] castBuffer = new Int16[reader.TotalSamples];
                Int32 count = reader.ReadSamples(buffer, 0, buffer.Length);

                Byte[] byteArray = new Byte[buffer.Length * 4];

                channels = reader.Channels;
                bits = 16;
                rate = reader.SampleRate*2;

                Buffer.BlockCopy(buffer, 0, byteArray, 0, byteArray.Length);

                return byteArray;
            }
        }
Jan 27 at 7:45 AM
I have discovered that the issue was the way that I was copying to buffer data into a byte array. I have since fixed the issue :)