Skip to content

Feature Request: Simple Compression and Filter #54

Open
@erichlof

Description

@erichlof

Hi James and all,
James I know you have a lot on your plate right now, but with possible reworking of some of the aspects of Howler's positional methods, I wanted to try to throw in a couple of feature requests that would be relatively easier to implement now, during possible re-structuring, rather than later as an afterthought.

Two effects come to mind when having a robust audio engine for games. The first is almost a necessity - compression. If the developer has too many sounds playing at the same time and a possible background track going on, the audio will become distorted due to clipping. May I suggest a howler.compressor object to limit the final output of the app's audio and to help keep in check the overall volume when the gameplay sounds get heavy (like a sudden firefight in a war game).

The second isn't so much a necessity as it is a cool effect that is difficult to hard-code ourselves, or re-record everything with the effect added. This is a Low-Pass Filter. For those of you non-audio buffs out there, it is essentially a muffling effect. It limits all the high parts of the audio spectrum (imagine speaking while cupping your hand over your mouth). The volume remains the same, but only the low parts pass through.

I can think of a couple of situations where a filter would come in handy - one is in a FPS when the player gets knocked by a nearby grenade or something, a muffled-world sound would ensue as well as red-tinted-screen 'damage' effects or whatever the developer wanted. The second case would be people talking or a club-music atmosphere going on in another room. As you approach the room from outside, the voices or music sound muffled, and when you open the door, the developer switches howler.filter to Off and then you can hear the high parts of the sounds again (just like in real-life).

So in summary, howler.compressor(amount) and howler.filter(frequency). The lower the frequency, the more muffled, the higher the frequency the less muffled the sound becomes. We could even use this feature to code a sweep of that frequency parameter and go smoothly from totally muffled to totally bright (as DeadMau5 makes money doing every night - haha).

Implementing these with Web Audio API is trivial. It's probably 4 or 5 lines of code for each effect. It involves creating the filter or compressor and then hooking them up with the .connect() function to the final audio destination (your speakers). As usual the Web Audio API overkills and gives you total control over every possible parameter if you want to design a synthesizer, but we just need a one-size-fits-all function with maybe 1 adjustable parameter to keep things simple and useful for gaming applications.

Please let me know what you all think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions