audiojs / audio

Class for high-level audio manipulations [NOT MAINTAINED]
MIT License
240 stars 9 forks source link

Extend constructor to allow for async args #48

Open dy opened 6 years ago

dy commented 6 years ago

Similar to Image:

Audio('./x.wav', (err, a) => {})
Audio(blob).on('load', a => {})
Audio(file).then(a => {})
  1. That would allow to get rid of / hide .decode, .load methods.
  2. Audio w/o content loaded is in temporary state of empty buffer, but available already.
  3. That complicates Promise interface Audio(url).then(a => {}): audio is thenable.
  4. That mixes up sync/async pattern: some audio sources are available synchronously, like buffers, others only in async way.

Otherwise it is not clear the natural way of creating blobs: Audio.load(blob),Audio.decode(blob) or Audio.from(blob)?