summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-03 01:15:49 -0500
committerAndrew Cady <d@jerkface.net>2015-12-03 01:18:23 -0500
commit5d6537d8e548b3c1a19b3af25194cb4a0f9121c1 (patch)
treea8da563a946da6c18541e8bc4837795d87fc6470
parent01df45553934d9d61f7810d49beec9419d2f1e4e (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--.gitignore1
l---------axis1
-rw-r--r--axis-of-eval.cabal4
-rw-r--r--axis.hs27
l---------dump1
-rw-r--r--stack.yaml25
6 files changed, 32 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index dfe42e9..9b1a93c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
1/dist 1/dist
2*.swp 2*.swp
3.stack-work
diff --git a/axis b/axis
deleted file mode 120000
index fafd197..0000000
--- a/axis
+++ /dev/null
@@ -1 +0,0 @@
1dist/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
24executable midi-dump 24executable 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
diff --git a/axis.hs b/axis.hs
index 90770f0..ba4ccdc 100644
--- a/axis.hs
+++ b/axis.hs
@@ -1,10 +1,7 @@
1{-# LANGUAGE NondecreasingIndentation #-} 1{-# LANGUAGE NondecreasingIndentation #-}
2{-# LANGUAGE StandaloneDeriving #-} 2{-# LANGUAGE StandaloneDeriving #-}
3import FRP.Netwire hiding (when)
4import Prelude hiding ((.), id, null, filter) 3import Prelude hiding ((.), id, null, filter)
5import Data.Time.Clock 4import Data.Time.Clock
6import Control.Wire hiding (when)
7import Control.Wire.Session
8import Control.Monad 5import Control.Monad
9import qualified Graphics.UI.SDL as SDL 6import qualified Graphics.UI.SDL as SDL
10import AlsaSeq 7import AlsaSeq
@@ -22,19 +19,6 @@ import qualified Sound.ALSA.Sequencer.Event as Event
22import qualified Graphics.UI.SDL.Utilities as SDL.Util 19import qualified Graphics.UI.SDL.Utilities as SDL.Util
23import qualified Data.Map as Map 20import qualified Data.Map as Map
24 21
25netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String
26netwireIsCool =
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
38smartShowPitch p = showPitch p -- TODO: use flat for Eb, Bb; use unicode flat/sharp chars 22smartShowPitch 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
325zipzip ls = if (head ls) == [] then [] else (map head ls) : (zipzip $ map tail ls) 306zipzip ls = if (head ls) == [] then [] else (map head ls) : (zipzip $ map tail ls)
326 307
diff --git a/dump b/dump
deleted file mode 120000
index 4983da0..0000000
--- a/dump
+++ /dev/null
@@ -1 +0,0 @@
1dist/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 @@
1flags: {}
2packages:
3 - '.'
4extra-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
24resolver: lts-3.7
25system-ghc: false