Commit c34315bd authored by Guerric Chupin's avatar Guerric Chupin

First work on implementing single layer.

parent 40ad31a2
{-# LANGUAGE Arrows #-}
module Reactogon.Auxiliary.Auxiliary where
import FRP.Yampa
-- Throws an Event when the incoming signal change. The Event is
-- tagged with the new value.
onChange :: (Eq a) => SF a (Event a)
onChange = proc a -> do
b <- onChange' -< a
returnA -< e
where onChange' :: (Eq a) => SF (a,a) Bool
onChange' = arr $ uncurry (==)
module Reactogon.Global.Clock where
import Reactogon.Semantics
import FRP.Yampa
tempo :: SF () Tempo
tempo = constant 96
metronome :: SF Tempo (Event Beat)
metronome = undefined
{-# LANGUAGE Arrows #-}
module Reactogon.Layer.Layer where
import Reactogon.Beat
import Reactogon.Semantics
import Reactogon.Global.Clock
import FRP.Yampa
-- Data representing the state of a layer. It is updated continuously.
data Layer = Layer { relTempo :: Double
, strength :: Strength
}
layerClock :: SF () Tempo -> SF Layer Tempo
layerClock tempo = proc Layer { relTempo = r } -> do
t <- tempo -< ()
returnA -< floor $ r * fromIntegral t
-- A layer is a producer of events triggered by the system beat clock.
layer :: SF () (Event Beat) -> SF Layer (Event Note)
layer beatSource = undefined
module Reactogon.Layer.PlayHead where
import Reactogon.Semantics
import FRP.Yampa
playHead :: SF () ()
......@@ -39,8 +39,16 @@ type BCtrl = Double
-- the beat clock would be defined externally, synchronized with other
-- layers and possibly external MIDI, and account for tempo, any swing, etc.
-- Tempo
-- The tempo is the number of beats per minute.
type Tempo = Int
-- Beats and Bars
-- A beat in itself is not important.
type Beat = ()
-- Beats per Bar: number of beats per bar in the time signature of a layer.
-- Non-negative.
type BeatsPerBar = Int
......@@ -164,12 +172,12 @@ articStrength st bn art
-- Duration
-- Duration in terms of a whole note at the *system* tempo. (Each layer
-- is clocked at a layer beat that is a fraction/multiple of the system
-- tempo). Note that notes are played a little shorter than their nominal
-- duration. This is taken care of by the translation into low-level
-- MIDI events. (One might consider adding indications of staccato or
-- tenuto.)
-- Duration in terms of a whole note at the *system* tempo. (Each
-- layer is clocked at a layer beat that is a fraction/multiple of the
-- system tempo). Note that notes are played a little shorter than
-- their nominal duration. This is taken care of by the translation
-- into low-level MIDI events. (One might consider adding indications
-- of staccato or tenuto.)
type Duration = Rational
......@@ -205,7 +213,7 @@ data NoteAttr = NoteAttr {
} deriving Show
-- High level note representation emitted form a layer
-- High level note representation emitted from a layer
data Note = Note {
notePch :: Pitch,
noteStr :: Strength,
......@@ -260,7 +268,7 @@ posToPitch (x,y) tr =
-- Actions
-- Maybe this coul dbe refined: some of the actions might be useful
-- Maybe this could be refined: some of the actions might be useful
-- both in note playing and silent versions: e.g. changing direction without
-- playing a note; playing a note without changing direction.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment