Skip to content

[Metronome] Ictus detection timestamp ignored in ConductorService #22

Description

@hakaru

概要

ConductorService.handleDetectedBeat において、実際の ictus 検知時刻(BeatDetected.hostTime)が無視され、メソッド実行時の現在時刻を基準にクリックの適用時刻(applyAtNs)が計算されています。

詳細

ConductorService.swift の handleDetectedBeat 実装:

private func handleDetectedBeat(_ beat: BeatDetected) async {
    let hostNow = mach_absolute_time()
    let syncedNow = syncedNowProvider()
    let applyAtNs = syncedNow + Self.leadTimeNs
    // ...
}

AsyncStream や Task のスケジューリング遅延が発生した場合、その遅延分だけメトロノームのクリック音が ictus から遅れてしまいます。指揮モードの正確性を期すため、検知された時点の正確なタイムスタンプ(beat.hostTime)を基準に将来の適用時刻を算出する必要があります。

期待される動作

beat.hostTime を基準に、マシンの monotonic clock と同期クロックのオフセットを考慮して applyAtNs を決定する。

優先度

High

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions