I try to convert a .wav file to a .mp3 file using C# and Mono.
I found this link which might be helpful.
When I use the following code to convert, I miss a libsndfile.dll. So I searched my harddrive and found it, but using it I get the message that it is not a valid .NET assembly.
AumpelWrapper wrapper = new AumpelWrapper ();
_wrapper.Convert (filePath, (int)SoundFormat.WAV, targetPath, (int)SoundFormat.MP3);
Is there another way to convert wav to mp3 or do I need another library, that this will work?
I want to use that in our company, so it needs to be OK with the license.
Related
I'm working on a program (C#) to convert an MP3 file to MIDI, but I have a problem with converting it. How should I do?
Is there any library to generate MIDI from MP3 file
Thank You
It seems that it is not a converter. It seems that you need some complicated process to generate a MIDI from an MP3 file. There are some useful discussions in the following links:
https://www.codeproject.com/Questions/992205/How-do-I-convert-an-mp-wav-file-to-midi-in-vb-net
https://www.gamedev.net/forums/topic/505842-writing-a-module-to-convert-mp3-to-midi-files/
I am currently having a probelm, where a file was sent to me as .m4a and I renamed it to .wav..... (I think that is the issue as I can play other .wav files)
Now it is giving me this error when I run the code:
Additional information: The file located at c:\Windows\Media\dj.wav is not a valid wave file.
Maybe I just need to change it back to .m4a and then have some website convert it to .wav compared to me just renaming it?
My code looks like this:
using System.Media;
playSimpleSound();
private void playSimpleSound()
{
SoundPlayer simpleSound = new SoundPlayer(#"c:\Windows\Media\dj.wav");
simpleSound.Play();
}
Also, how can I write my path, so that it would hit the file in the debug folder? Because I am going to deploy this to a thin client in another building.
Changing the extension of a file does not change the content in it. M4A are MPEG-4 audio-only data, whereas WAV files are typically raw and uncompressed audio samples.
To convert the data itself, you'll need to use an audio transcoding tool like SoX or GoldWave.
As for your path specifier, you can simply use "dj.wav" or "wavfiles\dj.wav", basically relative to where your exe sits. This is because the current working directory is set to where it resides when started with a simple double click in explorer. You can, however also specify the full path using the answer here.
Hope this helps!
I want to develop a desktop application by programming in C# and using the .Net framework 4.
The goal of my application is to extract a MP3 audio stream from a supplied AVI file.
I have learned from the Internet that an AVI file is a container and it might contain different audio streams.
If the supplied AVI file contains one MP3 audio stream at least then I want to extract it and split it.
I want to split the MP3 audio stream into MP3 audio parts identified with a start time and an end time.
I have looked on the Internet for any .Net library I could use but without success.
Does someone know what documented .Net library would be useful ?
Maybe you can try this:
Simple C# Wrapper for the AviFile Library
It is targeted at AVI video but there might be some clues as how to use the same methods to extract the audio only.
Either use it as-is or use the example to incorporate what you need into your own code.
Since tools for this task already exist, I see no point in creating another one unless you're curious about how to do this yourself and learn something new.
If so, using a ready-made library would defeat the entire idea of learning something which is why I strongly recommend you try implementing the splitter yourself.
You can find descriptions of the AVI file format online, that should get you started.
Having failed to find a way to programmatically convert a CCITT u-Law wave file to a PCM file (which Soundplayer demands) in accord with this question: How to play non-PCM file or convert it to PCM on the fly ?
(SOX looks like it might work, but I can't find any examples for converting from CCITT u-Law .wav file to a "regular" (PCM) .wav file using it from C#),
I wonder if I'm going about it the wrong way: maybe I should find a way to play CCITT u-Law .wav files, rather than trying to convert such to a PCM .wav file.
Does anybody know how this is possible? SoundPlayer always says, "Sound API only supports playing PCM wave files" so maybe there's another API I can use?
Note: Alvas.Audio is also "not an option" due to it not being free or open source.
The way to do it is to use newkie's code at: http://www.codeproject.com/Articles/175030/PlaySound-A-Better-Way-to-Play-Wav-Files-in-C?msg=4366037#xx4366037xx
In my case, at least, I had to change all of the lowercase x's to uppercase x's, though, to get it to work.
I'm doing a sample which will run mp3 files which are selected by the user. I
want to calculate the playing time of the file (e.g. 00:05:32). How can I calculate the playing time?
You could use TagLib Sharp
It exposes TagLib.AudioProperties.Duration
For Alvas.Audio library see code below
using (Mp3Reader mr = new Mp3Reader(File.OpenRead("len.mp3")))
{
int durationMS = mr.GetDurationInMS();
TimeSpan durationTS = TimeSpan.FromMilliseconds(durationMS);
}
You suggest in the tag that you're doing this in C#. This question deals with it:
Finding MP3 length in C#
And there's some code for reading the MP3 header and extracting relevant information (like the length) here:
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=79
I believe the Windows Media API (or windows mixer api or something, I can't recall the exact name) has a way to open and read sound files like mp3 and maybe get the time from it too. As an added bonus, by using that API you can open any audio format that will work in say Windows Media Player, so you're not limited to just mp3's.