0

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?

NealR
  • 10,189
  • 61
  • 159
  • 299
  • To whoever anonymously voted on closing the post without leaving any feedback: why?? I'm posting because I'm stuck on what seems like should be an easy procedure, despite tons of research. Willing to alter the post in any way that will help if need be. – NealR Feb 20 '15 at 04:06
  • But anyway you go against the SO rules. For any programmers, if there is nothing that directly fits your requirements, build it. Not to mention you can find many wrapper already for Core Audio APIs, http://netcoreaudio.codeplex.com/, which also ships with many useful test cases to demonstrate the API usage. – Lex Li Feb 20 '15 at 04:23
  • Maybe you don't understand the question - I'm unsure how to start with the wrappers you're talking about. What objects/interfaces do I use to connect to the computer's audio source? I'm lost trying to figure this out, but I'm trying :) – NealR Feb 20 '15 at 04:28
  • I can only suggest you to be patient, as [Microsoft does demonstrate in native language how to capture audio stream](https://msdn.microsoft.com/en-us/library/dd370800.aspx) (is that what you want to do?). And then you can easily find in the wrapper the corresponding interfaces, http://netcoreaudio.codeplex.com/SourceControl/latest#trunk/Code/CoreAudio/Interfaces/IAudioCaptureClient.cs. SO welcomes questions after investigation, and I think you haven't got started yet. – Lex Li Feb 20 '15 at 04:34
  • Sorry, but that's not accurate. I've seen this page, however it's written in C++ and I'm attempting to write this in C#. One of the draw backs I've encountered in my research. I haven't tested it yet, but this is as close to what I'm trying to do as anything I've found so far (note the similarities in the original post here and mine): http://stackoverflow.com/questions/5694326/record-input-from-naudio-wavein-and-output-to-naudio-waveout – NealR Feb 20 '15 at 04:37
  • Yes, you simply did not research much. Even NAudio lists clearly that it supports Core Audio API (aka WASAPI) in both recording and playback. It also lists another open source project named .NET Audio Recorder that demonstrates how to record based on NAudio. So my last piece of advice for you, is to research, try, and test, before posting questions like this one on SO. That's how you can learn new things. – Lex Li Feb 20 '15 at 05:10

1 Answers1

1

In NAudio, you can capture the audio being played on your system with WasapiLoopbackCapture.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194