This project has moved and is read-only. For the latest updates, please go here.

Is it possible to set the size of read sample buffer

Aug 21, 2010 at 2:35 PM

I am using naudio to generate pulse width modulation audio signals for controlling a pair of servo's.  Currently I am using the WaveProvider32 class that Mark Heath wrote ( which implements the IWaveProvider interface. The sample rate is 44100

The audio signal is basically a block N wide where the first part of the signal all the values are high, and for the remainder of the block the values are low.  Since the Read operation asks for more samples than the width of the block I just repeat the signal until I fill up the buffer.  The problem I have is that the length of the buffer is not a multiple of the width of my signal block, so part of the last block is cut off which screws with the servo and makes it twitch.  I realize I could do some code fanciness to keep track of it and offset the beginning of the next read, but I would be easier if I could set the number of values that WaveProvider had to provide at once so that I could make it a multiple (or maybe the exact width) of the signal block size.

Is that possible?

Sep 6, 2010 at 12:17 PM

the read size is determined by the latency of the playback device. You could fiddle with that (look at the WaveOut class) to see if you can force it to be the right size.