You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

scratch-audio

Package Overview
Dependencies
Maintainers
1
Versions
508
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scratch-audio - npm Package Compare versions

Comparing version

to
0.1.0-prerelease.1486753780

2

package.json
{
"name": "scratch-audio",
"version": "0.1.0-prerelease.1486075498",
"version": "0.1.0-prerelease.1486753780",
"description": "audio engine for scratch 3.0",

@@ -5,0 +5,0 @@ "main": "dist.js",

@@ -94,11 +94,12 @@ var log = require('./log');

/**
* Play a note for a duration on an instrument
* Play a note for a duration on an instrument with a volume
* @param {number} note - a MIDI note number
* @param {number} beats - a duration in beats
* @param {number} inst - an instrument number (0-indexed)
* @param {number} vol - a volume level (0-100%)
* @return {Promise} a Promise that resolves after the duration has elapsed
*/
AudioEngine.prototype.playNoteForBeatsWithInst = function (note, beats, inst) {
AudioEngine.prototype.playNoteForBeatsWithInstAndVol = function (note, beats, inst, vol) {
var sec = this.beatsToSec(beats);
this.instrumentPlayer.playNoteForSecWithInst(note, sec, inst);
this.instrumentPlayer.playNoteForSecWithInstAndVol(note, sec, inst, vol);
return this.waitForBeats(beats);

@@ -105,0 +106,0 @@ };

@@ -37,8 +37,13 @@ var Tone = require('tone');

* @param {number} instrumentNum - an instrument number (0-indexed)
* @param {number} vol - a volume level (0-100%)
*/
InstrumentPlayer.prototype.playNoteForSecWithInst = function (note, sec, instrumentNum) {
InstrumentPlayer.prototype.playNoteForSecWithInstAndVol = function (note, sec, instrumentNum, vol) {
var gain = vol / 100;
this.loadInstrument(instrumentNum)
.then(() => {
this.instruments[instrumentNum].play(
note, Tone.context.currentTime, {duration : sec}
note, Tone.context.currentTime, {
duration : sec,
gain : gain
}
);

@@ -45,0 +50,0 @@ });

Sorry, the diff of this file is too big to display