packages feed

Bang 0.1.1.0 → 0.1.1.1

raw patch · 4 files changed

+31/−12 lines, 4 files

Files

Bang.cabal view
@@ -1,7 +1,7 @@ name:                Bang-version:             0.1.1.0+version:             0.1.1.1 synopsis:            A Drum Machine DSL for Haskell-description:         +description:   This library consists of a DSL for piecing together drum compositions. It uses a MIDI backend   and is only currently available for use on Mac OSX. Much of the library was inspired by previous work done by Yale's   @<http://haskell.cs.yale.edu/euterpea/ Euterpea>@ project and Paul Hudak\'s @<http://cpsc.yale.edu/sites/default/files/files/tr1259.pdf paper>@.@@ -10,7 +10,7 @@ license-file:        LICENSE author:              Benjamin Kovach maintainer:          bkovach13@gmail.com--- copyright:           +-- copyright: category:            Sound build-type:          Simple extra-source-files:  README.md@@ -22,8 +22,8 @@                        Bang.Interface.Base,                        Bang.Interface.Drum,                        Bang.Music,-                       Bang.Music.Class, -                       Bang.Music.Operators, +                       Bang.Music.Class,+                       Bang.Music.Operators,                        Bang.Music.Transform,                        Bang.Experimental.Live,                        Bang.Experimental.SequentialDo,@@ -31,8 +31,8 @@    other-modules:       Bang.Interpreter -  build-depends:       base >=4.6 && <5, -                       mtl >=2.1 && <3, +  build-depends:       base >=4.6 && <5,+                       mtl >=2.1 && <3,                        transformers >=0.3 && <0.4,                        bifunctors >= 4 && <5,                        stm >= 2.4 && < 5,
README.md view
@@ -6,7 +6,7 @@ Bang interfaces with your system MIDI device in order to play drum compositions, directly written in and  interpreted by the Haskell programming language. -Currently, Bang only supports OSX Mavericks. Windows playback works, but is finnicky. In particular, if you interrupt a composition launched from a ghci interpreter session, the built-in MIDI synthesizer will complain about already being in use the next time you attempt to play something, until ghci is reloaded. This issue does not arise when playing songs from files. If you define a `main` function in an external file, and compile and run it, interrupting compositions should work fine.+Currently, Bang only supports OSX. Windows playback works, but is finnicky. In particular, if you interrupt a composition launched from a ghci interpreter session, the built-in MIDI synthesizer will complain about already being in use the next time you attempt to play something, until ghci is reloaded. This issue does not arise when playing songs from files. If you define a `main` function in an external file, and compile and run it, interrupting compositions should work fine.  ### Installing 
src/Bang/Interpreter.hs view
@@ -8,7 +8,6 @@ import Data.Ratio import Data.Monoid - toList :: Music Dur PercussionSound -> [MidiEvent] toList m = map drumToMidiEvent (interpret m) 
src/Bang/Music/Transform.hs view
@@ -60,8 +60,20 @@                     p@(Prim (Note d' _)) -> rest 0                     (a :+: b)    -> go dr a :+: go (dr - duration a) b                     (a :=: b)    -> go dr a :=: go dr b-                    (Modify c a) -> Modify c (go dr a)   +                    (Modify c a) -> Modify c (go dr a) +-- |Take the last `d` duration units of a composition+takeLast :: Dur -> Music Dur b -> Music Dur b+takeLast d m = dropDur (duration m - d) m++-- |Drop the last `d` duration units of a composition+dropLast :: Dur -> Music Dur b -> Music Dur b+dropLast d m = takeDur (duration m - d) m++-- |Remove the section of the composition between `d1` and `d2`.+removeBetween :: Dur -> Dur -> Music Dur b -> Music Dur b+removeBetween d1 d2 m = takeDur d1 m <> dropDur d2 m+ -- |Split a composition at a specific duration and return the composition -- before said duration along with the rest of it.  partitionDur :: Dur -> Music Dur b -> (Music Dur b, Music Dur b)@@ -75,9 +87,17 @@ hushFrom :: Dur -> Music Dur b -> Music Dur b hushFrom d m = takeDur d m <> rest (max (duration m - d) 0) +-- |Turn the last `d` duration units into silence+hushLast :: Dur -> Music Dur b -> Music Dur b+hushLast d m = hushFrom (duration m - d) m++-- |Turn everything but the last `d` duration units into silence+hushUntilLast :: Dur -> Music Dur b -> Music Dur b+hushUntilLast d m = hushFor (duration m - d) m + -- |Turn the section of a composition between `pos` and `d` into silence.-hushAt :: Dur -> Dur -> Music Dur b -> Music Dur b-hushAt pos d m = pre <> rest d <> dropDur d post+hushBetween :: Dur -> Dur -> Music Dur b -> Music Dur b+hushBetween pos d m = pre <> rest d <> dropDur d post   where (pre, post) = partitionDur pos m  -- |Play a polyrhythm with 'm' having units of length 1\/x and 'n' with units of length 1\/y