Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Issue: Destination array was not long anough when reading mp3 file whit NAudio [16345]

$
0
0
I've got this code

static void Main(string[] args)
{
try
{
Mp3FileReader reader = new Mp3FileReader(@"C:\testAudio.mp3");
long count = reader.Length;
if (count <= int.MaxValue)
{
byte[] info = new byte[count];
reader.Read(info, 0, (int)count);
Console.WriteLine("Succesfull read");
}
else
Console.WriteLine("Could not read");
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}

that prints out the following exception message

System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
at NAudio.Wave.AcmMp3FrameDecompressor.DecompressFrame(Mp3Frame frame, Byte[] dest, Int32 destOffset) in C:\NAudio-Source\NAudio\FileFormats\Mp3\Mp3FrameDecompressor.cs:line 50
at NAudio.Wave.Mp3FileReader.Read(Byte[] sampleBuffer, Int32 offset, Int32 numBytes) in C:\NAudio-Source\NAudio\Wave\WaveStreams\Mp3FileReader.cs:line 338
at Tester.Program.Main(String[] args) in C:\Tester\Program.cs:line 30

I've dowloaded NAudio code and I've been debugging it but I can't find the cause of the error, although, as you can see on the stack trace is in *NAudio-Source\NAudio\FileFormats\Mp3\Mp3FrameDecompressor.cs:line 50*

¿Am I doing something wrong? By the way, it only happens with a few mp3 files, others are read just fine. I'm attaching one of the files that can't be read

Thanx
Comments: Hi! Is there any development regarding this issue? I'm having the same issues that are represented here, I think all of them: 1 - Listening to the file in Windows Media Player either works flawlessly (in some files) or sounds, in fact, like a glitch (in the same frames where NAudio crashes); 2 - Of course I try-catched the Read method in NAudio, but that creates a silence inside the audio, as you would expect; 3 - If I play the file in NAudio once from beginning to end, the glitches sound much more audible and clear; however, if I repeat the problem region over and over again those glitches start to fade away, so I think that this issue might have something to do with the read buffer after all. Thanks in advance! Bruno Coelho

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>