Skip to content

Commit

Permalink
cleanup of debug messages and wrapping clearZone call in try to catch…
Browse files Browse the repository at this point in the history
… exceptions
  • Loading branch information
dktr0 committed Oct 13, 2023
1 parent 88f70c5 commit 29db501
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 3 additions & 7 deletions client/src/Estuary/Render/Renderer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,12 @@ maybeClearZone :: Int -> (TextNotation,Text,UTCTime) -> R ()
maybeClearZone z (newNotation,newTxt,_) = do
mOldDef <- gets (IntMap.lookup z . baseDefinitions)
case mOldDef of
Nothing -> liftIO $ putStrLn "maybeClearZone - no previous definition" -- pure () -- no previous definition so nothing to clear
Nothing -> pure () -- no previous definition so nothing to clear
Just oldDef -> do
x <- defsSameRenderer z oldDef newNotation newTxt
case x of
True -> liftIO $ putStrLn $ "maybeClearZone - defs have same renderer, " ++ show oldDef ++ ", " ++ show newNotation -- pure () -- definitions have same renderer so nothing to clear
True -> pure () -- definitions have same renderer so nothing to clear
False -> do
liftIO $ putStrLn $ "maybeClearZone - clearing zone: " ++ show oldDef
clearZone z oldDef
clearBaseDefinition z
clearBaseNotation z
Expand Down Expand Up @@ -325,14 +324,11 @@ clearZone z (Sequence _) = clearParamPattern z
clearZone _ _ = return ()

clearTextProgram :: Int -> TextNotation -> R ()
clearTextProgram z (TidalTextNotation MiniTidal) = do
liftIO $ putStrLn "clearTextProgram MiniTidal..."
(clearZone' miniTidal) z
clearTextProgram z (TidalTextNotation MiniTidal) = (clearZone' miniTidal) z
clearTextProgram z Punctual = (clearZone' punctual) z
clearTextProgram z CineCer0 = (clearZone' cineCer0) z
clearTextProgram z Hydra = modify' $ \x -> x { hydras = IntMap.delete z $ hydras x }
clearTextProgram z LocoMotion = do
liftIO $ putStrLn "clearTextProgram LocoMotion..."
s <- get
(clearZone' $ exoLangToRenderer LocoMotion $ locoMotion s) z
clearTextProgram z TransMit = do
Expand Down
11 changes: 10 additions & 1 deletion client/src/Estuary/Render/TextNotationRenderer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Data.Text
import Data.Time
import Data.Time.Clock.POSIX
import Control.Monad.State.Strict
import Control.Exception hiding (evaluate)

import Estuary.Types.NoteEvent
import Estuary.Render.R
Expand Down Expand Up @@ -77,7 +78,15 @@ scheduleWebDirtEvents' exoLang z = do
liftIO $ render exoLang z wStart wEnd

clearZone'' :: ExoLang -> Int -> R ()
clearZone'' exoLang z = liftIO $ clearZone exoLang z
clearZone'' exoLang z = do
x <- liftIO $ try $ clearZone exoLang z
case x of
Right () -> pure ()
Left exception -> do
let msg = "Estuary: exception in clearZone'': " ++ show (exception :: SomeException)
liftIO $ putStrLn msg
pure ()


preAnimationFrame' :: ExoLang -> R ()
preAnimationFrame' exoLang = liftIO $ preAnimate exoLang
Expand Down

0 comments on commit 29db501

Please sign in to comment.