Merge pull request #1146 from tidalcycles/midi-error-msg

handle midin device not found error
This commit is contained in:
Felix Roos 2024-09-14 10:43:17 +02:00 committed by GitHub
commit 2d72c8faa0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -169,13 +169,18 @@ const refs = {};
export async function midin(input) {
if (isPattern(input)) {
throw new Error(
`.midi does not accept Pattern input. Make sure to pass device name with single quotes. Example: .midi('${
`midin: does not accept Pattern as input. Make sure to pass device name with single quotes. Example: midin('${
WebMidi.outputs?.[0]?.name || 'IAC Driver Bus 1'
}')`,
);
}
const initial = await enableWebMidi(); // only returns on first init
const device = getDevice(input, WebMidi.inputs);
if (!device) {
throw new Error(
`midiin: device "${input}" not found.. connected devices: ${getMidiDeviceNamesString(WebMidi.inputs)}`,
);
}
if (initial) {
const otherInputs = WebMidi.inputs.filter((o) => o.name !== device.name);
logger(