Question

I want to add a reverb effect for audio files in Java or at the very least the playback of those audio files. The Java program is a desktop application so I cannot use the android libraries. I have tried use the controls on the ports using the Java Sound API, but it has not worked on my test machine. (My tests show that none of the ports support reverb control).

        Port line = null; 
    if (AudioSystem.isLineSupported(Port.Info.SPEAKER)) {
        try {
            line = (Port) AudioSystem.getLine(
                Port.Info.SPEAKER);
        }
        catch(Exception ex){
            ex.printStackTrace();
            return;
        }
    }
    EnumControl reverb = (EnumControl)line.getControl(EnumControl.Type.REVERB);
    System.out.println(Arrays.toString(reverb.getValues()));

The above code has not worked. Is there a way I can manually add a reverb effect? Perhaps through some overlooked api or by manipulating the waveform and or playback of that waveform? Any advice at all would be duely appreciated.

Was it helpful?

Solution

If your drivers don't support reverb, but do support playing back multiple sounds overlapping each other, you could play back the same sound several times with a short delay between instances and decreasing volume each time. "Proper" reverb would also do a bit of filtering on each repetition, but this should be close enough.

If your drivers don't let you do it that way, you could try reprocessing the sound itself to add reverb before playing it, using the same approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top