阅读系统音频输出流 [英] Reading The System Audio Output Stream

查看:164
本文介绍了阅读系统音频输出流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在示波器组件有关XNA和需要一点帮助。我想获得的音频信息形成的系统音频输出流,但我发现它非常难做到这一点。我已经找到了一些资源,但没有什么帮助了我一路,也有助于在某种程度上我不能够把握。这里有以下资源我发现至今。

I am currently Making an Oscilloscope Component For XNA and need a bit of help. I would Like to get the Audio Information form The Systems Audio Output Stream, However i am finding it extremely hard to do so. i have found Some Resources but nothing that helps me all the way, or it helps in a way i am not able to grasp. Here are the Following Resources i have found so far.

<一个href="http://stackoverflow.com/questions/3992798/how-to-programmatically-get-the-current-audio-level">How以编程方式获取当前音频电平?

http://msdn.microsoft.com/en-us/library/ms712636

<一个href="http://social.msdn.microsoft.com/Forums/en/xnagamestudioex$p$pss/thread/6a3ea3da-849b-475d-a2a4-7cf7c27347d5" rel="nofollow">http://social.msdn.microsoft.com/Forums/en/xnagamestudioex$p$pss/thread/6a3ea3da-849b-475d-a2a4-7cf7c27347d5

因为我不能完全得到什么做处理我都虚心地来到你的帮助,谢谢变化不大。

As i am not Able to completely get a handle on what to do i have humbly come to you for your help Thank you Vary much.

推荐答案

DirectSound的有很多细微差别就可以使它很难处理的。如果你是开放给使用一些第三方的选择,也有一些免费的可用的DirectSound的抽象的技术细节,使这个问题更加平易近人。我个人建议BASS.NET - 和n音讯是好的,如果你更感兴趣的是一个完全托管的解决方案

DirectSound has a lot of nuance to it that can make it difficult to work with. If you're open to using some third-party options, there are a few free ones available that abstract the technical details of DirectSound and make this problem much more approachable. I personally recommend BASS.NET - and NAudio is good if you're more interested in an entirely managed solution.

在BASS.NET,你的code会是这个样子:

In BASS.NET, your code would look something like this:

private RECORDPROC _myRecProc; // make it global, so that the Garbage Collector can not remove it
...
Bass.BASS_RecordInit(-1);
_myRecProc = new RECORDPROC(MyRecording);
// start recording paused
int settings = 0;
int inputSource = 0;
while (settings != -1)
{
  // get the settings of that input
  settings = Bass.BASS_RecordGetInput(inputSource, ref vol);
  if ( Bass.BASS_RecordGetInputName(inputSource) == "What U Hear" ||
       Bass.BASS_RecordGetInputName(inputSource) == "Stereo Mix")
  { 
    break;
  }
  inputSource++;
}    

Bass.BASS_RecordSetInput(inputSource, BASSInput.BASS_INPUT_ON, 0.5F)

int recChannel = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _myRecProc, IntPtr.Zero);
...
// really start recording
Bass.BASS_ChannelPlay(recChannel, false);
...
// the recording callback
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
{
  return true;
}

基本上,你初始化低音。然后你通过所有可能的输入源搜索您听到的声音或循环立体声混音。这是所有的扬声器输出的组合频道的名称,从声卡变化到声卡,所以你必须获得共同的名称的列表。当你找到一个合适的渠道,你就会开始录制。该MyRecording方法将有一个缓冲,为您分析一下。

Basically, you're initializing BASS. Then you loop through all the possible input sources searching for "What U Hear" or "Stereo Mix." The name of the channel that is a combination of all your speaker output varies from soundcard to soundcard, so you'll have to get a list of the common names. After you've found an appropriate channel, you'll start recording. The MyRecording method will have a buffer for you to analyze.

这只是其中的一个办法做到这一点,有一个图书馆。环顾四周,看看哪个库为您提供的数据格式,你想在

This is just one way to do it, with one library. Take a look around and see which library provides you with data in a format you want it in.

这篇关于阅读系统音频输出流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆