scratch-audioengine
Advanced tools
Comparing version 0.1.0-prerelease.1476387439 to 0.1.0-prerelease.1476480694
{ | ||
"name": "scratch-audioengine", | ||
"version": "0.1.0-prerelease.1476387439", | ||
"version": "0.1.0-prerelease.1476480694", | ||
"description": "audio engine for scratch 3.0", | ||
@@ -5,0 +5,0 @@ "main": "dist.js", |
# scratch-audioengine | ||
#### Scratch audio engine is for playing sounds, instruments and audio effects in Scratch 3.0 projects | ||
#### Please note this project is at an early stage and we are not ready for pull requests | ||
[![Build Status](https://travis-ci.com/LLK/scratch-audioengine.svg?token=KcCHRot8oJYS4bsz1qET&branch=master)](https://travis-ci.com/LLK/scratch-audioengine) | ||
@@ -5,0 +7,0 @@ |
var Tone = require('tone'); | ||
var Soundfont = require('soundfont-player'); | ||
function AudioEngine () { | ||
function AudioEngine (sounds) { | ||
@@ -28,4 +28,5 @@ // tone setup | ||
this.soundSamplers = []; | ||
this.loadSounds(sounds); | ||
// soundfont setup | ||
// soundfont setup | ||
@@ -46,2 +47,11 @@ // instrument names used by Musyng Kite soundfont, in order to | ||
AudioEngine.prototype.loadSounds = function (sounds) { | ||
for (var i=0; i<sounds.length; i++) { | ||
var url = sounds[i].fileUrl; | ||
var sampler = new Tone.Sampler(url, function () { | ||
this.soundSamplers[url] = sampler; | ||
}.bind(this)).toMaster(); | ||
} | ||
}; | ||
AudioEngine.prototype.playSound = function (soundNum) { | ||
@@ -149,9 +159,2 @@ this.soundSamplers[soundNum].triggerAttack(); | ||
AudioEngine.prototype.loadSounds = function (sounds) { | ||
for (var sound in sounds) { | ||
var sampler = new Tone.Sampler(sound.fileUrl).toMaster(); | ||
this.soundSamplers[sound.fileUrl] = sampler; | ||
} | ||
}; | ||
AudioEngine.prototype._clamp = function (input, min, max) { | ||
@@ -158,0 +161,0 @@ return Math.min(Math.max(input, min), max); |
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
803787
23381
29