Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Clock #492

Merged
merged 43 commits into from
Feb 20, 2025
Merged

Clock #492

Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
599383b
empty clock package with test app
funwithtriangles Jan 23, 2025
b77ddb5
basic skeleton for clock test app
funwithtriangles Jan 23, 2025
8618ea6
clock test app with mod/sin/cos
funwithtriangles Jan 23, 2025
c183bca
cycling in time with beat
funwithtriangles Jan 23, 2025
0705c77
extra waveforms
funwithtriangles Jan 23, 2025
f5d28bb
tidy
funwithtriangles Jan 25, 2025
783ae35
tidy
funwithtriangles Jan 25, 2025
6bea326
tidy
funwithtriangles Jan 25, 2025
5619206
tidy
funwithtriangles Jan 25, 2025
daa9884
test app extras
funwithtriangles Jan 25, 2025
80f6448
naive sendTemoTap implementation
funwithtriangles Jan 25, 2025
4939879
better temp tap alg
funwithtriangles Jan 25, 2025
77e1c51
tidy
funwithtriangles Jan 25, 2025
3dc5dab
eslint fix
funwithtriangles Jan 26, 2025
0cc9a4b
tidy
funwithtriangles Jan 26, 2025
d846424
removed build script (was crashing osc)
funwithtriangles Jan 26, 2025
ea4edca
clock test app as own package
funwithtriangles Jan 26, 2025
8dbe2c3
tidy
funwithtriangles Jan 26, 2025
b48cbc7
ts fix
funwithtriangles Jan 26, 2025
e511446
lint config fix
funwithtriangles Jan 26, 2025
af1f0b2
nohoist config tweak
funwithtriangles Jan 26, 2025
c65b26c
midi clock control HTML
funwithtriangles Jan 26, 2025
6ae3aea
midiclockmock pulse
funwithtriangles Jan 26, 2025
00da418
dodgy mock clock pulses
funwithtriangles Jan 26, 2025
344643e
mock clock not good
funwithtriangles Jan 26, 2025
e4797b1
tidy
funwithtriangles Jan 26, 2025
eb2cace
trying to increase accuracy of mock clock
funwithtriangles Jan 26, 2025
200a6cd
startOnNextTimingPulse and other timing pulse related stuff
funwithtriangles Jan 30, 2025
066c6d0
circle pulse
funwithtriangles Jan 30, 2025
8073730
fixed buggy app refresh behaviour
funwithtriangles Jan 31, 2025
383558d
tweaks and MIDI continue handling
funwithtriangles Jan 31, 2025
fe9f38a
timing offset calc every pulse
funwithtriangles Jan 31, 2025
a56b331
continueOnNextTimingPulse
funwithtriangles Jan 31, 2025
0b1f46a
beatPulseComparisonDelta
funwithtriangles Jan 31, 2025
f809017
tidy
funwithtriangles Jan 31, 2025
e9dc8a4
smoothed values
funwithtriangles Jan 31, 2025
8a8a819
nicer smoothing of bpm
funwithtriangles Jan 31, 2025
7a20fdc
readmes
funwithtriangles Feb 20, 2025
fc05d40
fixed tapping bpm display
funwithtriangles Feb 20, 2025
687dccf
nice comments
funwithtriangles Feb 20, 2025
9cb147a
external clock testing tips
funwithtriangles Feb 20, 2025
a7f7172
tidy up for pro tools stuff
funwithtriangles Feb 20, 2025
2117ab4
tidy
funwithtriangles Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tidy
funwithtriangles committed Jan 25, 2025
commit f5d28bba8711f97ecba7b647c597dc13b59ca41e
6 changes: 3 additions & 3 deletions packages/clock/clock-test-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -16,10 +16,10 @@ const $y = (id: string, y: number) =>
function App() {
useEffect(() => {
const update = () => {
const d = clock.getDelta()
const d = clock.delta

document.querySelector('#delta')!.textContent = d.toString()
document.querySelector('#beat')!.textContent = clock.getBeat().toString()
document.querySelector('#beat')!.textContent = clock.beat.toString()

$y('saw', (d * H) % H)
$y('sin', Math.sin(d * TAU) * H * 0.5 + H * 0.5)
@@ -37,7 +37,7 @@ function App() {
<>
<section>
<div className="grid">
<code id="delta">{clock.getDelta()}</code>
<code id="delta"></code>
<button onClick={clock.start}>start</button>
<button onClick={clock.stop}>stop</button>
<button onClick={clock.reset}>reset</button>
10 changes: 7 additions & 3 deletions packages/clock/src/Clock.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ const MS_PER_FRAME = 1000 / 60
const TICK_INTERVAL = MS_PER_FRAME / MS_IN_BEAT

export class Clock {
private beatDelta: number = 0 // Increments every frame, at a rate of exactly 1 per beat
private beatDelta: number = 0 // Increments fractionally every frame, at a rate of exactly 1 per beat
private isRunning: boolean = false
private startTimestamp: number | null = null
private beatCount: number = 0
@@ -24,9 +24,13 @@ export class Clock {
}
}

public getDelta = () => this.beatDelta
get delta() {
return this.beatDelta
}

public getBeat = () => this.beatCount
get beat() {
return this.beatCount
}

public stop = () => {
this.isRunning = false