mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 04:58:27 +00:00
webaudio error handling
This commit is contained in:
parent
0c08919bfa
commit
5ea2124e91
@ -95,7 +95,7 @@ const getSampleBufferSource = async (s, n, note) => {
|
|||||||
}
|
}
|
||||||
const bank = samples?.[s];
|
const bank = samples?.[s];
|
||||||
if (!bank) {
|
if (!bank) {
|
||||||
throw new Error('sample not found:', s, 'try one of ' + Object.keys(samples));
|
throw new Error(`sample not found: "${s}", try one of ${Object.keys(samples).join(', ')}`);
|
||||||
}
|
}
|
||||||
if (typeof bank !== 'object') {
|
if (typeof bank !== 'object') {
|
||||||
throw new Error('wrong format for sample bank:', s);
|
throw new Error('wrong format for sample bank:', s);
|
||||||
@ -142,6 +142,11 @@ const splitSN = (s, n) => {
|
|||||||
export const webaudioOutput = async (hap, deadline, hapDuration) => {
|
export const webaudioOutput = async (hap, deadline, hapDuration) => {
|
||||||
try {
|
try {
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
|
if (typeof hap.value !== 'object') {
|
||||||
|
throw new Error(
|
||||||
|
`hap.value ${hap.value} is not supported by webaudio output. Hint: append .note() or .s() to the end`,
|
||||||
|
);
|
||||||
|
}
|
||||||
// calculate correct time (tone.js workaround)
|
// calculate correct time (tone.js workaround)
|
||||||
const t = ac.currentTime + deadline;
|
const t = ac.currentTime + deadline;
|
||||||
// destructure value
|
// destructure value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user