Loop Stream issue while playing lengthy audio file

Nov 5, 2015 at 6:10 AM
Edited Nov 6, 2015 at 12:42 PM
Hi,

I am facing an issue with offset parameter and i am getting the exception as Argument Out of Range exception and parameter is Offset.

public class VPWaveSource : SampleSourceBase
{
   public override int Read(float[] buffer, int offset, int count)
    {
        int samplesRead = 0;
        try
        {
            samplesRead = base.Read(buffer, offset, count);
            for (int n = 0; n < samplesRead; n += 2)
            {
                buffer[n] *= LeftVolume;
                buffer[n + 1] *= RightVolume;
            }
        }
        catch(ArgumentOutOfRangeException ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
        }
    }
}

Implementation of VPWaveSource:
        VPWaveSource vpWaveSource = new VPWaveSource(waveSource.ToSampleSource());
        LoopStream stream = new LoopStream(vpWaveSource.ToWaveSource());
        _soundOut.Initialize(stream);
        Thread playThread = new Thread(_soundOut.Play);
        playThread.Start();

What is the expected value of offset to avoid the exception.


Thanks & Regards,
Siva.
Coordinator
Nov 9, 2015 at 6:08 PM
I'm sorry, but cscore moved to the https://github.com/filoe/cscore please, post your question on github. Codeplex is not longer in use.
Also please provide a stacktrace of the exception. That would help me a lot.