Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scratch-audioengine

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scratch-audioengine - npm Package Compare versions

Comparing version 0.1.0-prerelease.1478119073 to 0.1.0-prerelease.1478707222

src/vocoder.js

6

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc