Skip to content

Commit

Permalink
more general purpose kabel function
Browse files Browse the repository at this point in the history
+ kabelgate, kabeltrig, kabelvalue
  • Loading branch information
felixroos committed Jan 15, 2025
1 parent 1acd848 commit e80c1cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion kabelsalat.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
}
window.parent.kabelsalat = kabelsalat;

window.klok = cc('klok').trig();
window.kabelgate = (id) => cc(`kabelgate-${id}`);
window.kabeltrig = (id) => kabelgate(id).trig();
window.kabelvalue = (id) => cc(`kabelvalue-${id}`);

console.log('[kabelsalat] waiting for document click to init');
window.parent.document.addEventListener('click', async function interaction() {
Expand Down
9 changes: 5 additions & 4 deletions src/strudel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { getAudioContext, initAudio, registerSynthSounds, samples, webaudioOutpu

controls.createParam('docId');

window.klok = register('klok', (pat) => {
window.kabel = register('kabel', (id, pat) => {
return pat.onTrigger((_, hap, ct, cps, t) => {
const onset = t - ct;
const offset = onset + 0.05;
const offset = onset + hap.duration / cps - 0.05;
parent.kabelsalat.audio.setControls([
{ id: 'klok', time: onset, value: 1 },
{ id: 'klok', time: offset, value: 0 },
{ id: `kabelgate-${id}`, time: onset, value: 1 },
{ id: `kabelgate-${id}`, time: offset, value: 0 },
{ id: `kabelvalue-${id}`, time: onset, value: hap.value.value },
]);
});
});
Expand Down

0 comments on commit e80c1cc

Please sign in to comment.