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.3 to 1.0.4

worker.ts

31

Beatstepper.ts
//Based on article: https://html5rocks.com/en/tutorials/audio/scheduling/
//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
import tempoWorker from './worker';
const workerCode = `
let speed = 100;
let timerID = null;
onmessage = (e) => {
//console.log('MESSAGE', e.data);
if(e.data.speed) speed = e.data.speed;
if(e.data.message === 'start'){
timerID = setInterval(() => {postMessage('pulse')}, speed);
}
else if(e.data.message === 'stop'){
clearInterval(timerID);
timerID=null;
}
}
`;
const workerBlob = new Blob([workerCode], {type: 'application/javascript'})
interface IBeatstepperCallbackData {

@@ -40,5 +19,5 @@ step: number,

private tempoWorker: Worker;
private scheduleAheadTime = 0.18; //How far ahead to schedule events (in seconds)
private lookAhead = 20.0; //How frequently to call scheduling (in ms)
private nextStepTime = 0;
private scheduleAheadTime = 0.18; //How far ahead to schedule events (in seconds)
private lookAhead = 20.0; //How frequently to call scheduling (in ms)
private nextStepTime = 0;
private currentStep = 0;

@@ -59,3 +38,3 @@ private currentBeat = 0;

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

@@ -62,0 +41,0 @@ this.tempoWorker.onmessage = () => {this.scheduler()};

@@ -7,3 +7,3 @@ {

},
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -19,6 +19,6 @@ "main": "dist/Beatstepper.js",

"keywords": [
"webaudio",
"scheduler",
"web audio"
"webaudio",
"scheduler",
"web audio"
]
}
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