rserota / wad

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

setRate does not appear to work. #118

Closed alittlebitweird closed 4 years ago

alittlebitweird commented 4 years ago

When calling setRate with any parameters, the rate is set to 1.

rserota commented 4 years ago

That is the intended behavior, though I guess it could be documented a bit better.

If you want to change the rate of a wad that isn't currently playing, simply assign it a new rate: myWad.rate = 2. If you want to play a wad once with a specific rate, you can pass it in to play: myWad.play({rate:2}). The setRate() method is intended to be used on a wad that is currently playing. For example, you might set up a mod wheel on a MIDI keyboard to call setRate() on a wad, to play around with audio clips in real-time.

alittlebitweird commented 4 years ago

@rserota thanks for clearing that up. Can this be done the same way for filters?

rserota commented 4 years ago

If you want to change the filters of a wad that isn't playing, you can just assign to the filters property. If you want to change the frequency of a Wad that's currently playing, there isn't a very elegant way to do this yet, but it's possible: myWad.nodes[1].frequency.linearRampToValueAtTime(500, Wad.audioContext.currentTime, .1) Though you'd have to know the index of the filter node in the Wad's node list.