audio-param-transform
Advanced tools
Comparing version 0.4.0 to 1.0.0
@@ -8,3 +8,2 @@ var Scheduler = require('./scheduler') | ||
param.context = audioContext | ||
param._sampleRate = audioContext.sampleRate | ||
param.transform = transform | ||
@@ -35,3 +34,3 @@ param.clearTransforms = clearTransforms | ||
var transformParam = new TransformParam(this.context, defaultValue, param._transformCallback) | ||
var transformParam = TransformParam(this.context, defaultValue, param._transformCallback) | ||
transformParam.operation = operation | ||
@@ -51,3 +50,3 @@ transformParam._transforms = [] | ||
var duration = to - from | ||
var steps = Math.max(1, Math.floor(duration * param._sampleRate)) | ||
var steps = Math.max(1, Math.floor(duration * param.context.sampleRate)) | ||
var defaultValue = param.defaultValue | ||
@@ -54,0 +53,0 @@ |
{ | ||
"name": "audio-param-transform", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"description": "Apply multiple transforms with custom functions to Web Audio API AudioParams.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,16 +0,14 @@ | ||
module.exports = TransformAudioParam | ||
module.exports = function TransformAudioParam(audioContext, defaultValue, cb){ | ||
var instance = Object.create(proto, properties) | ||
instance.context = audioContext | ||
instance._callback = cb | ||
function TransformAudioParam(audioContext, defaultValue, cb){ | ||
if (!(this instanceof TransformAudioParam)){ | ||
return new TransformAudioParam(audioContext, defaultValue, cb) | ||
} | ||
Object.defineProperties(this, properties) | ||
this.context = audioContext | ||
this._callback = cb | ||
this._events = [] | ||
this._events.truncateFrom = truncateFrom | ||
this._events.truncateTo = truncateTo | ||
this.defaultValue = defaultValue | ||
this._lastValue = defaultValue | ||
this._sampleRate = audioContext.sampleRate | ||
instance._events = [] | ||
instance._sampleRate = audioContext.sampleRate | ||
instance._events.truncateFrom = truncateFrom | ||
instance._events.truncateTo = truncateTo | ||
instance.defaultValue = defaultValue | ||
instance._lastValue = defaultValue | ||
return instance | ||
} | ||
@@ -29,5 +27,3 @@ | ||
TransformAudioParam.prototype = { | ||
constructor: TransformAudioParam, | ||
var proto = { | ||
setValueAtTime: function(value, at){ | ||
@@ -111,4 +107,4 @@ this.addEvent({ | ||
var duration = toTime - fromTime | ||
var steps = Math.max(1, Math.floor(duration * this._sampleRate)) | ||
var curve = new Float32Array(steps) | ||
var steps = Math.max(1, Math.floor(duration * this._sampleRate)) | ||
@@ -133,3 +129,3 @@ for (var i=0;i<steps;i++){ | ||
} else if (target.at <= time){ | ||
if (typeof target.value == 'object'){ | ||
if (target.value instanceof Float32Array){ | ||
lastValue = target.value[target.value.length-1] | ||
@@ -136,0 +132,0 @@ } else { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
14940
395