在Java 1.4中控制音频剪辑的音量 [英] Controling the Volume of an Audio Clip in Java 1.4

查看:134
本文介绍了在Java 1.4中控制音频剪辑的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我本以为这将是一件容易的事,但是没有任何关于谷歌搜索的解决方案.

I would have thought that this would be an easy thing to do, but no amount of googling around has turned up any solutions.

我已经为全屏运行的客户端编写了一个应用程序,允许用户翻阅教育书籍,以帮助教孩子们阅读.到目前为止,一切都很好.所显示的资料中的某些短语会读回给用户,并且到目前为止,效果还不错.通常,这些声音是在系统音量下读取的. (即,无论音量大小如何,都会播放其他系统声音.)

I have written an application for a client that runs in full screen and allows the user to page through educational books in order to help teach kids to read. So far so good. Some phrases from the displayed materials are read back to the user and, again, so far so good. Normally, these sounds are read at the system volume. (ie, at whatever volume any other system sound would be played.)

但是,客户端现在希望用户能够调整程序中的音量.我的UI和处理工作已经完成,但是我很难以有意义的方式调整正在播放的剪辑的音量.现在,我有一个时髦的设置,其中涉及读取剪辑的原始增益,然后针对每个剪辑向上或向下调整该增益.尽管这确实可以调节音量,但相对于系统音量而言似乎并没有做到这一点-所有声音都比系统音量小得多.

The client, however, now wants the user to be able to adjust the volume in program. I have the UI and processing end of that working, but I'm having a hard time adjusting the volume of the clips being played in a meaningful way. Right now I have a funky setup that involves reading the original gain of the clip and then adjusting that up or down for each clip. While this does adjust the volume, it does not seem to do it relative to the system volume -- all of the sounds are much quieter than the system volume.

所以,我的问题确实是:您如何建议在程序中控制音量?我的所有研究都没有发现任何有意义的东西,这对我来说意味着种种困难,甚至是不可能的,但这似乎并不正确.

So, my question really is: how do you suggest controlling sound volume within a program? All of my research has turned up nothing meaningful, which implies to me that it's kind of hard or even impossible, but that just doesn't seem right.

哦,详细信息:我正在读WAV的AudioInputStreams,并以java.sound.sampled.Clip的形式播放它们.我正在使用FloatControl.Type.MASTER_GAIN控制增益. (不支持FloatControl.Type.VOLUME.)我被困在Java 1.4上.

Oh, details: I'm reading in WAVs as AudioInputStreams and playing them as java.sound.sampled.Clip. I'm controlling the gain using FloatControl.Type.MASTER_GAIN. (FloatControl.Type.VOLUME is not supported.) I'm stuck using Java 1.4.

推荐答案

您还可能希望查看是否存在支持Java 1.4的Java Media Framework(JMF)的较早版本...它可能会为您提供一个更丰富的音频处理环境.

You might also look to see if there is an older version of the Java Media Framework (JMF) that will support Java 1.4... it might provide you with a more rich environment for working with audio.

除此之外,您说自己陷入1.4的状态...您可能会看到是否有任何方法可以升级到Java 5或6,尽管您可能想先在本地计算机上测试其中任何一种以升级到Java 5或Java 6.看看他们是否真的有帮助.

Other than that, you say you are stuck in 1.4... you might see if there is any way you can get upgraded to Java 5 or 6, though you may want to test either of these first on your local machine to see if they actually help any.

我猜最后一个建议是找到一些Java游戏开发站点并将您的问题发布在那里.我想他们会想办法解决的……尽管您也可以在那里获得很多升级您的jvm"响应. :-)

I guess one last suggestion is to find some Java game development sites and post your question there; I would think they would have figured out ways around it... though you could also get a lot of 'upgrade your jvm' responses there too. :-)

祝你好运.

这篇关于在Java 1.4中控制音频剪辑的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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