473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to convert any audio format to mp3 using NAudio

sainathsagar
Expand|Select|Wrap|Line Numbers
  1.  
  2.  public void AudioConvert(){
  3.  
  4.  FileStream fs = new FileStream(InputFileName, FileMode.Open, FileAccess.Read);
  5.  
  6.  NAudio.Wave.WaveFormat format = new NAudio.Wave.WaveFormat();
  7.  
  8.  NAudio.Wave.WaveStream rawStream = new RawSourceWaveStream(fs, format);
  9.  
  10.  NAudio.Wave.WaveStream wsDATA = WaveFormatConversionStream.CreatePcmStream(rawStream);
  11.  
  12.  WaveStream wsstream = wst.CanConvertPcmToMp3(2, 44100);
  13.  
  14.  .....
  15.  }
  16.  
  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. }
  28.  
  29.  
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 11025
Willjoe
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].


Regards,
Will
Jul 26 '22 #2

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

Similar topics

3
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...
10
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
1
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?
4
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...
0
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.
1
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.
6
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...
2
Nert
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.