I get a "from must not equal to." Argument exception
when trying to set Position of a IWaveSource and then initializing it.
I assume that mean's the position is greater than the length of the audio file, but that is impossible if I can trust my console output using this:
Console.WriteLine(startTime + "/" + soundSource.Length);
soundSource.Position = startTime;
soundOut.Initialize(soundSource);
Tells me:
30293491/45365376
So the position should be fine and below the max, and is definitely not equal to current position.
Any information on that?
Edit:
Further research brought me to the exception source:
public static ChannelMatrix GetMatrix(ChannelMask from, ChannelMask to)
{ if (from == to)
throw new ArgumentException("from must not equal to.");
But I can't really do anything with that information, "Channel matrix" is beyond my skills.
EDIT2:
Ironically, using the newest cscore from github, compiling that
and in Extensions.cs adding a try/catch to the code below, catches a new issue of github-version and makes skipping work.
(ORIGINAL:
internal static byte[] ReadBytes(this IWaveSource waveSource, int count)
{
if (waveSource == null)
throw new ArgumentNullException("waveSource");
if (count <= 0 || (count % waveSource.WaveFormat.BlockAlign) != 0)
throw new ArgumentOutOfRangeException("count");
byte[] buffer = new byte[count];
int read = waveSource.Read(buffer, 0, buffer.Length);
if (read < count)
Array.Resize(ref buffer, read);
return buffer;
}
)
(NEW:
internal static byte[] ReadBytes(this IWaveSource waveSource, int count)
{
try
{
if (waveSource == null)
throw new ArgumentNullException("waveSource");
if (count <= 0 || (count % waveSource.WaveFormat.BlockAlign) != 0)
throw new ArgumentOutOfRangeException("count");
byte[] buffer = new byte[count];
int read = waveSource.Read(buffer, 0, buffer.Length);
if (read < count)
Array.Resize(ref buffer, read);
return buffer;
}
catch(Exception e)
{
byte[] buffer = new byte[1];
int read = waveSource.Read(buffer, 0, buffer.Length);
if (read < count)
Array.Resize(ref buffer, read);
return buffer;
}
}
)