Skip to content

Commit

Permalink
fix: animation and sound, locally
Browse files Browse the repository at this point in the history
  • Loading branch information
patreeceeo committed Aug 8, 2022
1 parent 6393d5d commit ccbfd7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions assets/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ main =


-- MODEL
-- Wrap parameters to init in abstract types so that init itself is testable


wrapInit : (firstArg -> Maybe Url -> Utils.TestableNavKey -> ( Model, Cmd Message )) -> firstArg -> Url -> Browser.Navigation.Key -> ( Model, Cmd Message )
Expand Down Expand Up @@ -152,7 +153,7 @@ contextualize msg model =
Router.currentRoute model.router

millisSinceKeyDown =
OS.milisSinceKeyDown KbdEvent.KeySpace model.os
OS.milisSinceKeyDown event.key model.os

volume =
User.Interface.intensityOfKeyPress millisSinceKeyDown
Expand Down Expand Up @@ -215,8 +216,8 @@ interpret msg context =
_ ->
[ msg ]

( Message.KeyUp _, WithRouteVolumeVoiceIndexAndPitch MainRoute volume voiceIndex intensityOfPress ) ->
[ msg, Message.PlayNote volume voiceIndex intensityOfPress ]
( Message.KeyUp _, WithRouteVolumeVoiceIndexAndPitch MainRoute volume voiceIndex pitch ) ->
[ msg, Message.PlayNote volume voiceIndex pitch ]

( Message.KeyDown _, WithRouteAndSequenceItem SelectChordRoute chord ) ->
[ msg, Message.SelectChord chord ]
Expand Down Expand Up @@ -479,8 +480,8 @@ mapUIInstrument update_ msg taggedModel selectors =
subscriptions : Model -> Sub Message
subscriptions model =
Sub.batch
-- [ Browser.Events.onAnimationFrame Message.AnimationFrame
[ Browser.Events.onResize (\w _ -> Message.WindowResize w)
[ Browser.Events.onAnimationFrame Message.AnimationFrame
, Browser.Events.onResize (\w _ -> Message.WindowResize w)
, Browser.Events.onVisibilityChange Message.VisibilityChange
, Browser.Events.onKeyDown (KbdEvent.decode |> D.map Message.KeyDown)
, Browser.Events.onKeyUp (KbdEvent.decode |> D.map Message.KeyUp)
Expand Down
6 changes: 3 additions & 3 deletions assets/elm/UserInterfaces.elm
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ viewString voice index time msgForMouseOver =
, Sattr.stroke "rgba(255, 255, 255, 0.5)"
, Sattr.fill "none"
, onMouseOver msgForMouseOver
, Sattr.class "string"
, Sattr.id ("instrument-voice-" ++ String.fromInt index)
]
[ viewStringAnimation voice index time ]


viewStrings : Instrument.Model -> OS.Model -> (Int -> MouseEvent.Model -> msg) -> List (Svg.Svg msg)
viewStrings instrumentModel osModel msgForMouseOver =
List.indexedMap
(\index voice -> viewString voice index osModel.timeInMillis (msgForMouseOver index))
(Array.toList instrumentModel.voices)
Array.toList instrumentModel.voices
|> List.indexedMap (\index voice -> viewString voice index osModel.timeInMillis (msgForMouseOver index))


viewDebugVoiceNote : Int -> ( Int, Float ) -> Svg.Svg msg
Expand Down

0 comments on commit ccbfd7b

Please sign in to comment.