Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple beats/refactor #2

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
11 changes: 6 additions & 5 deletions metronome.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ class Metronome {
}

// This allows output of the notesInQueue array to sync with graphics
aListener(val) {};
registerListener(listener) {
this.aListener = listener;
}
// aListener(val) {};
// registerListener(listener) {
// this.aListener = listener;
// }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you Delete all of this to avoid


_scheduleSamples(beatNumber, time) {

this._notesInQueue.push({ note: beatNumber, time: time });
this.aListener(this._notesInQueue, audioCtx.currentTime, this._samplesArray[0].name)
if (this._notesInQueue.length >= this._timeSigniture) this._notesInQueue.splice(0,1);

if (this._accentChecked && this._samplesArray.length >= 2) {
if (beatNumber === this._timeSigniture - 1) this._playSample(audioCtx, this._samplesArray[1].audioBuffer, this._noteVolumes[beatNumber]);
else this._playSample(audioCtx, this._samplesArray[0].audioBuffer, this._noteVolumes[beatNumber]);
Expand Down Expand Up @@ -213,7 +214,7 @@ class Metronome {
return Promise.all(urlArray.map(async path => {
let sampleHolder = {};
sampleHolder.audioBuffer = await this._loadSound(audioCtx, path);
sampleHolder.name = path.match(/([^\/]+)(?=\.\w+$)/)[0].replace(/-/, '_');
sampleHolder.name = path.match(/\/([^\/]+)\/?$/)[1].replace(/-/, '_');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was supposed to change this method.. But ill make those changes into mine so we avoid conflicts

return sampleHolder;
}))
.then(data => data);
Expand Down