I was having an issue with WaveformPainter throwing System.ArgumentOutOfRangeException when i resized my window (From bigger to smaller). I've been writting a VOIP server/client using naudio and nspeex and its working great, thanks for this great library!
To duplicate the exception you have to resize the control from big to small, and the amount audio displayed needs to be greater than what can be shown when its resized. If that makes sense, haha...
Anyway I added one like to the AddMax function...
the change
if (insertPos < maxSamples)
samples[insertPos] = maxSample;
the function with change
public void AddMax(float maxSample)
{
if (maxSamples == 0)
{
// sometimes when you minimise, max samples can be set to 0
return;
}
if (samples.Count <= maxSamples)
{
samples.Add(maxSample);
}
else
{
if (insertPos < maxSamples)
samples[insertPos] = maxSample;
}
insertPos++;
insertPos %= maxSamples;
this.Invalidate();
}
Now I dont get the exception and the WaveformPainter keeps painting normally after resizing the control. (From bigger to smaller)