When playback ends

Mar 9, 2012 at 12:09 PM

Hi, I have downloaded the newest version of NAudio. But still can't check when playback ends. DirectSoundOut.PlaybackStopped event is triggered after calling Stop() method, not when the file ends.

So how do I know when playback ends?
(Stop() method is not called, insetad, end of wave is reached)

Coordinator
Mar 9, 2012 at 12:12 PM

depends what is in your playback graph. Some WaveStreams / WaveProviders keep returning data no matter whether their source has any input or not. In that case, PlaybackStopped will never happen - it is still playing, just playing silence. What are you passing in to Init?

Mar 9, 2012 at 1:19 PM


I'm passing WaveFileReader or RawSourceWaveStream

Coordinator
Mar 10, 2012 at 9:39 AM

What if you use WaveOut? Do you get PlaybackStopped event then? I don't use DirectSoundOut much myself, but the latest version ought to be raising the PlaybackStopped event.

Apr 24, 2012 at 11:46 AM

Now I'm using waveOut instead od DirectSoundOut. But PlaybackStopped event still doesn't fire, when playback actually ends itself.

Coordinator
Apr 24, 2012 at 12:02 PM

it may be that the waveprovider you gave to waveOut never stops returning data from the Read function. this is quite possible as some streams pad with zeroes. you can simply test it by setting up a loop that reads from your waveprovider and see if it ever exits

Jun 1, 2012 at 1:47 PM

Hi ,

  I am using NAudio playbak for playing I am playing some noise file. This is loop play or single play  I hear a really bad buzz at
the loop edge , ho to resolve this any ideas.

 

Thanks in advance

Jun 11, 2012 at 10:05 AM
markheath wrote:

it may be that the waveprovider you gave to waveOut never stops returning data from the Read function. this is quite possible as some streams pad with zeroes. you can simply test it by setting up a loop that reads from your waveprovider and see if it ever exits


I record sample with using NAudio and then I play it. Come on, there must be some other, normal way to do this.

Coordinator
Jun 11, 2012 at 4:49 PM

the playback stopped event will only fire when playback actually stops. If you send in a never-ending stream you would instead check on a timer if the current position was greater than the length of the file and then stop.

Mark

Dec 3, 2012 at 8:08 AM

Is there a simple way of adding loop utility to wavechannel32 object?

I must use wavechannel32 because I am using pan and volume utilities of wc32.

I have implemented a LoopStream class from waveStream successfully, but I have to use pan and volume properties of wc32.

Which one should I choose in your opinion?

Adding loop (when it lasts, it return to position=0) property to wc32 or adding pan and volume properties to my LoopStream?

Or is there any other way.

NOTE: I do not want to track the position by timer!

Coordinator
Dec 3, 2012 at 4:32 PM

With NAudio you build up a pipeline, so you could pass your LoopStream into WaveChannel32 as the source.