This commit is contained in:
alex 2022-06-17 14:45:58 +01:00
parent 34ba762b42
commit 23be3e5ba3
2 changed files with 9 additions and 4 deletions

View File

@ -744,6 +744,11 @@ const generic_params = [
['f', 'uid', ''],
['f', 'val', ''],
['f', 'cps', ''],
['s', 'action', ''],
['f', 'by', ''],
['s', 'part', ''],
['f', 'to', ''],
['f', 'duration', ''],
];
// TODO: slice / splice https://www.youtube.com/watch?v=hKhPdO0RKDQ&list=PL2lW1zNIIwj3bDkh-Y3LUGDuRcoUigoDs&index=13

View File

@ -34,7 +34,6 @@ export async function getWriter(br=115200) {
const latency = 0.1;
// Pattern.prototype.midi = function (output: string | number, channel = 1) {
Pattern.prototype.serial = async function (...args) {
return this._withHap((hap) => {
if (!serialWriter) {
@ -43,11 +42,11 @@ Pattern.prototype.serial = async function (...args) {
const onTrigger = (time, hap, currentTime) => {
var message = "";
if (typeof hap.value === 'object') {
if ('what' in hap.value) {
message += hap.value['what'] + '(';
if ('action' in hap.value) {
message += hap.value['action'] + '(';
var first = true;
for (const [key, val] of Object.entries(hap.value)) {
if (key === 'what') {
if (key === 'action') {
continue;
}
if (first) {
@ -69,6 +68,7 @@ Pattern.prototype.serial = async function (...args) {
else {
message = hap.value;
}
console.log("sending: " + message);
const offset = (time - currentTime + latency) * 1000;
window.setTimeout(serialWriter, offset, message);
};