在 Vista 和 Win 7 中访问系统/主音量控制的 Java Sound API

Java Sound API to access the system/master volume control in Vista and Win 7(在 Vista 和 Win 7 中访问系统/主音量控制的 Java Sound API)

本文介绍了在 Vista 和 Win 7 中访问系统/主音量控制的 Java Sound API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

历史与情况:

我目前正在更新几年前为客户开发的 Java 应用程序(在 WinXP 上运行),用于测试和培训有某些听力障碍的人.购买此应用程序的用户将获得特定的 USB 声音设备和耳机.

I'm currently working on updating a Java application that was developed for a client several years ago (to run on WinXP) and is used for testing and training people with certain hearing impairments. Users who bought this application were provided with a particular USB sound device and headphones.

此软件最重要的要求之一是必须以特定分贝声级向用户播放音频.使用 Java Sound API,该应用程序被开发为将 Windows 音量动态调整到计算的水平(基于在开发过程中校准 USB 声音设备和耳机时进行的测量).

One of the most important requirements for this software is that the audio must be played to the user at specific decibel sound levels. Using the Java Sound API, the application was developed to dynamically adjust the Windows Volume to calculated levels (based on measurements made when calibrating the USB sound device & headphones during development).

问题:

该应用程序现在需要升级以支持 Windows Vista 和 Windows 7,但是由于 Windows 新的 per-app 声音架构,我无法找到使用 Java Sound 访问主/系统音量的任何方法API.

The application now needs to be upgraded to support Windows Vista and Windows 7, however due to Windows' new per-app sound architecture, I've been unable to find any way to access the Master/System volume using the Java Sound API.

应用程序的 Windows 音量控制本身并不能削减它,因为它与系统音量相关,并且无法保证用户会听到特定的已知级别的输出音频.

The application's windows volume control alone doesn't cut it since it's relative to the system volume and there's no way to guarantee that the user will hear the output audio at a specific, known level.

有没有人知道在 Java 中是否可以做到这一点,如果可以,那怎么做?如果不可能,那么您能否就实现它的最简单方法提供任何指导?(也许是 JNI 和 C - 虽然我以前从未使用过 JNI...有什么需要注意的问题吗?)

Does anybody know if it is even possible to do this in Java and if so then how? If it's not possible, then can you give any guidance on what might be the simplest way to achieve it? (JNI and C perhaps - though I've never used JNI before... any gotchas to be aware of?)

推荐答案

如果您在 Windows XP 兼容模式下运行您的应用程序,它应该可以工作(这取决于 Java Sound API 如何与硬件音量交互).

If you run your application in Windows XP compatibility mode, it should work (it depends on how the Java Sound API interacts with the hardware volume).

如果您想使用 Vista(及更高版本)声音 API,您需要查看 IAudioEndpointVolume API.

If you want to use the Vista (and beyond) sound APIs, you want to look at the IAudioEndpointVolume API.

这篇关于在 Vista 和 Win 7 中访问系统/主音量控制的 Java Sound API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 Vista 和 Win 7 中访问系统/主音量控制的 Java Sound API

基础教程推荐