-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* roadmap update * do not attach currentTick/currentMeasure to metronome reader * remove not-very-useful MetronomeControls component * use dependency arrays correctly in effects * Refactor Metronome: - extract Clock worker into new Clock component - pass Clock worker to children, rather than a complex Metronome controls * remove metronome props from Track; use clock instead * move KeyboardBindingsList to App * move `worklets` directory to `workers` * move Track control components into directory * remove console log * HTML/manifest updates * Encapsulate beat counter listener/state into component * use recording length from recorder event * remove extraneous state * fix muting bug on loop start * handle NaNs in waveform * update roadmap
- Loading branch information
Showing
36 changed files
with
327 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useMemo } from 'react' | ||
import { Metronome } from '../Metronome' | ||
import { Scene } from '../Scene' | ||
|
||
export const Clock: React.FC = () => { | ||
/** | ||
* Instantiate the clock worker. | ||
* This is truly the heartbeat of the entire app 🥹 | ||
* Workers should be loaded exactly once for a Component. | ||
* The `import.meta.url` is thanks to this SO answer https://stackoverflow.com/a/71134400/3991555, | ||
* which is just a digestible version of the webpack docs https://webpack.js.org/guides/web-workers/ | ||
* I tried refactoring this into a custom hook but ran into all sorts of weird issues. This is easy enough so leaving as is | ||
*/ | ||
const clock = useMemo( | ||
() => new Worker(new URL('../workers/clock', import.meta.url)), | ||
[] | ||
) | ||
|
||
return ( | ||
<> | ||
<Metronome clock={clock} /> | ||
<Scene clock={clock} /> | ||
</> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useEffect, useState } from 'react' | ||
import type { ClockControllerMessage } from '../workers/clock' | ||
import { ControlPanelItem } from './ControlPanelItem' | ||
|
||
type BeatCounterProps = { | ||
clock: Worker | ||
beatsPerMeasure: number | ||
} | ||
export function BeatCounter(props: BeatCounterProps) { | ||
const [currentTick, setCurrentTick] = useState(0) | ||
|
||
/** | ||
* Add clock event listeners | ||
*/ | ||
useEffect(() => { | ||
const clockMessageHandler = ( | ||
event: MessageEvent<ClockControllerMessage> | ||
) => { | ||
if (event.data.message === 'TICK') { | ||
setCurrentTick(event.data.currentTick) | ||
} | ||
} | ||
props.clock.addEventListener('message', clockMessageHandler) | ||
return () => { | ||
props.clock.removeEventListener('message', clockMessageHandler) | ||
} | ||
}, [props.clock, props.beatsPerMeasure]) | ||
|
||
return ( | ||
<ControlPanelItem> | ||
<span className="font-mono text-2xl pr-2"> | ||
{/* `+ 1` to convert "computer numbers" to "musician numbers" */} | ||
{(currentTick % props.beatsPerMeasure) + 1} | ||
</span> | ||
<span className="font-mono text-l"> | ||
. {Math.floor(currentTick / props.beatsPerMeasure) + 1} | ||
</span> | ||
</ControlPanelItem> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ControlPanel/MeasuresPerLoop.tsx → ...onome/controls/MeasuresPerLoopControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ControlPanel/Tempo.tsx → src/Metronome/controls/TempoControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/ControlPanel/TimeSignature.tsx → ...tronome/controls/TimeSignatureControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ControlPanel/VolumeControl.tsx → src/Metronome/controls/VolumeControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.