converting multi-channel ogg to stereo wav file? RRS feed

  • Question

  • hi guys.

    I have to do the following:

    1 - read in a multi-channel ogg audio file of varying sizes, sample rates, and channels

    2 - cut it into a 30 second clip, convert to a 2-channel 20050Hz file, add a fade-in and a fade-out, and export as ogg again

    I know there's no way to do all of that in one go, so I'm trying to convert to wav, do the edits while on wav format, then export to ogg at the end.

    So right now i'm at the step of converting the ogg file to a WAV file. But i'm stuck. The code samples I found online lead me to use the following code. But it crashes the form without any error message.

    var audio_ogg = new NVorbis.NAudioSupport.VorbisWaveReader(ogg);
    var target = new WaveFormat(20050, 16, 2);
    var audio_wav = new WaveFormatConversionStream(target, audio_ogg);

    Using 1-4 to represent the lines, I can say that after #1 I can test by printing out the ogg file's channels, sample rate, etc, and it's read correctly. After #3, if I try to print the same info that I can print for #1, the form crashes. It also crashes if I let it go to #4, but I assume that's become audio_wav is not being created correctly.

    Why isn't this working? Or do you have another way I can achieve what I need to?


    Monday, September 9, 2013 7:21 AM


All replies

  • Hi,

    NVorbis is a 3rd-party project, and it seems to be a problem inside this component. I suggest that you post your question in this discussion page:http://nvorbis.codeplex.com/discussions, or maybe you could download the sourcecode and debug your project with it to analysis the problem.

    I did some searching and found that there's little information about how to convert ogg file to wav file in C#. Maybe you need to use some other software to do this instead of coding by yourself. Please see: http://www.convertfiles.com/convert/audio/OGG-to-WAV.html.

    Related links:



    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Caillen Tuesday, September 17, 2013 1:30 AM
    Tuesday, September 10, 2013 12:59 PM
  • Hi, I know this is an old question, but figured I'd post what I did to get it working just in case someone else has the same issue (I just got the latest nuget of NAudio.Vorbis):

    using NAudio.Wave;
    using NAudio.Vorbis;
    using (VorbisWaveReader vorbisStream = new VorbisWaveReader("PathToInput.ogg"))
      WaveFileWriter.CreateWaveFile("PathToOutput.wav", vorbisStream);

    • Proposed as answer by juanventer Monday, June 11, 2018 10:25 AM
    Monday, June 11, 2018 7:16 AM