14import Abcjs.Types (BeatNumber, Fraction, Qpm, TimingEvent, TotalBeats, TuneObject)
15import Data.Nullable (Nullable)
16import Data.Time.Duration (Seconds)
18import Effect.Uncurried (EffectFn1, EffectFn2, EffectFn3, EffectFn4, mkEffectFn1, mkEffectFn3, runEffectFn1, runEffectFn2, runEffectFn4)
19import Prim.Row (class Union)
21-- | A standalone animation timer over a rendered tune. Drives the cursor and
22-- | game logic off note timing, independent of whether audio is playing.
23foreign import data TimingCallbacks :: Type
25-- | Timer options as a row, so a caller supplies only what they need; anything
26-- | omitted falls back to abcjs (no `qpm` means the tune's written tempo).
27-- | `eventCallback` fires per note/rest/bar; abcjs passes `null` at the end of
28-- | the tune, hence `Nullable`. `beatCallback` receives
29-- | (beatNumber, totalBeats, totalTime).
32 , eventCallback :: Nullable TimingEvent -> Effect Unit
33 , beatCallback :: BeatNumber -> TotalBeats -> Seconds -> Effect Unit
37 :: forall provided rest
38 . Union provided rest TimingOptions
39 => TuneObject -> { | provided } -> Effect TimingCallbacks
40newTimingCallbacks tune options =
41 runEffectFn4 newTimingCallbacksImpl mkEffectFn1 mkEffectFn3 tune options
43-- | The FFI gets the converters and the partial options, and converts each
44-- | callback only where supplied — omitted fields are left off the abcjs object.
45foreign import newTimingCallbacksImpl
48 ((Nullable TimingEvent -> Effect Unit) -> EffectFn1 (Nullable TimingEvent) Unit)
49 ((BeatNumber -> TotalBeats -> Seconds -> Effect Unit) -> EffectFn3 BeatNumber TotalBeats Seconds Unit)
54start :: TimingCallbacks -> Effect Unit
55start = runEffectFn1 startImpl
57foreign import startImpl :: EffectFn1 TimingCallbacks Unit
59stop :: TimingCallbacks -> Effect Unit
60stop = runEffectFn1 stopImpl
62foreign import stopImpl :: EffectFn1 TimingCallbacks Unit
64pause :: TimingCallbacks -> Effect Unit
65pause = runEffectFn1 pauseImpl
67foreign import pauseImpl :: EffectFn1 TimingCallbacks Unit
69reset :: TimingCallbacks -> Effect Unit
70reset = runEffectFn1 resetImpl
72foreign import resetImpl :: EffectFn1 TimingCallbacks Unit
74-- | Jump the cursor to a fraction of the tune (0.0 to 1.0).
75setProgress :: Fraction -> TimingCallbacks -> Effect Unit
76setProgress = runEffectFn2 setProgressImpl
78foreign import setProgressImpl :: EffectFn2 Fraction TimingCallbacks Unit
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list