Audio Conversion C#

╄→гoц情女王★ 提交于 2019-12-11 03:25:23

问题


What is the best way to convert various audio formats to PCM?

For example: mp3, evrc, ogg vox.

Is there a library out there that will allow me to implement this relatively easily?

EDIT:

I guess my initial question wasn't really what I needed. Most of the libs I have found are file converters. What I need is a block converter, where I pass in a 1Kb block of vox data and it returns its converted PCM block. Of course I’ll have to tell the converter what type of data it is and various pieces of codec information.

The solution I am going for is to save and VOIP formats into a common wav format and to play that conformed file in real time. I thought there should be an easy way to do this because all audio is eventually turned into PCM before it is outputted anyways.


回答1:


You can use NAudio to pass blocks of compressed audio into any ACM codecs you have installed on your machine. You do need to know how to create the appropriate WAVEFORMAT structure to describe the compressed audio type correctly though.




回答2:


Check out AVBlocks SDK for .NET. It supports several audio formats, and audio transforms like Multi-channel audio to Stereo audio, resampling and bitrate conversion.




回答3:


Try modified code from http://alvas.net/alvas.audio,tips.aspx#tip91

    static void AnyToWav(string fileName)
    {
        DsReader dr = new DsReader(fileName);
        IntPtr formatPcm = dr.ReadFormat();
        byte[] dataPcm = dr.ReadData();
        dr.Close();
        WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), AudioCompressionManager.FormatBytes(formatPcm));
        ww.WriteData(formatPcm);
        ww.Close();
    }



回答4:


Don't know any lib that does it all but we do mp3->wav using madxlib.

It's free but I suggest paying the $10 for the sdk as it comes with documentation and examples.




回答5:


There is a c# tutorial on youtube that might be helpful to you. It shows how to use a specific audio library called alvas.audio that really does some neat things with audio. I found the video to be very educational. The audio library is completely written in c#. Watch the video for more details: http://www.youtube.com/watch?v=2DIQECXFPeU



来源:https://stackoverflow.com/questions/1295546/audio-conversion-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!