SoundGetVolume

检索声音设备的音量设置.

Setting := SoundGetVolume(Component, Device)

参数

Component

类型: 字符串整数

组件的显示名称和/或索引. 例如, 1, "Line in""Line in:2".

如果省略或为空, 则检索主音量设置.

有关详情, 请参阅 Component (Sound 函数).

Device

类型: 字符串整数

设备的显示名称和/或索引. 例如, 1, "Speakers", "Speakers:2""Speakers (Example HD Audio)".

如果省略该参数, 则它默认为系统的默认回放设备(不一定是设备 1).

有关详情, 请参阅 Device (Sound 函数).

返回值

类型: 浮点数字符串(空值)

函数返回 0.0 到 100.0 之间的浮点数.

错误处理

失败时可能会抛出以下异常之一:

Error 类消息
TargetErrorDevice not found(无法找到设备)
Component not found(无法找到组件)
Component doesn't support this control type(组件不支持此控件类型)
OSErrorSystem-generated.(由系统生成)

备注

要发现系统上安装的声音设备的功能 -- 比如名称和可用的组件 -- 请运行这个声卡分析脚本.

Sound 函数

示例

检索并报告主音量.

master_volume := SoundGetVolume()
MsgBox "Master volume is " master_volume " percent."

检索和报告麦克风播放音量.

mic_volume := SoundGetVolume("Microphone")
MsgBox "Microphone listening volume is " mic_volume " percent."

检索并报告麦克风的录音音量.

mic_volume := SoundGetVolume( , "Microphone")
MsgBox "Microphone recording volume is " mic_volume " percent."
unixetc