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

查看:19
本文介绍了用于在 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 新的每应用程序声音架构,我一直无法找到任何使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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