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
510
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.20231215224619

8

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

@@ -31,7 +31,7 @@ "main": "dist.js",

"babel-core": "6.26.3",
"babel-eslint": "7.2.3",
"babel-eslint": "10.1.0",
"babel-loader": "7.1.5",
"babel-preset-env": "1.7.0",
"eslint": "3.19.0",
"eslint-config-scratch": "3.1.0",
"eslint": "8.0.1",
"eslint-config-scratch": "9.0.3",
"json": "9.0.6",

@@ -38,0 +38,0 @@ "tap": "12.7.0",

@@ -92,3 +92,3 @@ const ArrayBufferStream = require('./ArrayBufferStream');

* @param {ArrayBuffer} audioData - containing ADPCM encoded wav audio
* @return {AudioBuffer} the decoded audio buffer
* @return {Promise.<AudioBuffer>} the decoded audio buffer
*/

@@ -103,3 +103,3 @@ decode (audioData) {

log.warn('incorrect adpcm wav header');
reject();
reject(new Error('incorrect adpcm wav header'));
}

@@ -115,3 +115,3 @@

log.warn('incorrect adpcm wav header');
reject();
reject(new Error('incorrect adpcm wav header'));
}

@@ -126,3 +126,3 @@

this.bitsPerSample = formatChunk.readUint16();
formatChunk.position += 2; // skip extra header byte count
formatChunk.position += 2; // skip extra header byte count
this.samplesPerBlock = formatChunk.readUint16();

@@ -175,3 +175,3 @@ this.adpcmBlockSize = ((this.samplesPerBlock - 1) / 2) + 4; // block size in bytes

// Number of samples in full blocks.
const fullBlocks = blocks * (2 * (blockSize - 4)) + 1;
const fullBlocks = (blocks * (2 * (blockSize - 4))) + 1;
// Number of samples in the last incomplete block. 0 if the last block

@@ -224,3 +224,3 @@ // is full.

code = lastByte & 0xF;
delta = DELTA_TABLE[index * 16 + code];
delta = DELTA_TABLE[(index * 16) + code];
// compute next index

@@ -239,3 +239,3 @@ index += INDEX_TABLE[code];

code = (lastByte >> 4) & 0xF;
delta = DELTA_TABLE[index * 16 + code];
delta = DELTA_TABLE[(index * 16) + code];
// compute next index

@@ -242,0 +242,0 @@ index += INDEX_TABLE[code];

@@ -98,3 +98,2 @@ class ArrayBufferStream {

this._position = value + this.start;
return value;
}

@@ -101,0 +100,0 @@

@@ -221,3 +221,3 @@ const StartAudioContext = require('./StartAudioContext');

return this._decodeSound(sound)
.then(([id, buffer]) => new SoundPlayer(this, {id, buffer}));
.then(([id, buffer]) => new SoundPlayer(this, {id, buffer}));
}

@@ -224,0 +224,0 @@

@@ -5,3 +5,3 @@ /**

class Effect {
/**
/**
* @param {AudioEngine} audioEngine - audio engine this runs with

@@ -8,0 +8,0 @@ * @param {AudioPlayer} audioPlayer - audio player this affects

@@ -121,3 +121,3 @@ const Effect = require('./Effect');

for (const id in players) {
if (players.hasOwnProperty(id)) {
if (Object.prototype.hasOwnProperty.call(players, id)) {
this.updatePlayer(players[id]);

@@ -124,0 +124,0 @@ }

@@ -47,5 +47,5 @@ const log = require('./log');

})
.catch(err => {
log.warn(err);
});
.catch(err => {
log.warn(err);
});
}

@@ -52,0 +52,0 @@

@@ -153,3 +153,3 @@ const log = require('./log');

for (const soundId in this.soundPlayers) {
if (this.soundPlayers.hasOwnProperty(soundId)) {
if (Object.prototype.hasOwnProperty.call(this.soundPlayers, soundId)) {
this.soundPlayers[soundId].dispose();

@@ -156,0 +156,0 @@ }

@@ -160,47 +160,47 @@ /* global Uint8Array Promise */

return Promise.resolve()
.then(() => {
.then(() => {
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
soundPlayer.play();
soundPlayer.finished().then(() => log.push('play 2 finished'));
soundPlayer.play();
soundPlayer.finished().then(() => log.push('play 2 finished'));
// wait for a micro-task loop to fire our previous events
return Promise.resolve();
})
.then(() => {
// wait for a micro-task loop to fire our previous events
return Promise.resolve();
})
.then(() => {
t.equal(log[0], 'play 1 finished');
t.notEqual(soundPlayer.outputNode, firstPlayNode, 'created new player node');
t.equal(log[0], 'play 1 finished');
t.notEqual(soundPlayer.outputNode, firstPlayNode, 'created new player node');
t.equal(help.engineInputs.length, 2, 'there should be 2 players connected');
t.equal(firstPlayNode.$state, 'PLAYING');
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(help.engineInputs[0].gain.value, 1, 'old sound connectect to gain node with volume 1');
t.equal(help.engineInputs.length, 2, 'there should be 2 players connected');
t.equal(firstPlayNode.$state, 'PLAYING');
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(help.engineInputs[0].gain.value, 1, 'old sound connectect to gain node with volume 1');
const {currentTime} = audioContext;
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + 0.001);
t.notEqual(help.engineInputs[0].gain.value, 1,
'old sound connected to gain node which will fade');
const {currentTime} = audioContext;
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + 0.001);
t.notEqual(help.engineInputs[0].gain.value, 1,
'old sound connected to gain node which will fade');
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.001);
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(firstPlayNode.$state, 'FINISHED');
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.001);
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(firstPlayNode.$state, 'FINISHED');
t.equal(help.engineInputs[0].gain.value, 0, 'faded old sound to 0');
t.equal(help.engineInputs[0].gain.value, 0, 'faded old sound to 0');
t.equal(log.length, 1);
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.3);
t.equal(log.length, 1);
audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.3);
// wait for a micro-task loop to fire our previous events
return Promise.resolve();
})
.then(() => {
// wait for a micro-task loop to fire our previous events
return Promise.resolve();
})
.then(() => {
t.equal(log[1], 'play 2 finished');
t.equal(help.engineInputs.length, 1, 'old sound disconneted itself after done');
t.equal(log.length, 2);
t.equal(log[1], 'play 2 finished');
t.equal(help.engineInputs.length, 1, 'old sound disconneted itself after done');
t.equal(log.length, 2);
t.end();
});
t.end();
});
});

@@ -207,0 +207,0 @@

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

Sorry, the diff of this file is not supported yet