mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 05:38:35 +00:00
add sysex handler to midicmd
This commit is contained in:
parent
52d1443cf8
commit
20dcae68c1
@ -311,6 +311,21 @@ Pattern.prototype.midi = function (output) {
|
||||
}
|
||||
device.sendControlChange(midicmd[0], midicmd[1], midichan, { time: timeOffsetString });
|
||||
}
|
||||
} else if (midicmd[0] === 'sysex') {
|
||||
if (midicmd.length === 3) {
|
||||
const [_, id, data] = midicmd;
|
||||
if (Array.isArray(id)) {
|
||||
if (!id.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
||||
throw new Error('all sysex id bytes must be integers between 0 and 255');
|
||||
}
|
||||
} else if (!Number.isInteger(id) || id < 0 || id > 255) {
|
||||
throw new Error('sysex id must be a number between 0 and 255 or an array of such integers');
|
||||
}
|
||||
if (!Array.isArray(data) || !data.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
||||
throw new Error('sysex data must be an array of integers between 0 and 255');
|
||||
}
|
||||
device.sendSysex(id, data, { time: timeOffsetString });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user