473,511 Members | 16,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert any audio format to mp3 using NAudio

sainathsagar
7 New Member
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 11146
Willjoe
12 New Member
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
19092
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
162618
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
2249
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
4508
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
1281
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
1203
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
1714
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
10610
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
7138
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
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.