472,958 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

How to convert any audio format to mp3 using NAudio

Expand|Select|Wrap|Line Numbers
  2.  public void AudioConvert(){
  4.  FileStream fs = new FileStream(InputFileName, FileMode.Open, FileAccess.Read);
  6.  NAudio.Wave.WaveFormat format = new NAudio.Wave.WaveFormat();
  8.  NAudio.Wave.WaveStream rawStream = new RawSourceWaveStream(fs, format);
  10.  NAudio.Wave.WaveStream wsDATA = WaveFormatConversionStream.CreatePcmStream(rawStream);
  12.  WaveStream wsstream = wst.CanConvertPcmToMp3(2, 44100);
  14.  .....
  15.  }
  17. // Here is the class 
  18. public class WaveFormatConversionStreamTests
  19. {
  20.     public WaveStream CanConvertPcmToMp3(int channels,int sampleRate)
  21.     {           
  22.       WaveStream ws = CanCreateConversionStream( new WaveFormat(sampleRate, 
  23.                                                  16, channels),
  24.       new Mp3WaveFormat(sampleRate, channels, 0, 128000/8));
  25.       return ws;
  26.     }
  27. }
Here, i am trying to convert any audio format to mp3 but my code is throwing exception like "ACMNotPossible" at ConvertPCMToMp3 function call. I am using NAudio 1.6 version dll. Right now i am working on windows 7. Please correct me where i went wrong in this code.
Aug 3 '13 #1
1 10472
12 Byte
How do I convert audio Format to MP3?
How to Convert Audio Files to MP3
Insert the audio CD into your computer's CD drive.
Click on the arrow below the Rip tab on the Windows Media Player menu.
Select the option to change the format to MP3.
Click Rip and the file will be loaded as MP3 [source: Microsoft].

Jul 26 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: dreamer | last post by:
I am making a program for a friend with a disability. I need to adjust his audio volume using the keyboard as he cannot use a mouse. Any suggestions as to how I can raise the volume using the up...
by: bonnie.tangyn | last post by:
Dear all In my ASP page, user can enter date in dd/mm/yyyy format. How can I use Javascript to convert dd/mm/yyyy to yyyy-mm-dd hh:mm:ss. Please give me some advices. Cheers Bon
by: svnlakshmi | last post by:
Pls help me out in this aspect--How to convert a binary file to a file in text format using C?
by: thomasc1020 | last post by:
This is regarding VB.NET 2003. Variable 'Date' is a string and it contains date information in this format: "DEC/05/2007". Now I am trying to convert the format as "2007-12-05". Is it...
by: VinDiesal | last post by:
Hi Buddies, I want the Sample source code about How to convert Dss audio format to wav format in .net. Please anybody send the source code for this.
by: mailtosantoshkumar | last post by:
Hi Buddies, I want the Sample source code about How to convert Dss audio format to wav format in .net. Please anybody send the source code for this.
by: BeMe | last post by:
I'm programming a project in C# that uses audio classes I would like to know information about audio in .net: 1. someone records a specific sound and I need to covert it to data that means let say...
by: Nert | last post by:
Hello there., i have this problem converting an flv video format to 3gp format using ffmpeg so that i can put the video on my cellphone. Well actually i have successfully converted the video to...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.