简体   繁体   English

PAN 在 java sound api 中不起作用

[英]PAN not works in java sound api

I have a big problem, I have developed a Java application which aims to test hearing, delivering sounds at different frequencies (500Hz - 6000Hz) and decibels, so good until apareción a problem in some notebooks does not work well because when you run a sound to the right ear is delivered to the two ears, the same with the left.我有一个大问题,我开发了一个 Java 应用程序,旨在测试听力,提供不同频率 (500Hz - 6000Hz) 和分贝的声音,很好,直到出现某些笔记本电脑中的问题无法正常工作,因为当你运行声音时右耳传送到两耳,与左耳相同。 At first I thought it was a mistake on my application, but when I found an example of similar oracle java http://www.oracle.com/technetwork/java/index-139508.html was the same was taken aback.一开始我以为是我的应用程序出错了,但是当我发现一个类似的oracle java http://www.oracle.com/technetwork/java/index-139508.html的例子时,我大吃一惊。 I can also be hardaware rule because in my notebook windows7/fedora working properly in linux.我也可以是硬件规则,因为在我的笔记本 windows7/fedora 中可以在 linux 中正常工作。

I can only begin to see the solution to level drivers or operating system for the application to run on any computer.我只能开始看到为应用程序在任何计算机上运行的驱动程序或操作系统级别的解决方案。

-I have tried it on multiple computers, so far has not worked in 2 samsung, 1 HP and 1 Toshiba (new and used, it is not a matter of sound settings) - 我已经在多台电脑上试过了,到目前为止还没有在 2 台三星、1 台 HP 和 1 台东芝上运行过(新的和用过的,不是声音设置的问题)

-This application also works well be me that is C + + http://www.programming.de/freeware_windows.php (ear test) - 这个应用程序也很好用,我是 C++ http://www.programming.de/freeware_windows.php (耳朵测试)

-Here's a code sample http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml - 这是一个代码示例http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml

-I tried creating. - 我试着创造。 Wav files in stereo and mono mode (with Audacity)立体声和单声道模式下的 Wav 文件(使用 Audacity)

-In java I installed the 1.4 jre to test the current -在java中我安装了1.4 jre来测试当前

-Probably many of you would work because it depends on the computer - 可能你们很多人会工作,因为这取决于计算机

a piece of code:一段代码:

private void propiedadesSound()
{
        this.clipAudio.stop();
        this.clipAudio.close();
        try
        {
            InputStream temp = getClass().getResourceAsStream(this.archivo);
            InputStream bufferedIn = new BufferedInputStream(temp);
            this.audio = AudioSystem.getAudioInputStream(bufferedIn);
                this.clipAudio.open(this.audio);
                if(this.clipAudio.isControlSupported(FloatControl.Type.PAN))
                {
                    FloatControl pan = (FloatControl) this.clipAudio.getControl(FloatControl.Type.PAN);
                    if(this.jRadioButtonIzq.isSelected())
                     pan.setValue(-1.0f);
                     else if(this.jRadioButtonDer.isSelected())
                     pan.setValue(1.0f);
                     else if(this.jRadioButtonAmbos.isSelected())
                     pan.setValue(0.0f);
                }
        else if(this.clipAudio.isControlSupported(FloatControl.Type.BALANCE))
                {
                    FloatControl pan = (FloatControl) this.clipAudio.getControl(FloatControl.Type.BALANCE);
                    if(this.jRadioButtonIzq.isSelected())
                    pan.setValue(-1.0f);
                    else if(this.jRadioButtonDer.isSelected())
                    pan.setValue(1.0f);
                    else if(this.jRadioButtonAmbos.isSelected())
                    pan.setValue(0.0f);
                 }
                if(this.clipAudio.isControlSupported(FloatControl.Type.MASTER_GAIN))
                {
                    FloatControl gain = (FloatControl) this.clipAudio.getControl(FloatControl.Type.MASTER_GAIN);
                    float max = gain.getMaximum();
                    float min = gain.getMinimum();
                    float current = gain.getValue();
                    double gainValue = this.jSliderDecibel.getValue()+20;
                    float newValue = (float)(min + gainValue * (max - min) / 100.0F);
                    gain.setValue(newValue);
                }
        }
        catch (UnsupportedAudioFileException ex)
        {
            exitError("Archivo de audio no soportado.");
        }
        catch (LineUnavailableException ex)
        {
            exitError("Linea no soportada.");
        }
        catch (IOException ex)
        {
            exitError("Error en la lectura del archivo de audio."+ex);
        }
    }

pd: I also tried removing the code PAN only, balance and only two like this now pd:我也尝试仅删除代码 PAN,平衡,现在只有两个这样的

someone comes up with an alternative?, the code must be java as it is part of a larger program, but perhaps you could add some other language dll有人提出了替代方案?,代码必须是java,因为它是更大程序的一部分,但也许您可以添加一些其他语言的dll

Thank you in advance先感谢您

/-----EDIT--------------------------------/ / - - -编辑 - - - - - - - - - - - - - - - - /

I found a solution that is not definitive but it has worked so far.我找到了一个不确定的解决方案,但到目前为止它已经奏效。 The notebooks that had the problem were coming from the factory, for some reason fails to divide java sound so have been formatted, you have installed a new windows (in this case Windows 7), the same version of Windows that was bringing but not factory, after that it worked every notebook I had that problem.有问题的笔记本来自工厂,由于某种原因无法分割java声音所以已经格式化,你安装了一个新的Windows(在这种情况下是Windows 7),与带来但不是工厂的相同版本的Windows , 之后它在我遇到这个问题的每台笔记本电脑上都有效。 Therefore it is an incompatibility of factory drivers of some notebooks with java api, which has not been updated for many years所以是部分笔记本出厂驱动与java api不兼容,多年未更新

/----------------------------------------/ /----------------------------------------/

The definition of PAN is a bit vague. PAN的定义有点模糊。 You may not get complete stereo separation depending on how they interpret PAN.根据他们解释 PAN 的方式,您可能无法获得完整的立体声分离。

I recommend opening a stereo line and doing your own panning.我建议打开立体声线路并进行自己的平移。 I do this in JSyn and I get complete stereo separation.我在 JSyn 中这样做,我得到了完整的立体声分离。

If you want a tone on only one channel then write the tone to one channel and zeros to the other.如果您只想在一个通道上发出音调,则将音调写入一个通道,将零写入另一个通道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM