Bang-0.1.1.0: A Drum Machine DSL for Haskell

Copyright(c) Benjamin Kovach, 2014
LicenseMIT
Maintainerbkovach13@gmail.com
Stabilityexperimental
PortabilityMac OSX
Safe HaskellNone
LanguageHaskell2010

Bang.Experimental.Live

Description

An experimental alternative to the base Bang module that allows "live coding," a la Overtone or Tidal, via a ghci session. Note: Very finnicky, pull requests welcome at https:/github.com5outh/Bang.

The following works in GHCI if you fork off run into a new thread and readIORef counter. We can use an unsafe global variable like this to hold the duration to wait until the next Bang composition should be played. Right now, the aim is to be able to *replace* compositions being played during runtime, but eventually I think this could be extended to include multiple compositions being played at runtime, and turned on and off at will with calls to killThread, etc. I want to make this more generic than making everyone learn about concurrency and stuff, but as a first pass getting it working with the existing concurrency mechanisms is the goal.

Synopsis

Documentation

bangL :: Music Dur PercussionSound -> IO ThreadId Source

Bang live from a GHCi session. Note that the ThreadId involved must be referenced directly in order to replace or add to the currently running track.

Example:

track <- bangL bd

bangLWith :: Options -> Music Dur PercussionSound -> IO ThreadId Source

Bang live with specified options.

killThen :: ThreadId -> Music Dur PercussionSound -> IO ThreadId Source

Kill a thread playing music and replace it with a new composition.

Example:

  m1 <- bangL hc 
  m2 m1 `killThen` (bd < hc <> bd <> bd)

addTrack :: ThreadId -> Music Dur PercussionSound -> IO ThreadId Source

Add another track to play concurrently with the currently playing track.

Example:

  m1 <- bangL hc 
  m2 m1 `addTrack` (bd < hc <> bd <> bd)