rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.9k stars 160 forks source link

Multiple Sources? #18

Closed bignimbus closed 10 years ago

bignimbus commented 10 years ago

In the spirit of allowing multiple filters, I'd like to add a feature that allows the user to specify more than one source wave. This opens up the possibility of more closely approximating real instrument sounds, if one were so inclined.

I don't see any reason why this couldn't be done in a very similar fashion to the way multiple filters are handled. Before I get started, does anyone have any thoughts?

rserota commented 10 years ago

I'm currently working on a feature which should address this issue. Rather than adding multiple sources to one Wad, I'm thinking about an object that stores multiple Wads. You can then have a set of filters/effects apply to all Wads in that object, and also call play() or stop() on that object to play or stop all the wads it contains.

Does this sound like it addresses your desire? Or am I missing something?

coleww commented 10 years ago

I've thought of doing this with drum samples to change up velocity and such. Like make a wrapper object that stores a wads [] attribute, and when you call play it picks one based on ____.

Not quite sure what is meant by approximating real sounds though...

I like the idea of the multi-wad object with one set of attrs. It accomplishes things that a wrapper function couldn't, like having the one global reverb.

bignimbus commented 10 years ago

Raphael, yes, I believe that your approach would result in a solution that satisfies the parameters I detailed in the original post. I am really looking forward to it!

some explanation for @coleww, the general consensus in the audio community on sound synthesis is that any given sound can be represented as one or more sine waves at different frequencies. The more sine waves you can instantiate at once, the more harmonic interactions the waves create with one another.

Fourier demonstrated that any function (such as a sound waveform) can be expressed as a sum of sine or cosine graphs. This reverse engineering or deconstructing of a given graph is called Fourier Analysis.

So if, through WAD, the Web Audio API can be implemented so that web audio developers can use and manipulate an arbitrary amount of source waves, he/she can, theoretically, engineer any conceivable sound. The limiting factor, though, would be the client's computing power: I'm not sure how many oscillators a browser running on mainstream hardware could handle.

bignimbus commented 10 years ago

@rserota,

I sent you an email, check your spam folder. I wrote an article on WAD, thought you might want to check it out.

rserota commented 10 years ago

Sorry it took me so long to finish this up, but I've finally implemented and documented a solution that lets you group several oscillators and play them simultaneously. Check out the documentation on PolyWads.

bignimbus commented 10 years ago

Very cool!