I am looking to create an application that will allow me to record from my mic and playback the recording through other pc's. At this point however I would just like it to play back on my own computer so I can get it working.
I have been looking at NAudio for the past few hours and it seems like it may be able to help me achieve this goal.
I am just wondering if anyone else has had any experience with this and if it is at all possible?
Thanks,
Stuart
There is an example project on codeproject doing this:
http://www.codeproject.com/KB/cs/Streaming_wave_audio.aspx
I don't know how low the latency is.
As a codec I'd recommend Speex(at least for speech). It's free, open source and offers low latency and low bandwidth.
Bass Audio Library is another solid option worth looking into.
It is possible to do, but you are unlikely to get low latency with WaveIn/WaveOut (possibly better results with WASAPI). You could use the BufferedWaveProvider (in the latest source code) to store up the audio being recorded from the microphone and supplying the output to soundcard.
NAudio is great as a starting point for audio capture and playback but as Mark pointed out the latency might be an issue.
If you take the next step and want to sent the audio data across the network you will need a codec to compress the data as PCM or WAV are uncompressed and for voice you only need a small part of the bandwidth needed for WAV.
As you are working with C# there is a C# port of Speex available, called NSpeex, which might be worth having a look at..
Related
I want to programmatically be able to connect to my computer's audio output (the exact same thing I'd hear if I plugged my headphones into the side of my laptop) and collect the audio.
So far, I haven't really been able to find anything that does this, other than Core Audio APIs, and even then it seems better built for simply locating sound files and encoding/unencoding then.
I've also taken a look at NAudio, however this seems better suited, again, for sound files. The one bit of streaming it is able to do, is only uses a URL as the source.
Can anyone point me to a library or interface within the .Net framework that will allow me to simply connect to my computer's audio out function and collect a stream of data?
In NAudio, you can capture the audio being played on your system with WasapiLoopbackCapture.
I want to develop an Audio Monitoring Software, for example to know how many ads of certain company where published on x radio station ?
There is any way to analyse "realtime" the audio stream and detect when any version of an ad is played on the radio?
Or the best way is to analyse every x seconds the audio fragment, if this is the way to go, what can I do to know if only a segment of an audio has the sample audio (for example analyse 20 minutes of radio and return true if the spot (ad) where player in that audio sample)
(Sorry for my English, I hope is understandable)
I guess realtime could be difficult due to the fact that you have to analyze your radiostream. For that you need to cache, analyze / fingerprint and run against an existing database.
But take a look on these questions:
https://stackoverflow.com/questions/2462410/acoustic-fingerprint-opensource
Musicbrainz fingerprinting
More Links:
http://acoustid.org
https://musicbrainz.org/doc/Fingerprinting
http://echoprint.me // service by spotify / echonest
https://www.audiblemagic.com/broadcast-infrastructure
Good luck.
An excellent open-source audio fingerprinting library in Python can be found here:
http://github.com/worldveil/dejavu
It allows you to fingerprint an audio file once, store the fingerprints in a database, and do continual recognition and adding fingerprints as time goes on.
You can even fingerprint small sections of song to save disk storage if you are just doing on-disk deduplication.
I’m making an audio synthesizer and I’m having issues figuring out what to use for audio playback. I’m using physics and math to calculate the source waveforms and then need to feed that waveform to something which can play it as sound. I need something that can 1) play the waveforms I calculate and 2) play multiple sounds simultaneously (like holding one key down on a piano while pressing other keys). I’ve done a fair bit of research into this and I can’t find something that does both of those things. As far as I know, I have 5 potential options:
DirectSound. It can take a waveform (a short[]) as a parameter and play it as sound, and can play multiple sounds simultaneously. But it won’t work with .NET 4.5.
System.Media.SoundPlayer. It works with .NET 4.5 and has better quality audio than Direct Sound, but it has to play sound from a .wav file and cannot play multiple sounds at once (nor can multiple instances of SoundPlayer). I ‘trick’ SoundPlayer into working by translating my waveform into .wav format in memory and then send SoundPlayer a MemoryStream of the in-memory .wav file. Could I potentially achieve control over the playback by altering the stream? I cannot append bytes to the stream (I tried) but I could potentially make the stream an arbitrary size and just re-write all the bytes in the stream with the next segment of audio data every time the end of the stream is reached.
System.Windows.Controls.MediaElement. I have not experimented with this yet, but from MSDNs documentation I don’t see a way to send it a waveform in memory without saving it to disk first and then reading it; I don’t think I can send it a stream.
System.Windows.Controls.MediaPlayer. I have not experimented with this either, but the documentation says it’s meant to be used as a companion to some kind of animation. I could potentially use this without doing any real (user-perceivable) animation to achieve my desired effect.
An open source solution. I’m hesitant to use an open source solution as I find they are typically poorly documented and not very maintainable, but I am open to ideas if there is one out there that is well documented and can do what I need.
Can anyone offer me any guidance on this or how to create flexible audio playback?
http://naudio.codeplex.com , without a doubt. Mark is a regular here on SO, the product is well alive, there are good code examples.
It works. We built some great stuff with it.
My question is simple,
I would like to do this :
http://www.codeproject.com/Articles/19854/Sending-and-playing-microphone-audio-over-network
But with another codec , in MP3.
Its possible with a free SDK/tools ... ?
Thanks
I would probably use the NAudio library and send the buffer with sockets (which should be easy since they're both a byte array).
I can't expend too much because NAudio and sockets are 2 complete subjects.
But I can provide links:
NAudio
Any information you'd probably need + download can be found here
The videos in this user is a nice series that explains NAudio
Sockets - pretty hard subject for me so I'll give more links
http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspxhttp://www.codeguru.com/csharp/csharp/cs_misc/sampleprograms/article.php/c7695/Asynchronous-Socket-Programming-in-C-Part-I.htm
http://www.csharp-examples.net/socket-send-receive/
http://www.codeproject.com/Articles/5252/Sockets-in-C
http://www.developerfusion.com/article/3918/socket-programming-in-c-part-1/
http://www.codeguru.com/csharp/csharp/cs_misc/sampleprograms/article.php/c7695/Asynchronous-Socket-Programming-in-C-Part-I.htm
http://csharp.net-informations.com/communications/csharp-socket-programming.htm
Don't forget to use Google!
Once you have basic understanding read my first sentence (with the buffer) and it will be clear.
P.S. NAudio might need another .dll to handle mp3, not sure, but it shouldn't be hard to find.
VLC Media Player can stream in a variety of different formats, including Icecast. I have not used them myself, but it looks like a nice starting point.
I have encountered a bug in DirectShow .NET where I create a secondary buffer with a sample rate of 8khz, and upon playback, the sound plays back at approx. 8.1khz instead.
Googling this, I discovered that I might be forced to upsample the 8khz audio myself to 48khz or 44.1khz depending on the soundcard in the PC.
Is there any C# library or generic algorithm I could use for this?
Thanks!!
Roey
For Alvas.Audio see code below
byte[] data48khz = AudioCompressionManager.Convert(format8khz, format48khz, data8khz, false);
You could always port Secret Rabbit Code to C#?
Or how about using the Audio Compression Manager directly via platform invoke?
Your issues of "sounds being played back too fast" may be soundcard specific. Not sure which OS you are on, but I believe Windows natively upsamples all audio streams to either 44 or 48khz before directing the samples to the soundcard (so it can properly mix it with all the other streams). So I'm not sure if you upsample with your own code if you'll get any improvements.
Have you tried using a different PC (running a different OS) or plugging in some USB headphones to see if this issue is consistent?