diff options
author | Andrew Cady <d@jerkface.net> | 2015-12-03 01:15:49 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2015-12-03 01:18:23 -0500 |
commit | 5d6537d8e548b3c1a19b3af25194cb4a0f9121c1 (patch) | |
tree | a8da563a946da6c18541e8bc4837795d87fc6470 | |
parent | 01df45553934d9d61f7810d49beec9419d2f1e4e (diff) |
compile with stack
Got rid of dependency on netwire since it wasn't used for anything
except to get a time delta from the previous frame.
(That time delta still needs to be reimplemented, though.)
-rw-r--r-- | .gitignore | 1 | ||||
l--------- | axis | 1 | ||||
-rw-r--r-- | axis-of-eval.cabal | 4 | ||||
-rw-r--r-- | axis.hs | 27 | ||||
l--------- | dump | 1 | ||||
-rw-r--r-- | stack.yaml | 25 |
6 files changed, 32 insertions, 27 deletions
@@ -1,2 +1,3 @@ | |||
1 | /dist | 1 | /dist |
2 | *.swp | 2 | *.swp |
3 | .stack-work | ||
@@ -1 +0,0 @@ | |||
1 | dist/build/axis-of-eval/axis-of-eval \ No newline at end of file | ||
diff --git a/axis-of-eval.cabal b/axis-of-eval.cabal index 161575f..ed67081 100644 --- a/axis-of-eval.cabal +++ b/axis-of-eval.cabal | |||
@@ -18,12 +18,12 @@ executable axis-of-eval | |||
18 | default-language: Haskell2010 | 18 | default-language: Haskell2010 |
19 | hs-source-dirs: . | 19 | hs-source-dirs: . |
20 | build-depends: | 20 | build-depends: |
21 | base >= 4.5 && < 4.7, time, SDL, SDL-ttf, SDL-gfx, containers, haskore, alsa-seq, alsa-core, netwire (>= 5.0.0) | 21 | base, time, SDL, SDL-ttf, SDL-gfx, containers, haskore, alsa-seq, alsa-core |
22 | main-is: axis.hs | 22 | main-is: axis.hs |
23 | 23 | ||
24 | executable midi-dump | 24 | executable midi-dump |
25 | default-language: Haskell2010 | 25 | default-language: Haskell2010 |
26 | hs-source-dirs: . | 26 | hs-source-dirs: . |
27 | build-depends: | 27 | build-depends: |
28 | base >= 4.5 && < 4.7, time, containers, haskore, alsa-seq, alsa-core | 28 | base, time, containers, haskore, alsa-seq, alsa-core |
29 | main-is: midi-dump.hs | 29 | main-is: midi-dump.hs |
@@ -1,10 +1,7 @@ | |||
1 | {-# LANGUAGE NondecreasingIndentation #-} | 1 | {-# LANGUAGE NondecreasingIndentation #-} |
2 | {-# LANGUAGE StandaloneDeriving #-} | 2 | {-# LANGUAGE StandaloneDeriving #-} |
3 | import FRP.Netwire hiding (when) | ||
4 | import Prelude hiding ((.), id, null, filter) | 3 | import Prelude hiding ((.), id, null, filter) |
5 | import Data.Time.Clock | 4 | import Data.Time.Clock |
6 | import Control.Wire hiding (when) | ||
7 | import Control.Wire.Session | ||
8 | import Control.Monad | 5 | import Control.Monad |
9 | import qualified Graphics.UI.SDL as SDL | 6 | import qualified Graphics.UI.SDL as SDL |
10 | import AlsaSeq | 7 | import AlsaSeq |
@@ -22,19 +19,6 @@ import qualified Sound.ALSA.Sequencer.Event as Event | |||
22 | import qualified Graphics.UI.SDL.Utilities as SDL.Util | 19 | import qualified Graphics.UI.SDL.Utilities as SDL.Util |
23 | import qualified Data.Map as Map | 20 | import qualified Data.Map as Map |
24 | 21 | ||
25 | netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String | ||
26 | netwireIsCool = | ||
27 | for 2.5 . pure "Once upon a time..." --> | ||
28 | for 3 . pure "... games were completely imperative..." --> | ||
29 | for 2 . pure "... but then..." --> | ||
30 | for 10 . (pure "Netwire 5! " <> anim) --> | ||
31 | netwireIsCool | ||
32 | |||
33 | where | ||
34 | anim = | ||
35 | holdFor 0.5 . periodic 1 . pure "Hoo..." <|> | ||
36 | pure "...ray!" | ||
37 | |||
38 | smartShowPitch p = showPitch p -- TODO: use flat for Eb, Bb; use unicode flat/sharp chars | 22 | smartShowPitch p = showPitch p -- TODO: use flat for Eb, Bb; use unicode flat/sharp chars |
39 | 23 | ||
40 | _USE_HEXAGONS = True | 24 | _USE_HEXAGONS = True |
@@ -233,14 +217,11 @@ main = | |||
233 | putStrLn "Initialized." | 217 | putStrLn "Initialized." |
234 | 218 | ||
235 | let parseAlsa keysDown = parseAlsaEvents h keysDown (forwardNoteEvent h q publicAddr) | 219 | let parseAlsa keysDown = parseAlsaEvents h keysDown (forwardNoteEvent h q publicAddr) |
236 | let loop state midiKeysDown keysDown resolution font s w x = do | 220 | let loop state midiKeysDown keysDown resolution font = do |
237 | let (LoopState firstLoop colsRepeat) = state | 221 | let (LoopState firstLoop colsRepeat) = state |
238 | 222 | ||
239 | (keysDown', resolution') <- parseSDLEvents keysDown resolution | 223 | (keysDown', resolution') <- parseSDLEvents keysDown resolution |
240 | midiKeysDown' <- parseAlsa midiKeysDown | 224 | midiKeysDown' <- parseAlsa midiKeysDown |
241 | (ds, s') <- stepSession s | ||
242 | (ex, w') <- stepWire w ds (Right x) | ||
243 | let x' = either (const "") id ex | ||
244 | let colsRepeat' = case firstDigitDown keysDown' of Nothing -> colsRepeat; (Just 0) -> colsRepeat; (Just n) -> n; | 225 | let colsRepeat' = case firstDigitDown keysDown' of Nothing -> colsRepeat; (Just 0) -> colsRepeat; (Just n) -> n; |
245 | 226 | ||
246 | let restartVideo = resolution' /= resolution || colsRepeat' /= colsRepeat | 227 | let restartVideo = resolution' /= resolution || colsRepeat' /= colsRepeat |
@@ -315,12 +296,12 @@ main = | |||
315 | _ <- SDL.flip videoSurface | 296 | _ <- SDL.flip videoSurface |
316 | 297 | ||
317 | let framerate = 30 | 298 | let framerate = 30 |
318 | let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds) | 299 | let delay = 1000 `div` framerate -- TODO: subtract delta |
319 | SDL.delay (delay) | 300 | SDL.delay (delay) |
320 | Control.Monad.when (not $ keyDown SDL.SDLK_ESCAPE keysDown) $ | 301 | Control.Monad.when (not $ keyDown SDL.SDLK_ESCAPE keysDown) $ |
321 | loop (LoopState False colsRepeat') midiKeysDown' keysDown' resolution' font' s' w' x' | 302 | loop (LoopState False colsRepeat') midiKeysDown' keysDown' resolution' font' |
322 | 303 | ||
323 | loop (LoopState True _AXIS_COLS_REPEAT) Set.empty Set.empty (sWidth, sHeight) font clockSession_ netwireIsCool "" | 304 | loop (LoopState True _AXIS_COLS_REPEAT) Set.empty Set.empty (sWidth, sHeight) font |
324 | 305 | ||
325 | zipzip ls = if (head ls) == [] then [] else (map head ls) : (zipzip $ map tail ls) | 306 | zipzip ls = if (head ls) == [] then [] else (map head ls) : (zipzip $ map tail ls) |
326 | 307 | ||
@@ -1 +0,0 @@ | |||
1 | dist/build/midi-dump/midi-dump \ No newline at end of file | ||
diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..abcd766 --- /dev/null +++ b/stack.yaml | |||
@@ -0,0 +1,25 @@ | |||
1 | flags: {} | ||
2 | packages: | ||
3 | - '.' | ||
4 | extra-deps: | ||
5 | - SDL-0.6.5.1 | ||
6 | - SDL-gfx-0.6.0.1 | ||
7 | - SDL-ttf-0.6.2.1 | ||
8 | - alsa-core-0.5.0.1 | ||
9 | - alsa-seq-0.6.0.5 | ||
10 | - haskore-0.2.0.7 | ||
11 | |||
12 | - enumset-0.0.4 | ||
13 | - event-list-0.1.1.2 | ||
14 | - markov-chain-0.0.3.3 | ||
15 | - midi-0.2.1.5 | ||
16 | - non-negative-0.1.1 | ||
17 | - poll-0.0 | ||
18 | - utility-ht-0.0.11 | ||
19 | |||
20 | - explicit-exception-0.1.7.3 | ||
21 | - monoid-transformer-0.0.3 | ||
22 | - storable-record-0.0.3 | ||
23 | |||
24 | resolver: lts-3.7 | ||
25 | system-ghc: false | ||