Skip to content

Commit

Permalink
WIP callback for adding notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
severak2 committed Sep 11, 2024
1 parent e5e73dc commit 50c530a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions groovebox.html
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ <h1>Severák's ideal Groovebox</h1>

me.patterns = {A: [], B: [], C:[], D:[], E:[], F:[], G:[], H:[]};

me.pianoroll.addedNoteCallback(function (n){
me.synth.noteOn(n);
setTimeout(function (){me.synth.noteOff(n);}, 500);
});

me.start = function (){
me.running = true;
me.step = 0;
Expand Down
9 changes: 8 additions & 1 deletion js/webaudio-pianoroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ customElements.define("webaudio-pianoroll", class Pianoroll extends HTMLElement
this[v.observer]();
}
});
}
}
}
connectedCallback(){
let root;
Expand Down Expand Up @@ -434,6 +434,9 @@ customElements.define("webaudio-pianoroll", class Pianoroll extends HTMLElement
};
this.addNote=function(t,n,g,v,f){
if(t>=0 && n>=0 && n<128){
if (this.noteAddCallback) {
this.noteAddCallback(n);
}
const ev={t:t,c:0x90,n:n,g:g,v:v,f:f};
this.sequence.push(ev);
this.sortSequence();
Expand Down Expand Up @@ -1159,4 +1162,8 @@ customElements.define("webaudio-pianoroll", class Pianoroll extends HTMLElement
return v;
}
disconnectedCallback(){}

addedNoteCallback(callback) {
this.noteAddCallback = callback;
}
});

0 comments on commit 50c530a

Please sign in to comment.