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

Converting WAVs to AIFFs

Nov 11, 2012 at 7:55 PM

I'm trying to convert from .wav to .aiff and notice there is an example of how to convert a .aiff to .wav using the AiffFileReader but there doesn't appear to be an AiffFileWriter which I'd hoped there would be.

Is there a way to use NAudio to convert .wav files to .aiff files?

Coordinator
Nov 12, 2012 at 6:28 AM

Unfortunately there is no AiffFileWriter in NAudio. If someone were to contribute a working one to the project I would be glad to include it. You may be able to work out how to create one yourself by examining the code for the reader.

Mark

Nov 12, 2012 at 6:54 AM

Thanks for the prompt response Mark, I'll take a look at that

Nov 22, 2012 at 10:17 PM

Hi Mark and Keith,

You're more than welcome to use the AiffFileWriter that I wrote, which is here:  http://giawa.com/tutorials/src/AiffFileWriter.cs

It depends on an IEEE floating point library, which is here:  http://giawa.com/tutorials/src/IEEE.cs

The AiffFileReader currently included with NAudio has its own IEEE floating point conversion methods (I wrote it before the AiffFileWrite, so I didn't think to put it in its own static class).  It should be pretty straight forward to consolidate the whole thing to work with the IEEE.cs provided.

Hope this helps,

Giawa

Nov 23, 2012 at 7:53 AM

Much appreciated!

Coordinator
Nov 23, 2012 at 8:07 AM

hi Giawa, this is brilliant. I'll try to get this into NAudio for v1.7

thanks so much

Mark

Coordinator
Nov 23, 2012 at 12:35 PM

I've committed the new class, although haven't had a chance to test it yet. Any chance you could do a quick code review for me. The change is here.

many thanks for this contribution.

Mark

Nov 26, 2012 at 9:20 PM
Edited Nov 26, 2012 at 9:20 PM

Hi Mark,

I built the latest source and quickly tested both the AiffFileReader and AiffFileWriter.  Seems to work well!  Here's some quick example code to test out the new writer.

OpenFileDialog open = new OpenFileDialog();
open.Filter = "WAVE File (*.wav)|*.wav;";
if (open.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

SaveFileDialog save = new SaveFileDialog();
save.Filter = "AIFF File (*.aif)|*.aif;";
if (save.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

AiffFileWriter.CreateAiffFile(save.FileName, new WaveFileReader(open.FileName));

Cheers,

Giawa

Coordinator
Nov 27, 2012 at 12:09 PM

that's great. thanks again