如何以编程方式获取当前音频电平? [英] How to programmatically get the current audio level?

查看:539
本文介绍了如何以编程方式获取当前音频电平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我需要的是挖掘到当前的音频输出和检查声级的方式,即我需要能够检查是否有东西玩音频设备上或没有。

Basically, what I need is a way to tap into the current audio output and check the sound level, i.e. I need to be able to check whether there is something playing on the audio device or not.

我不需要检查音量设置,但在实际播放音频流的音量。

I do not need to check the volume setting, but the actual playing audio stream's sound level.

对不起,我问的是如何要做到这一点在Windows上的Visual Studio 2008

Sorry, I was asking about how to do it in Windows, on Visual Studio 2008.

@mikerobi:构成我的推理的一部分 - 如果正在对系统音量表显示它,必须有是一个系统调用,可以拿回来

@mikerobi: That forms a part of my reasoning - if it is being displayed on the system volume meter, there must be a system call that can get it back

推荐答案

这是一个很好的问题。答案,32位的Windows应用程序,是挂接到WINMM.DLL和其他低级别的音频控制的DLL。在C#中我会创建一个包含的extern方法原型的包装类:

This is a good question. The answer, for 32-bit Windows apps, is to hook into winmm.dll and other low-level audio control DLLs. In C# I'd create a wrapper class containing extern method prototypes:

public class MyAudioWrapper
{
   [DllImport("winmm.dll", EntryPoint = "waveOutGetVolume")]
   public extern void GetWaveVolume(IntPtr devicehandle, out int Volume);

   ...
}



看一看< A HREF =htt​​p://msdn.microsoft.com/en-us/library/ms712636相对=nofollow>对于Windows音频方法列表此链接;你可以使用调音台,或者只是波输出控制器,设置音量。要使用将决定什么样的库导入什么。你必须研究如何最好定义原型,以及如何获得句柄到音频/混音设备。

Have a look at this link for a list of Windows audio methods; you can use the mixer, or just the wave-out controller, to set volume. What you want to use will dictate what libraries to import. You'll have to research how best to define the prototype, and how to get the handle to the audio/mixer device.

这篇关于如何以编程方式获取当前音频电平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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