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

onPlaybackStopped not being called

Jun 24, 2014 at 7:43 PM
ok I convert my WaveProviderbuffers to Waverstreams
I use that to make a WaveChannel32.
and I set PadWithZeroes = false, but the the stop event is still not being called .

side note If i play without a file or an file with an effect without a tone in WaveProviderbuffers, the stop event is called, so that does work.

What am I missing?
 WaveProviderToWaveStream wptws = new WaveProviderToWaveStream(Sinebuffer, Sinebuffer.BufferLength);
                WaveChannel32 temp = new WaveChannel32(wptws);
                temp.PadWithZeroes = false;
the tone does stop playing at the time I set, but the stop event is still not being called
Marked as answer by btb4198 on 6/26/2014 at 11:03 AM
Jun 25, 2014 at 12:00 AM
markheath is there something else doing PadWithZeroes?
is something else adding zero that I do not know about?
if so can you please tell me here I should turn it off?
Jun 25, 2014 at 12:10 AM
i was looking at the source code for WaveProviderbuffer and it say
/// <summary>
/// Provides a buffered store of samples
/// Read method will return queued samples or fill buffer with zeroes
/// Now backed by a circular buffer
so does that mean that after the my samples are done it will start adding zeros?
if so how do I stop it ?
Jun 25, 2014 at 6:29 AM
Yes, BufferedWaveProvider always returns the number of bytes asked for in Read, with extra silence if needed. The reason it works this way is it is intended for playing audio that comes in over the network or from a microphone and so there may be small gaps in available data to play. If your source is originally from a file, BufferedWaveProvider shouldn't be used.

But it's really easy though to make your own that works how you want. Just copy the code from BufferedWaveProvider and change the Read method.

Maybe it can be an optional feature for a future NAudio
Jun 26, 2014 at 6:03 PM
so I redid my classes and they all inherit from waveform now. I removed BufferedWaveProvider and i have this in all my classes :
if (n2 >= Bufferlength && stopflag == false)
            return 0;
bufferlength have the number of samples need for the time frame I am looking for
and it you use
and then return 0;
the program will call the onPlaybackStopped event
so it will pay the tone I make and stop at the need time.

thank for the help