mirror of
https://codeberg.org/uzu/strudel
synced 2026-09-05 22:58:09 -04:00
fix clock being set to 0
This commit is contained in:
@@ -36,7 +36,9 @@ export class CyclistBridge extends Cyclist {
|
||||
|
||||
logger('[cyclist] start');
|
||||
this.clock.start();
|
||||
|
||||
this.setStarted(true);
|
||||
console.log('clock duration: ', this.clock.interval);
|
||||
}, timestamp - Date.now() - evaluationTime);
|
||||
} else {
|
||||
this.stop();
|
||||
@@ -52,13 +54,13 @@ export class CyclistBridge extends Cyclist {
|
||||
let x = Date.now();
|
||||
const linkmsg = {
|
||||
// TODO: change this to value of "main" clock cps
|
||||
cps: 0.5,
|
||||
cps: 0,
|
||||
started: true,
|
||||
timestamp: Date.now(),
|
||||
phase: this.clock.getPhase(),
|
||||
};
|
||||
Invoke('sendabelinkmsg', { linkmsg }).then(() => {
|
||||
logger(`${Date.now() - x}`);
|
||||
logger(`invoke delay: ${Date.now() - x}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ export class CyclistBridge extends Cyclist {
|
||||
this.setStarted(false);
|
||||
const linkmsg = {
|
||||
// TODO: change this to value of "main" clock cps
|
||||
cps: 0.5,
|
||||
cps: 0,
|
||||
started: false,
|
||||
timestamp: Date.now(),
|
||||
phase: this.clock.getPhase(),
|
||||
|
||||
@@ -137,7 +137,7 @@ pub fn init(_logger: Logger, abelink: Arc<Mutex<AbeLinkState>>) {
|
||||
if started != prev_is_started {
|
||||
state.send_started();
|
||||
prev_is_started = started;
|
||||
} else if state.cps() != prev_cps {
|
||||
} else if state.cps() != prev_cps && state.cps() != 0.0 {
|
||||
state.send_cps();
|
||||
prev_cps = state.cps();
|
||||
// a phase sync message needs to be sent to strudel every 30 seconds to keep clock drift at bay
|
||||
@@ -166,7 +166,7 @@ pub async fn sendabelinkmsg(linkmsg: LinkMsg, state: tauri::State<'_, AbeLinkSta
|
||||
if linkmsg.started != started {
|
||||
abelink.session_state.set_is_playing_and_request_beat_at_time(linkmsg.started, time_stamp as u64, 0.0, quantum);
|
||||
}
|
||||
if linkmsg_bpm != abelink.session_state.tempo() {
|
||||
if linkmsg_bpm != abelink.session_state.tempo() && linkmsg_bpm != 0.0 {
|
||||
abelink.session_state.set_tempo(linkmsg_bpm, time_stamp);
|
||||
}
|
||||
abelink.commit_app_state();
|
||||
|
||||
Reference in New Issue
Block a user