mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-28 05:58:28 +00:00
Merge pull request #141 from tidalcycles/serial-twiddles
Serial twiddles
This commit is contained in:
commit
a708265e14
@ -9,7 +9,7 @@ import { Pattern, isPattern } from '@strudel.cycles/core';
|
|||||||
var serialWriter;
|
var serialWriter;
|
||||||
var choosing = false;
|
var choosing = false;
|
||||||
|
|
||||||
export async function getWriter(br=115200) {
|
export async function getWriter(br=38400) {
|
||||||
if (choosing) {
|
if (choosing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,8 +34,7 @@ export async function getWriter(br=115200) {
|
|||||||
|
|
||||||
const latency = 0.1;
|
const latency = 0.1;
|
||||||
|
|
||||||
// Pattern.prototype.midi = function (output: string | number, channel = 1) {
|
Pattern.prototype.serial = function (...args) {
|
||||||
Pattern.prototype.serial = async function (...args) {
|
|
||||||
return this._withHap((hap) => {
|
return this._withHap((hap) => {
|
||||||
if (!serialWriter) {
|
if (!serialWriter) {
|
||||||
getWriter(...args);
|
getWriter(...args);
|
||||||
@ -43,8 +42,27 @@ Pattern.prototype.serial = async function (...args) {
|
|||||||
const onTrigger = (time, hap, currentTime) => {
|
const onTrigger = (time, hap, currentTime) => {
|
||||||
var message = "";
|
var message = "";
|
||||||
if (typeof hap.value === 'object') {
|
if (typeof hap.value === 'object') {
|
||||||
for (const [key, val] of Object.entries(hap.value).flat()) {
|
if ('action' in hap.value) {
|
||||||
message += `${key}:${val};`
|
message += hap.value['action'] + '(';
|
||||||
|
var first = true;
|
||||||
|
for (const [key, val] of Object.entries(hap.value)) {
|
||||||
|
if (key === 'action') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message +=',';
|
||||||
|
}
|
||||||
|
message += `${key}:${val}`
|
||||||
|
}
|
||||||
|
message += ')';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (const [key, val] of Object.entries(hap.value)) {
|
||||||
|
message += `${key}:${val};`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user