Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Precise timing based on AsyncProcessor (WIP) #53

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

y-usuzumi
Copy link
Owner

Summary

This PR attempts to provide a unified adapter for CoreAudio and JACK.

  • CoreAudio follows a synchronous workflow where you take care of calling MidiPort.write() at the correct time or give it a precise timestamp for playback later (in the unit of monotonic ticks based on mach_absolute_time.
  • JACK gives you more flexible control by calling your registered callback at every process cycle (based on sample rate, buffer size and period). It is much easier to calculate the offset in the buffer to write base on the beat time.

When the "coreaudio" feature is enabled, a thread will be spawned that calls an audio-framework-agnostic AsyncProcessor at a fixed interval (based on sample rate and buffer size), in which a MIDIAdapter is passed which can be used to write MIDI notes.

When the "jack" feature is enabled, a callback will be registered to JACK that simply calls AsyncProcessor.on_process_cycle().

The MIDIAdapter has different implementations for CoreAudio and JACK (of course).

@y-usuzumi y-usuzumi changed the title Precise timing based on AsyncProcessor Precise timing based on AsyncProcessor (WIP) Feb 4, 2025
@y-usuzumi y-usuzumi force-pushed the yukio/precise-timing branch from d8275b2 to 3f1496a Compare February 21, 2025 21:32
@y-usuzumi y-usuzumi force-pushed the yukio/precise-timing branch from 3f1496a to dedece8 Compare February 22, 2025 22:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant