export webaudio out as separate function
This commit is contained in:
parent
e77129fa51
commit
ee84b4e013
1 changed files with 151 additions and 148 deletions
|
|
@ -124,13 +124,12 @@ const splitSN = (s, n) => {
|
||||||
return [s2, n2];
|
return [s2, n2];
|
||||||
};
|
};
|
||||||
|
|
||||||
Pattern.prototype.out = function () {
|
// export const webaudioOutput = async (t, hap, ct, cps) => {
|
||||||
return this.onTrigger(async (t, hap, ct, cps) => {
|
export const webaudioOutput = async (hap, deadline, hapDuration) => {
|
||||||
const hapDuration = hap.duration / cps;
|
|
||||||
try {
|
try {
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
// calculate correct time (tone.js workaround)
|
// calculate correct time (tone.js workaround)
|
||||||
t = ac.currentTime + t - ct;
|
const t = ac.currentTime + deadline;
|
||||||
// destructure value
|
// destructure value
|
||||||
let {
|
let {
|
||||||
freq,
|
freq,
|
||||||
|
|
@ -272,5 +271,9 @@ Pattern.prototype.out = function () {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('.out error:', e);
|
console.warn('.out error:', e);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
Pattern.prototype.out = function () {
|
||||||
|
// TODO: refactor (t, hap, ct, cps) to (hap, deadline, duration) ?
|
||||||
|
return this.onTrigger((t, hap, ct, cps) => webaudioOutput(hap, t - ct, hap.duration / cps));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue