mirror of
https://codeberg.org/uzu/strudel
synced 2026-09-05 14:58:03 -04:00
figuring out backend integration
This commit is contained in:
@@ -7,6 +7,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
import createClock from './zyklus.mjs';
|
||||
import { logger } from './logger.mjs';
|
||||
import { Invoke } from '../../website/src/tauri.mjs';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
|
||||
export class Cyclist {
|
||||
constructor({ interval, onTrigger, onToggle, onError, getTime, latency = 0.1 }) {
|
||||
@@ -17,6 +18,24 @@ export class Cyclist {
|
||||
this.lastEnd = 0; // query end of last tick
|
||||
this.getTime = getTime; // get absolute time
|
||||
this.onToggle = onToggle;
|
||||
// this.abeLinkListener = listen('abelink-event', async (e) => {
|
||||
// const payload = e?.payload;
|
||||
// if (payload == null) {
|
||||
// return;
|
||||
// }
|
||||
// const { play, bpm, timestamp } = payload;
|
||||
// console.log('play');
|
||||
|
||||
// if (this.started !== play && play != null) {
|
||||
// if (play) {
|
||||
// this.start();
|
||||
// } else {
|
||||
// this.stop();
|
||||
// }
|
||||
// }
|
||||
|
||||
// const { message, message_type } = e.payload;
|
||||
// });
|
||||
this.latency = latency; // fixed trigger time offset
|
||||
const round = (x) => Math.round(x * 1000) / 1000;
|
||||
this.clock = createClock(
|
||||
|
||||
@@ -128,26 +128,6 @@ function useStrudel({
|
||||
}
|
||||
};
|
||||
|
||||
// useEffect(() => {
|
||||
// async function listenForAbelinkMessage() {
|
||||
// await listen('abelink-event', async (e) => {
|
||||
// const payload = e?.payload;
|
||||
// if (payload == null) {
|
||||
// return;
|
||||
// }
|
||||
// const { play, bpm, timestamp } = payload;
|
||||
// console.log(scheduler.started);
|
||||
|
||||
// if (scheduler.started !== play && play != null) {
|
||||
// togglePlay();
|
||||
// }
|
||||
|
||||
// const { message, message_type } = e.payload;
|
||||
// });
|
||||
// }
|
||||
// listenForAbelinkMessage();
|
||||
// }, []);
|
||||
|
||||
listen('abelink-event', async (e) => {
|
||||
const payload = e?.payload;
|
||||
if (payload == null) {
|
||||
@@ -157,6 +137,7 @@ function useStrudel({
|
||||
|
||||
if (started !== play && play != null) {
|
||||
if (play) {
|
||||
// activateCode();
|
||||
start();
|
||||
} else {
|
||||
stop();
|
||||
|
||||
Reference in New Issue
Block a user