Socket
Socket
Sign inDemoInstall

@errozero/beatstepper

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.6 to 1.0.7

dist/worker.d.ts

8

Beatstepper.ts

@@ -90,2 +90,6 @@ //Based on article: https://html5rocks.com/en/tutorials/audio/scheduling/

start(){
if(this.playing){
return;
}
this.playing = true;

@@ -100,2 +104,6 @@ this.nextStepTime = this.context.currentTime;

stop(){
if(!this.playing){
return;
}
this.playing = false;

@@ -102,0 +110,0 @@ this.tempoWorker.postMessage({message: 'stop'});

4

dist/Beatstepper.d.ts

@@ -31,7 +31,11 @@ interface IBeatstepperCallbackData {

pause(): void;
getStepsPerBeat(): number;
setStepsPerBeat(steps: number): void;
getBeatsPerBar(): number;
setBeatsPerBar(beats: number): void;
getTempo(): number;
setTempo(tempo: number): void;
getStepLength(): number;
}
export { Beatstepper, IBeatstepperCallbackData };
export default Beatstepper;

38

dist/Beatstepper.js
"use strict";
//Based on article: https://html5rocks.com/en/tutorials/audio/scheduling/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Beatstepper = void 0;
//Web Worker as a string, removes the need to provide a url to a worker file, this dynamically creates one
//https://stackoverflow.com/a/61621269/2347456
var workerCode = "\n let speed = 100;\n let timerID = null;\n onmessage = (e) => {\n //console.log('MESSAGE', e.data);\n\n if(e.data.speed) speed = e.data.speed;\n\n if(e.data.message === 'start'){\n timerID = setInterval(() => {postMessage('pulse')}, speed);\n } \n else if(e.data.message === 'stop'){\n clearInterval(timerID);\n timerID=null;\n }\n }\n";
var workerBlob = new Blob([workerCode], { type: 'application/javascript' });
var worker_1 = __importDefault(require("./worker"));
var Beatstepper = /** @class */ (function () {
function Beatstepper(context, callback) {
var _this = this;
this.scheduleAheadTime = 0.1; //How far ahead to schedule events (in seconds)
this.lookAhead = 25.0; //How frequently to call scheduling (in ms)
this.scheduleAheadTime = 0.18; //How far ahead to schedule events (in seconds)
this.lookAhead = 20.0; //How frequently to call scheduling (in ms)
this.nextStepTime = 0;

@@ -26,3 +26,3 @@ this.currentStep = 0;

this.setStepLength();
this.tempoWorker = new Worker(URL.createObjectURL(workerBlob));
this.tempoWorker = worker_1.default;
this.tempoWorker.postMessage({ speed: this.lookAhead });

@@ -36,3 +36,4 @@ this.tempoWorker.onmessage = function () { _this.scheduler(); };

while (this.nextStepTime < this.context.currentTime + this.scheduleAheadTime) {
//if(!State.playing) return;
if (!this.playing)
return;
this.scheduleStep();

@@ -70,2 +71,5 @@ this.nextStep();

Beatstepper.prototype.start = function () {
if (this.playing) {
return;
}
this.playing = true;

@@ -79,2 +83,5 @@ this.nextStepTime = this.context.currentTime;

Beatstepper.prototype.stop = function () {
if (!this.playing) {
return;
}
this.playing = false;

@@ -88,4 +95,7 @@ this.tempoWorker.postMessage({ message: 'stop' });

this.playing = false;
this.tempoWorker.postMessage({ message: 'pause' });
this.tempoWorker.postMessage({ message: 'stop' });
};
Beatstepper.prototype.getStepsPerBeat = function () {
return this.stepsPerBeat;
};
Beatstepper.prototype.setStepsPerBeat = function (steps) {

@@ -95,2 +105,5 @@ this.stepsPerBeat = steps;

};
Beatstepper.prototype.getBeatsPerBar = function () {
return this.beatsPerBar;
};
Beatstepper.prototype.setBeatsPerBar = function (beats) {

@@ -100,7 +113,12 @@ this.beatsPerBar = beats;

};
Beatstepper.prototype.getTempo = function () {
return this.tempo;
};
Beatstepper.prototype.setTempo = function (tempo) {
this.tempo = tempo;
this.setStepLength();
//this.tempoWorker.postMessage({speed});
};
Beatstepper.prototype.getStepLength = function () {
return this.stepLength;
};
return Beatstepper;

@@ -107,0 +125,0 @@ }());

@@ -7,7 +7,8 @@ {

},
"version": "1.0.6",
"version": "1.0.7",
"description": "",
"main": "dist/Beatstepper.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
},

@@ -14,0 +15,0 @@ "author": "errozero",

@@ -0,0 +0,0 @@ # Beatstepper

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ //Web Worker as a string, removes the need to provide a url to a worker file, this dynamically creates one

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc