This project has moved and is read-only. For the latest updates, please go here.

ArgumentOutOfRangeException 'count'

Mar 24, 2015 at 11:00 AM
Edited Mar 24, 2015 at 11:03 AM
Hi, I installed the Nuget package yesterday and any attempt to call VorbisReader.ReadSamples() threw an exception complaining about the 'count' argument. I pulled down the source and couldn't see anything wrong with the code so built it and now I don't get that exception. Is the Nuget package somehow out of date?
            using (var vorbis = new VorbisReader(@"c:\tmp\{b3966622-ed14-4fe7-bfa8-53aa8fa54455}.ogg"))
            {
                var buffer = new float[16384];
                int count;

                var buffer2 = new byte[16384 * 2];

                while ((count = vorbis.ReadSamples(buffer, 0, buffer.Length)) > 0)
                {
                    for (int index = 0;
                        index < count;
                        ++index)
                    {
                        var sampleValue = (Int16)(buffer[index] * 32768f);
                        buffer2[index * 2] = (Byte)(sampleRate & 0xFF);
                        buffer2[(index * 2) + 1] = (Byte)(sampleRate >> 8);
                    }
                    // Do stuff with the samples returned...
                    // Sample value range is -0.99999994f to 0.99999994f
                    // Samples are interleaved (chan0, chan1, chan0, chan1, etc.)
                }

            }
Apr 1, 2015 at 10:08 PM
Ah, I can finally reply...

The nuget package has issues with Ogg's "spanned packets" (the packet is spread out across more than one page, generally due to size). Until I release a new version, just use latest source.