Haskore

Haskore is a set of Haskell modules for creating music as MIDI, CSound, Audio files. Because of the concise programming style of Haskell, the composer can concentrate on composing rather than programming. Nevertheless the music author can benefit from the full power of functional programming. Haskore was created by Paul Hudak at Yale in 1996.

Examples

Since Haskore is free here is an example ChildSong6.lhs from the official archive which contains a partial encoding of Chick Corea's "Children's Song No. 6":

module ChildSong6 where
import Haskore

-- note updaters for mappings
fd d n = n d v
vol n = n v
v =
lmap f l = line (map f l)

-- repeat something n times
times 1 m = m
times (n+1) m = m :+: (times n m)

-- Baseline:
b1 = lmap (fd dqn)
b2 = lmap (fd dqn)
b3 = lmap (fd dqn)

bassLine = times 3 b1 :+: times 2 b2 :+: times 4 b3 :+: times 5 b1

-- Main Voice:
v1 = v1a :+: v1b
v1a = lmap (fd en)
v1b = lmap vol [cs 5 tn, d 5 (qn-tn), cs 5 en, b 4 en]

v2 = v2a :+: v2b :+: v2c :+: v2d :+: v2e :+: v2f
v2a = lmap vol [cs 5 (dhn+dhn), d 5 dhn,
f 5 hn, gs 5 qn, fs 5 (hn+en), g 5 en]
v2b = lmap (fd en) :+: a 4 dqn v :+:
lmap (fd en)
v2c = lmap vol [cs 6 (hn+en), d 6 en, cs 6 en, e 5 en] :+: enr :+:
lmap vol
v2d = lmap (fd en) :+:
lmap vol [fs 5 tn, e 5 (qn-tn), d 5 en, e 5 tn, d 5 (qn-tn),
cs 5 en, d 5 tn, cs 5 (qn-tn), b 4 (en+hn)]
v2e = lmap vol [cs 5 en, b 4 en, fs 5 en, a 5 en, b 5 (hn+qn), a 5 en,
fs 5 en, e 5 qn, d 5 en, fs 5 en, e 5 hn, d 5 hn, fs 5 qn]
v2f = Tempo (3/2) (lmap vol ) :+: b 4 (3*dhn+hn) v

mainVoice = times 3 v1 :+: v2

-- Putting it all together:
childSong6 = Instr "piano" (Tempo 3 (Phrase bassLine :=: mainVoice))
 
< Prev   Next >