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

Chaining WaveStream objects and WaveFormat conversions

Dec 23, 2010 at 3:33 AM

Hi, many thanks for the great library!  I've just started using it and I have a few questions. 

My application is placing various wav sounds (read from wav files) into a "master" output file at various locations.  I allow the user to specify the Pan, Volume and Time when placing the input into the output mix.  Also the input files may be of different wav formats (e.g. 16-bit/32-bit, float/pcm, and so on).

So far the approach I'm using is to read them in using WaveFileReader, pass that into a WaveChannel32 to control Pan/Volume and convert them to 32-bit float.  Then I create a WaveOffsetStream to specify the Time offset, and add that to a WaveMixer32 to generate the output file.

However, the problems I've hit are:

1) If the input is already 32-bit the WaveChannel32 rejects it (it only accepts 16-bit PCM)

2) The WaveOffsetStream only accepts PCM, so I'm having to down-grade the input back to 16-bit PCM

3) the WaveMixer32 only accepts 32-bit float, so I have to re-upgrade it back up to 32-bit float to add it here.


So far my naive approach for #2 and #3 above is to simply convert them in between steps using Wave32To16Steam and WaveChannel32 as needed.  But this seems like alot of unecessary conversions and extra code to deal with.  Is there a simpler way to do this, or would it be beneficial for me to create additional WaveChannelNN classes to handle the various types of input?  I would be happy to contribute any additional wav stream classes I come up with, if they fit into the architectural model you have in mind.

I suppose another solution would be to change the order of operations such that I read the file, add it to the WaveOffsetStream (still in original format), and *then* create a WaveChannel32 to alter the volume/pan.  However, I currently let the user preview the altered sample before adding it to the output so I would have to do that separately. Also this does not solve the problem #1 above.

Any input would be greatly appreciated.  Again, thank you for providing this nice library! 





Dec 24, 2010 at 10:10 AM

The original classes were written to put the WaveOffsetStream before the WaveChannel32. Seems like you might need to make your own WaveOffsetStream and WaveChannel32 stream that can accept 32 bit input (should be quite easy to write based on the existing ones)


Dec 24, 2010 at 3:45 PM

Mark, thanks for the reply.  Yes I think I may take that approach. I'm playing with some different ideas at the moment.

Another question is what (if any) of the existing classes would be best if i want to generate a sample programmatically?  In this case I really just need to manipulate the raw byte/float buffer and somehow inject it into a stream.  Any suggestions?


Dec 29, 2010 at 9:36 AM




Dec 30, 2010 at 1:58 AM
Thank you for the link! Do you know if there a built-in way to feed a IWaveProvider into a WaveStream? In this case I need to output it to a wav file.

On Wed, Dec 29, 2010 at 5:36 AM, OpenSebJ <> wrote:

From: OpenSebJ

Read the full discussion online.

To add a post to this discussion, reply to this email (

To start a new discussion for this project, email

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at

Jan 4, 2011 at 9:43 AM

IWaveProvider is a more lightweight version of WaveStream - it doesn't report length or position and can't reposition. The NAudio library hasn't yet been fully updated to support IWaveProvider everywhere, but it is not hard to make your own adapter if necessary, or modify existing classes to work with IWaveProvider instead of WaveStream