Moved tests.
authorGuerric Chupin <guerric.chupin@ensta-paristech.fr>
Tue, 17 May 2016 14:25:09 +0000 (15:25 +0100)
committerGuerric Chupin <guerric.chupin@ensta-paristech.fr>
Tue, 17 May 2016 14:25:09 +0000 (15:25 +0100)
.gitignore
Reactogon/Arpeggiated.hs
Reactogon/MIDI.hs
Reactogon/tests/testArpeggiated.hs [new file with mode: 0644]
Reactogon/tests/testAvgInt.hs [moved from Reactogon/testAvgInt.hs with 100% similarity]

index 4fd5d5ff990b36013703dff77f97f882eb62d497..e28092288a3fda31cc4c0085231ac504263e6023 100644 (file)
@@ -1,3 +1,6 @@
+*
+!/**/
+!*.*
 *.o
 *.hi
 FluidSynth/
index 3082a80bf70f54b04dda78bba8accac5dde15973..69662fd1d8dd262ff86b56db25b73a7f6b40743d 100644 (file)
@@ -10,12 +10,13 @@ import Note
 arpeggiated :: SF (ControllerValue, Event Note) (Event Note)
 arpeggiated = proc (c,n) -> do
   non   <- uncurry gate ^<< identity &&& arr (event False isOn) -< n
-  non'  <- fmap perfectFifth ^<< delayEvent t                   -< non
-  non'' <- fmap majorThird ^<< delayEvent t                     -< non'
-  (nof',nof'')  <- makeOff *** makeOff -< (non',non'')
+  non'  <- fmap majorThird ^<< delayEvent t                     -< non
+  non'' <- fmap perfectFifth ^<< delayEvent t                   -< non'
+  (nof',
+   nof'') <- makeOff *** makeOff                                -< (non',non'')
   -- It's assumed that the NoteOff event corresponding to n will be
   -- emitted.
   returnA -< mergeEvents [n, non, non', nof', non'', nof'']
     where onoffGap = 0.9*t
-          t = 10
+          t = 100000
           makeOff = delayEvent onoffGap <<^ fmap switchOnOff
index 46c85afbcb65d0b97b630b5c0a8a7b01ef985ea4..e9d2f9457b18a6dc85f9e32716b7a956a8b20a06 100644 (file)
@@ -2,6 +2,8 @@ module MIDI ( SampleRate
             , Pitch
             , toPitch
             , fromPitch
+            , fromVelocity
+            , toVelocity
             , Velocity
             , Voice ( fromVoice
                     , toVoice
@@ -14,6 +16,8 @@ module MIDI ( SampleRate
 
 import Sound.MIDI.Message.Channel.Voice ( fromPitch
                                         , toPitch
+                                        , fromVelocity
+                                        , toVelocity
                                         )
 import qualified Sound.MIDI.Message.Channel.Voice as Voice
 
diff --git a/Reactogon/tests/testArpeggiated.hs b/Reactogon/tests/testArpeggiated.hs
new file mode 100644 (file)
index 0000000..64877c7
--- /dev/null
@@ -0,0 +1,26 @@
+import FRP.Yampa
+
+import MIDI
+import Note
+import Arpeggiated
+
+import System.IO
+import Data.Maybe
+
+ifReadyDo :: Handle -> IO a -> IO (Maybe a)
+ifReadyDo hnd x = hReady hnd >>= f
+   where f True = x >>= return . Just
+         f _    = return Nothing
+
+main :: IO ()
+main = reactimate initInput sensing output arpeggiated
+
+initInput = return (110, NoEvent)
+
+sensing _ = do c <- stdin `ifReadyDo` getChar
+               let c' = if isJust c
+                        then Event (NoteOn (toPitch 60) (toVelocity 100))
+                        else NoEvent
+               return (1, Just (110,c'))
+
+output _ x = print x >> return False