accord-net / framework

Machine learning, computer vision, statistics and general scientific computing for .NET
http://accord-framework.net
GNU Lesser General Public License v2.1
4.48k stars 1.99k forks source link

Real-time audio playing example #744

Open gustav21 opened 7 years ago

gustav21 commented 7 years ago

Can anybody give a sample code to play audio directly from the AudioCaptureDevice? There is a sample Wave Recorder app, but it plays audio from the previously created stream ..

gustav21 commented 7 years ago

Maybe @cesarsouza can help?

cesarsouza commented 7 years ago

Hi @gustav21,

The audio APIs in the framework are more focused towards capturing/playing audio data to be used in machine learning applications (where usually you would build or process a dataset of audio samples stored somewhere). I think it might be possible to link a AudioCaptureDevice and a AudioOutputDevice together, but I do not have a sample available right now showing how to do it.

Since the framework classes are more intended to be used to capture to/playback from different streams, I would also suggest trying to implement this functionality directly with SharpDX. It may be a bit more complicated, but it will surely be more efficient/flexible regarding your needs (the framework uses SharpDX under the hood of many audio classes).

I will leave the issue open until I could come up with a sample. If you find a solution in the meantime, please also let us know!

Regards, Cesar

gustav21 commented 7 years ago

@cesarsouza I got it, many thanks! I will definitely let you know about a solution when I find it.