open audio formats and audio synthesis using NAudio - c#

How can I open different audio formats(except .mp3 and .wav) using Naudio and C#?
How can I create audio synthesis unsing Naudio and C#?(I mean how to get the sound frequency and other data necesary for audio synthesis).
P.S. I've looked at this tutorial series
http://opensebj.blogspot.com/2009/02/introduction-to-using-naudio.html
and this one
http://www.giawa.com/tutorials/?p=19o

In addition to MP3 and WAV, NAudio can also open AIFF and WMA files with the AiffFileReader and WmaFileReader classes. Beyond that, you will have to write your own WaveStream derived class to read other formats.
See my tutorial on how to play a sine wave in NAudio, which will show you the basics of how to get started with audio synthesis in NAudio.

Related

How to output wav file to microphone input using NAudio in C#

I found NAudio Library during making simple audio editor program.
I want to output wav(*.wav) file to microphone input stream.
This is not something natively supported by Windows Audio APIs, and so NAudio isn't able to help you with this. You need an audio 'loopback' device driver like this, or physically connect an output of your soundcard to an input with an audio cable.

C# Video Streaming

I'm developing a C# video streaming application using NReco library. At this moment I was able to encode audio and video separately and save data in to queue. I can stream video using UDP protocol without audio and it played nicely in ffplay equally I can stream audio using UDP protocol without video and it also played nicely.Now I want to merge these two streams in to one and stream through UDP protocol and player should play both audio and video. But I have no idea how to do it. I would appreciate if some one can give me any points to do this or any other different method achieve this.
Thank You.
The answer highly depends on the source of video and audio streams. NReco.VideoConverter is a wrapper to FFMpeg tool and it actually can combine video and audio streams (see filters configuration in FFMpeg documentation) if either video or audio input can be specified as ffmpeg input source (UDP stream or direct show input device).
If both video and audio data represented by byte stream in your C# code you cannot pass them together using NReco.VideoConverter (ConvertLiveMedia method) because it uses stdin for communicating with ffmpeg and only one stream can be passed from C# code.

Loading mp3 to AudioClip at runtime in Unity

How can I load mp3 file from filesystem to AudioClip object?
I can load ogg or wav using WWW class, and play it with Audio Source component, but on Windows mp3 is not supported.
Or use an external library, like NAudio. But I'm using AudioSource.GetSpectrumData() to visualize some game elements, and can't find similar method in NAudio.
What should i use to play audio from file, and analyze it?

Playing an MP3 with LAME

I'm looking into making a desktop music player, probably in C# (not certain yet), and for MP3 support I would like to use LAME for various quality and other reasons. I am used to coding in Java and as such have only used Java libraries with Java and don't quite understand how to use LAME to play an MP3 in my program.
I have used lame.exe on the command line to decode an MP3 to WAV (lame.exe --decode "filename.mp3") but don't see how I can play an MP3 with LAME nor how to do it in a program (i.e. not using command line).
Do I have to be using C to use the LAME library?
Also do I have to decode the MP3 first before playing?

Extract wav file from video file

I am developing an application in which I need to extract the audio from a video. The audio needs to be extracted in .wav format but I do not have a problem with the video format. Any format will do, as long as I can extract the audio in a wav file.
Currently I am using Windows Media Player COM control in a windows form to play the videos, but any other embedded player will do as well.
Any suggestions on how to do this?
Thanks
If you want to do this with C#, take a look at NAudio library. It can analyze the audio format (like FFMpeg) and also provide the audio stream. Here's one example.
Snippet from the sample:
using NAudio.Wave;
using System.IO;
...
// contentAsByteArray consists of video bytes
MemoryStream contentAsMemoryStream = new MemoryStream(contentAsByteArray);
using (WaveStream pcmStream =
WaveFormatConversionStream.CreatePcmStream(
new StreamMediaFoundationReader(contentAsMemoryStream)))
{
WaveStream blockAlignReductionStream = new BlockAlignReductionStream(pcmStream);
// Do something with the wave stream
}
Here is a link on how to extract audio using GraphEdit, GraphEdit is an front end UI for the DirectShow API so everything it can do you can do with API.
You can use the DirectShow.NET liberty which wraps the DirectShow API for the managed world.
Probably easiest to use ffmpeg for this kinda thing...
Very easy with FFMPEG! I routinely do this to grab audio out of downloaded youtube videos, convert music downlaods to WAV for editing, etc etc. It should work for any file extension:
ffmpeg -i source-of-any-file-extension.avi -vn -ar 44100 -ac 2 -ab 768000 -f wav target-filename.wav

Categories

Resources