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

Create Wad.listener Object #121

Closed frastlin closed 4 years ago

frastlin commented 4 years ago

Hello, In light of differing supports for the AudioListener, could Wad wrap the Wad.audioContext.listener in a Wad.listener object that can:

  1. Make the set position code to be uniform across different browsers, probably using the accepted positionX API, and that keeps track of the listener pos, so that if users use the Wad.listener object, they can always get the Wad.listener.positionX, even on Safari.
frastlin commented 4 years ago

I am closing https://github.com/rserota/wad/issues/108 in favor of this one. The things from 108 I was commenting were:

  1. Normalize the API
  2. Currently, the set orientation requires a vector, but all the code in my systems uses angles and degrees. It would be extremely helpful for me if there was a set orientation function that would rotate the listener object through: setOrientation(90)
  3. There could also be a setPosition function that takes a theta and an amount to move, and sets the new position if the 3rd argument is true. Then it can return the new position.
  4. This would also be a good place to allow someone to put effects over all sounds at once, as if the listener was having an effect put onto them.
frastlin commented 4 years ago

I'm going to start working on this, unless you have already started.

rserota commented 4 years ago

I haven't started working on this. If you wanted to build it, that would be great.

frastlin commented 4 years ago

Hm, so I'm looking on Chrome at listener.positionX, and there are quite a few functions here that are not on MDN. I wonder if it's possible to view their code somewhere?

AudioParamautomationRate: (...)
cancelAndHoldAtTime: ƒ cancelAndHoldAtTime()
cancelScheduledValues: ƒ cancelScheduledValues()
defaultValue: (...)
exponentialRampToValueAtTime: ƒ exponentialRampToValueAtTime()
linearRampToValueAtTime: ƒ linearRampToValueAtTime()
maxValue: (...)
minValue: (...)
setTargetAtTime: ƒ setTargetAtTime()
setValueAtTime: ƒ setValueAtTime()
setValueCurveAtTime: ƒ setValueCurveAtTime()
value: (...)
constructor: ƒ AudioParam()
Symbol(Symbol.toStringTag): "AudioParam"
get automationRate: ƒ automationRate()
set automationRate: ƒ automationRate()
get defaultValue: ƒ defaultValue()
get maxValue: ƒ maxValue()
get minValue: ƒ minValue()
get value: ƒ value()
set value: ƒ value()
rserota commented 4 years ago

I guess you could try searching through the Chromium source code? For example: https://github.com/chromium/chromium/search?q=cancelAndHoldAtTime&unscoped_q=cancelAndHoldAtTime

frastlin commented 4 years ago

Do you think you could possibly push a release to this? I have a couple projects that I want to refactor to use this listener object, and rather than pointing them to my local version of the repository, I would like to just update them.

rserota commented 4 years ago

Version 4.9.0 is now available on npm.