diff --git a/soundwave.cm b/soundwave.cm index deb43d7..5d7a9fd 100644 --- a/soundwave.cm +++ b/soundwave.cm @@ -50,15 +50,21 @@ * .finish_hook- optional callback when voice finishes */ -var wav = use('soundwave/wav') -var mp3 = use('soundwave/mp3') -var flac = use('soundwave/flac') -var dsp = use('soundwave/dsp') +var wav = use('wav') +var mp3 = use('mp3') +var flac = use('flac') +var dsp = use('dsp') var samplerate = use('libsamplerate/convert') var Blob = use('blob') var soundwave = {} +var voice = { + stop() { + this.stopped = true + } +} + // Create a new audio player instance soundwave.create = function(opts) { opts = opts || {} @@ -196,22 +202,22 @@ soundwave.create = function(opts) { player.play = function(pcm, opts) { if (!pcm) return null - var voice = { + var newvoice = meme(voice, { source: pcm, pos: 0, vol: 1.0, loop: false, stopped: false, finish_hook: null - } + }) if (opts) { - if (opts.loop != null) voice.loop = opts.loop - if (opts.vol != null) voice.vol = opts.vol + if (opts.loop != null) newvoice.loop = opts.loop + if (opts.vol != null) newvoice.vol = opts.vol } - player.voices.push(voice) - return voice + player.voices.push(newvoice) + return newvoice } // Pull mixed audio frames