This project has moved. For the latest updates, please go here.

AcmNotPossible calling acmStreamConvert and other errors

Apr 1, 2010 at 5:44 PM

Mark,

I've encountered several different errors with playback of various MP3 files using the demo applications.

These errors include:

  1. AcmNotPossible calling acmStreamConvert
  2. Not a recognised MP3 block
  3. Index out of the bounds of the array

Looking back through previous posts it seems that there was an issue where "AcmNotPossible calling acmStreamConvert" is thrown on mono MP3s due to Mp3FileReader hard coding the number of channels which is fixed in the latest source but the 1.3 download from the main page still has this problem.

The other two errors are present in the latest source.  If you like I can post the MP3 files and full stack traces.

Steve

Coordinator
Apr 6, 2010 at 9:37 AM

yes, MP3 files and stack traces would be useful. I can't promise any fast turnaround though. I have noticed that NAudio cannot play the sample MP3 files that come with Windows 7, but I have no idea what the problem is (some kind of issue parsing the ID3 tag correctly is my guess)

Mark

Oct 31, 2010 at 1:54 PM

Hi Mark,

any news on this topic? I started to use NAudio to play encrypted mp3s on-the-fly, but as soon, as some ID3 info was added, I got exactly the same exception. Was the problem found/fixed?

Pavol

Coordinator
Oct 31, 2010 at 2:48 PM

hi Pavol, have you tried with the latest code? there have been some improvements recently

Mark

Nov 7, 2010 at 12:56 PM
Edited Nov 7, 2010 at 12:58 PM

Hi Mark,

I have a similar problem with MP3s - I'm getting the same exception.

With some MP3s it does not happen at all, with others it happens consistently when I open the file for playing (works fine) but then move the WaveChannel.CurrentTime forward in time. 

Then the exception happens.

I do admire your efforts to write NAudio and it is a great library, but I think it is defective at this point - this is a show stopper. Any MP3 file must be played without exceptions, otherwise the library is not reliable and therefore cannot be used. If WinAmp was to fail on some MP3s nobody would use it.

Please let me know if I can assist you - I have an application and MP3 file that show the problem, and I can provide these to you with full source code so you can debug the problem.

Thanks

Yuval

Edit - I'm using the latest NAudio source code (1.3.12.0)

Coordinator
Nov 7, 2010 at 1:29 PM

Hi Yuval,

I recommend using the latest source code from the Source Control tab as it contains some MP3 improvements. I now can parse MP3 frames reliably, which opens the door for accurate measurement of length of MP3 files, and more reliable repositioning within them. However, my main issue is finding the time to work on this. I'm hoping NAudio 1.4 will have a greatly improved story for MP3.

Mark

 

Nov 7, 2010 at 2:31 PM

Mark,

 

I just download and recompiled the latest source code as you recommended (Filename: naudio-63343.zip).

The exception still happens.

Hopefully you'll find time to figure this out.

The call stack is shown below:

A first chance exception of type 'NAudio.MmException' occurred in NAudio.dllException: NAudio.MmException: AcmNotPossible calling acmStreamConvert   at NAudio.MmException.Try(MmResult result, String function) in c:\naudio\NAudio\Wave\MmeInterop\MmException.cs:line 39   at NAudio.Wave.Compression.AcmStreamHeader.Convert(Int32 bytesToConvert, Int32& sourceBytesConverted) in c:\naudio\NAudio\Wave\Compression\AcmStreamHeader.cs:line 63   at NAudio.Wave.Compression.AcmStream.Convert(Int32 bytesToConvert, Int32& sourceBytesConverted) in c:\naudio\NAudio\Wave\Compression\AcmStream.cs:line 155   at NAudio.Wave.WaveFormatConversionStream.Read(Byte[] array, Int32 offset, Int32 count) in c:\naudio\NAudio\Wave\WaveStreams\WaveFormatConversionStream.cs:line 158   at NAudio.Wave.BlockAlignReductionStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\naudio\NAudio\Wave\WaveStreams\BlockAlignReductionStream.cs:line 148   at NAudio.Wave.WaveChannel32.Read(Byte[] destBuffer, Int32 offset, Int32 numBytes) in c:\naudio\NAudio\Wave\WaveStreams\WaveChannel32.cs:line 151

Thanks,

Yuval

Coordinator
Nov 7, 2010 at 7:35 PM

OK, just did a significant checkin. MP3FileReader now emits PCM so no more need for WaveFormatConversionStream. Keep blockalignmentreduction stream for time being (will remove need for it in a future checkin - currently Read method is naughty and can return more bytes than it was asked for hence the need for it).

If you get a chance to check it out, let me know how you get on.

Mark

Nov 7, 2010 at 11:08 PM

Hi Mark,

Good job! The problem does not seem to replicate.

I did some basic tests but it looks great so far, no crashes and it seems to be more responsive than before.

Just for information: I also tried running the stack as is without changes, before removing the pcm stream converter (WaveFormatConversionStream.CreatePcmStream()), so I had it working redundantly in the stream stack. The exception did not appear again but another exception appeared - NullReferenceException

A first chance exception of type 'System.NullReferenceException' occurred in NAudio.dllException: System.NullReferenceException: Object reference not set to an instance of an object.   at NAudio.Wave.Mp3FileReader.set_Position(Int64 value) in c:\naudio\Wave\WaveStreams\Mp3FileReader.cs:line 244   at NAudio.Wave.BlockAlignReductionStream.set_Position(Int64 value) in c:\naudio\Wave\WaveStreams\BlockAlignReductionStream.cs:line 89   at NAudio.Wave.WaveChannel32.set_Position(Int64 value) in c:\naudio\Wave\WaveStreams\WaveChannel32.cs:line 112   at NAudio.Wave.WaveStream.set_CurrentTime(TimeSpan value) in c:\naudio\Wave\WaveStreams\WaveStream.cs:line 116

This to me has a much lower priority (That stream stack is not 'Normal') , but it does suggest that class MP3FileReader might need some more fixing/sanity checks for that logic.

>> 244:                    mp3Stream.Position = mp3Index.FilePosition;

Anyway, thanks for taking your time to fix this show stopper!

I'll do further testing and let you know how if there's anything else.

 

BTW: You are welcome to check my new Open Source C# application - Practice#. It is a playback utility for practicing musicians that allows changing playback speed (without creating pitch changes) and pitch changes (without affecting speed), which really is not a new concept, just a much better user interface and functionality IMO. The library is written in C# using NAudio and SoundTouch library (C++). It works quite nicely even at an early alpha. I decided to publish the sources today after this show stopper to allow you usage of the utility. This is a pretty good unit tester for NAudio ;)

http://code.google.com/p/practicesharp/

Thanks,

Yuval

Coordinator
Nov 8, 2010 at 6:05 AM

thanks for the feedback Yuval, would you like me to add a link to your app on the NAudio codeplex page?

the null reference was possibly a reposition to outside the range of the file. I'll look into getting that behaving a little better. This blog post describes the current state of MP3 playback support in the latest NAudio code if you want a bit more detail:

http://mark-dot-net.blogspot.com/2010/11/state-of-mp3-playback-support-in-naudio.html

Mark

Nov 8, 2010 at 11:00 AM

No problem, happy to help.

If you don't mind, yes, please add a link to Practice# on NAudio codeplex page.

I've already added a link to NAudio on the google code page.

 

Wow - I'm very impressed with the last MP3 changes you've made. You seemed to get to the bottom of this problem, which is great and as I understand it 'killed two birds' in one shot - now NAudio is more stable, simpler to use and a faster IMO.

 

The Null reference does not bother much me right now, as it only happened when using the original stream stack, but I will report back any issues I find.

 

Thanks!

Yuval

Nov 9, 2010 at 12:49 AM

Hi Mark,

I tested again and this problem indeed happens every time I put the file position pointer beyond the file maximum duration.

So I've put a workaround to it: (Temporary fix, but should hold until the next version is out)

if (m_newPlayTime > m_filePlayDuration)   m_newPlayTime = m_filePlayDuration.Subtract( new TimeSpan( 0, 0, 0, 0, 100 ) );

 

 

Thanks,

Yuval

Coordinator
Nov 9, 2010 at 6:13 AM

have you tried again with the very latest code? I tried to put a fix in for your issue already

Mark

Nov 9, 2010 at 10:48 AM

Just tried again with latest source - so far looks fine, thanks!

Yuval