How to create/program rhythm-based mechanics using Quartz?

Hi everyone,

I am trying to program a rhythm mechanic for a school assessment with Quartz as the source of truth for timing and playing audio. After numerous hours looking through google search results and youtube vidoes, I’m feeling fairly confident about setting up the clock, subscribing to events, and playing back quantized audio, but there don’t appear to be any guides/tutorials/resources on how to setup any other part of the mechanic. Has anyone does this before or know where to find a good tutorial/guide or documentation on how these types of mechanics are programmed? Thanks in advance for your help.

quartz works well as the source of truth — the part nobody documents is that rhythm mechanics need both of its layers:

grid layer: quantized events. subscribe to the clock’s beat/bar callbacks — these are your measure ticks. spawn judgment windows, advance the note-chart cursor, and trigger lane visuals from these, never from tick.

continuous layer: the audio clock. the clock handle gives you the current time in song-space; that is what you compare player input against. never judge hits on quantized events — an input between beats would round onto the wrong one. on input: read clock time, convert to beats (time x bpm / 60), compare against the target note’s beat with your hit-window expressed in beats or milliseconds.

two things that make or break it: (1) latency compensation — input arrives late by audio output latency plus device latency; store a constant offset and let players calibrate it with a slider, like every shipped rhythm game does. (2) visuals must lead audio — drive the note highway from clock time plus a lookahead equal to the audio latency, so notes align with what players hear from the speakers, not with when the engine schedules the sample.

keep the chart data-driven (a plain struct array: beat, lane, type) and the quartz clock as the only clock — everything else interpolates between its callbacks. that architecture scales from a school assessment to a full game, and it avoids the classic death spiral of mixing engine time with audio time.