scratch-audio
Advanced tools
Comparing version
{ | ||
"name": "scratch-audio", | ||
"version": "0.1.0-prerelease.20180621210133", | ||
"version": "0.1.0-prerelease.20180625191752", | ||
"description": "audio engine for scratch 3.0", | ||
@@ -5,0 +5,0 @@ "main": "dist.js", |
@@ -251,2 +251,6 @@ const StartAudioContext = require('./StartAudioContext'); | ||
/** | ||
* Create an effect chain. | ||
* @returns {EffectChain} chain of effects defined by this AudioEngine | ||
*/ | ||
createEffectChain () { | ||
@@ -258,2 +262,7 @@ const effects = new EffectChain(this, this.effects); | ||
/** | ||
* Create a sound bank and effect chain. | ||
* @returns {SoundBank} a sound bank configured with an effect chain | ||
* defined by this AudioEngine | ||
*/ | ||
createBank () { | ||
@@ -260,0 +269,0 @@ return new SoundBank(this, this.createEffectChain()); |
@@ -23,2 +23,6 @@ const Effect = require('./Effect'); | ||
/** | ||
* Return the name of the effect. | ||
* @type {string} | ||
*/ | ||
get name () { | ||
@@ -25,0 +29,0 @@ return 'pan'; |
@@ -38,2 +38,6 @@ const Effect = require('./Effect'); | ||
/** | ||
* Return the name of the effect. | ||
* @type {string} | ||
*/ | ||
get name () { | ||
@@ -40,0 +44,0 @@ return 'pitch'; |
@@ -15,2 +15,6 @@ const Effect = require('./Effect'); | ||
/** | ||
* Return the name of the effect. | ||
* @type {string} | ||
*/ | ||
get name () { | ||
@@ -17,0 +21,0 @@ return 'volume'; |
@@ -24,19 +24,71 @@ const {EventEmitter} = require('events'); | ||
/** | ||
* Unique sound identifier set by AudioEngine. | ||
* @type {string} | ||
*/ | ||
this.id = id; | ||
/** | ||
* AudioEngine creating this sound player. | ||
* @type {AudioEngine} | ||
*/ | ||
this.audioEngine = audioEngine; | ||
/** | ||
* Decoded audio buffer from audio engine for playback. | ||
* @type {AudioBuffer} | ||
*/ | ||
this.buffer = buffer; | ||
/** | ||
* Output audio node. | ||
* @type {AudioNode} | ||
*/ | ||
this.outputNode = null; | ||
/** | ||
* VolumeEffect used to fade out playing sounds when stopping them. | ||
* @type {VolumeEffect} | ||
*/ | ||
this.volumeEffect = null; | ||
/** | ||
* Target engine, effect, or chain this player directly connects to. | ||
* @type {AudioEngine|Effect|EffectChain} | ||
*/ | ||
this.target = null; | ||
/** | ||
* Internally is the SoundPlayer initialized with at least its buffer | ||
* source node and output node. | ||
* @type {boolean} | ||
*/ | ||
this.initialized = false; | ||
/** | ||
* Is the sound playing or starting to play? | ||
* @type {boolean} | ||
*/ | ||
this.isPlaying = false; | ||
/** | ||
* Timestamp sound is expected to be starting playback until. Once the | ||
* future timestamp is reached the sound is considered to be playing | ||
* through the audio hardware and stopping should fade out instead of | ||
* cutting off playback. | ||
* @type {number} | ||
*/ | ||
this.startingUntil = 0; | ||
/** | ||
* Rate to play back the audio at. | ||
* @type {number} | ||
*/ | ||
this.playbackRate = 1; | ||
// handleEvent is a EventTarget api for the DOM, however the web-audio-test-api we use | ||
// uses an addEventListener that isn't compatable with object and requires us to pass | ||
// this bound function instead | ||
// handleEvent is a EventTarget api for the DOM, however the | ||
// web-audio-test-api we use uses an addEventListener that isn't | ||
// compatable with object and requires us to pass this bound function | ||
// instead | ||
this.handleEvent = this.handleEvent.bind(this); | ||
@@ -236,5 +288,5 @@ } | ||
// always do a manual stop on a taken / volume effect fade out sound player | ||
// take will emit "stop" as well as reset all of our playing statuses / remove our | ||
// nodes / etc | ||
// always do a manual stop on a taken / volume effect fade out sound | ||
// player take will emit "stop" as well as reset all of our playing | ||
// statuses / remove our nodes / etc | ||
const taken = this.take(); | ||
@@ -244,3 +296,4 @@ taken.volumeEffect = new VolumeEffect(taken.audioEngine, taken, null); | ||
taken.volumeEffect.connect(taken.target); | ||
// volumeEffect will recursively connect to us if it needs to, so this happens too: | ||
// volumeEffect will recursively connect to us if it needs to, so this | ||
// happens too: | ||
// taken.connect(taken.volumeEffect); | ||
@@ -247,0 +300,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
578048
1.07%4383
3.15%