scratch-audioengine
Advanced tools
Comparing version 0.1.0-prerelease.1478119073 to 0.1.0-prerelease.1478707222
{ | ||
"name": "scratch-audioengine", | ||
"version": "0.1.0-prerelease.1478119073", | ||
"version": "0.1.0-prerelease.1478707222", | ||
"description": "audio engine for scratch 3.0", | ||
@@ -36,5 +36,3 @@ "main": "dist.js", | ||
}, | ||
"dependencies": { | ||
"vocoder": "^0.1.1" | ||
} | ||
"dependencies": {} | ||
} |
var log = require('./log'); | ||
var Tone = require('tone'); | ||
var Soundfont = require('soundfont-player'); | ||
// var Soundfont = require('soundfont-player'); | ||
var Vocoder = require('./vocoder'); | ||
@@ -17,4 +18,5 @@ function AudioEngine (sounds) { | ||
this.reverb = new Tone.Freeverb(); | ||
this.distortion = new Tone.Distortion(); | ||
this.distortion = new Tone.Distortion(1); | ||
this.pitchEffectValue; | ||
this.vocoder = new Vocoder(); | ||
@@ -25,3 +27,3 @@ // the effects are chained to an effects node for this clone, then to the master output | ||
this.effectsNode = new Tone.Gain(); | ||
this.effectsNode.chain(this.distortion, this.delay, this.panner, this.reverb, Tone.Master); | ||
this.effectsNode.chain(this.vocoder, this.distortion, this.delay, this.panner, this.reverb, Tone.Master); | ||
@@ -46,2 +48,3 @@ // reset effects to their default parameters | ||
this.instrumentNum; | ||
this.setInstrument(0); | ||
@@ -109,5 +112,22 @@ | ||
AudioEngine.prototype.playNoteForBeats = function (note, beats) { | ||
this.instrument.play( | ||
note, Tone.context.currentTime, {duration : Number(beats)} | ||
); | ||
// this.instrument.play( | ||
// note, Tone.context.currentTime, {duration : Number(beats)} | ||
// ); | ||
// if the soundplayer exists and its buffer has loaded | ||
if (this.soundPlayers[this.instrumentNum] && this.soundPlayers[this.instrumentNum].buffer.loaded) { | ||
// create a new buffer source to play the sound | ||
var bufferSource = new Tone.BufferSource(this.soundPlayers[this.instrumentNum].buffer.get()); | ||
bufferSource.connect(this.effectsNode); | ||
bufferSource.start('+0', 0, beats); | ||
var ratio = this.tone.intervalToFrequencyRatio(note - 60); | ||
bufferSource.playbackRate.value = ratio; | ||
return new Promise(function (resolve) { | ||
setTimeout( function () { | ||
resolve(); | ||
}, 1000 * beats); | ||
}); | ||
} | ||
}; | ||
@@ -182,7 +202,7 @@ | ||
break; | ||
case 'DISTORTION' : | ||
case 'FUZZ' : | ||
this.distortion.wet.value = value / 100; | ||
break; | ||
case 'ROBOTIC' : | ||
// vocoder effect? | ||
this.vocoder.wet.value = value / 100; | ||
break; | ||
@@ -209,3 +229,3 @@ } | ||
break; | ||
case 'DISTORTION' : | ||
case 'FUZZ' : | ||
this.distortion.wet.value += value / 100; | ||
@@ -215,3 +235,4 @@ this.distortion.wet.value = this._clamp(this.distortion.wet.value, 0, 1); | ||
case 'ROBOTIC' : | ||
// vocoder effect? | ||
this.vocoder.wet.value += value / 100; | ||
this.vocoder.wet.value = this._clamp(this.vocoder.wet.value, 0, 1); | ||
break; | ||
@@ -235,2 +256,5 @@ | ||
} | ||
var freq = this._getPitchRatio() * Tone.Frequency('C3').eval(); | ||
this.vocoder.setCarrierOscFrequency(freq); | ||
}; | ||
@@ -243,2 +267,4 @@ | ||
AudioEngine.prototype.setInstrument = function (instrumentNum) { | ||
this.instrumentNum = instrumentNum; | ||
/* | ||
return Soundfont.instrument(Tone.context, this.instrumentNames[instrumentNum]).then( | ||
@@ -250,2 +276,3 @@ function (inst) { | ||
); | ||
*/ | ||
}; | ||
@@ -259,2 +286,3 @@ | ||
this.distortion.wet.value = 0; | ||
this.vocoder.wet.value = 0; | ||
@@ -261,0 +289,0 @@ this.effectsNode.gain.value = 1; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
17
0
0
792079
22994
- Removedvocoder@^0.1.1
- Removedvocoder@0.1.1(transitive)