Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Convert X to Y

$
0
0
I would like to convert any (supported ofcourse) audio format I can throw at NAudio to any (supported ofcourse) audio format NAudio can write. So I might throw a wavefile, mp3 or aiff file at it, specify the output filename and some parameters (samplerate, bit depth, channels) and have NAudio do the heavy lifting / figure out what to do exactly.

There is a AudioFileReader which is supposed to read all supported filetypes but there is no AudioFileWriter, is there?

I guess I need to read the input, convert it to "raw audio" at the input's samplerate/bits/channels and then output it thru some writer? I assume I would need the WaveFormatConversionStream for this?

Because my input and desired output are specified by the user I don't want to have all kinds of ConvertXXXToYYY() methods but one method that handles the conversion. I was hoping something along the lines of:
using (var reader = new AudioFileReader(inFile))
using (var resampler = new WaveFormatConversionStream(waveFormat, reader))
{
    AudioFileWriter.CreateFile(outFile, resampler);
}
(This is just a mockup). Is it possible to achieve this without writing lots of code?

Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>