1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
<title>Haskore Tutorial: Examples</title>
<body bgcolor="#ffffff"><i>The Haskore Tutorial</i><br><a href="index.html">top</a> <a href="TestHaskore.html">back</a> <a href="ChildSong6.html">next</a><hr>
section B
<a name="examples"></a><a name="sect11"></a>
<h2>11<tt> </tt>Examples of Haskore in Action</h2>
<p>
<tt> <br>
<br>
> module HaskoreExamples (module Haskore, module TestHaskore, <br>
> module ChildSong6, module SelfSim)<br>
> where<br>
><br>
> import Haskore<br>
> import TestHaskore<br>
> import ChildSong6<br>
> import SelfSim<br>
<br>
Simple examples of Haskore in action. Note that this module also<br>
imports modules ChildSong6 and SelfSim.<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
From the tutorial, try things such as pr12, cMajArp, cMajChd, etc. and<br>
try applying inversions, retrogrades, etc. on the same examples. Also<br>
try "childSong6" imported from module ChildSong. For example:<br>
<br>
> t0 = test (Instr "piano" childSong6)<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
C Major scale for use in examples below:<br>
<br>
> cMajScale = Tempo 2 1<br>
> (line [c 4 en [], d 4 en [], e 4 en [], f 4 en [], <br>
> g 4 en [], a 4 en [], b 4 en [], c 5 en []])<br>
><br>
> cms = cMajScale<br>
<br>
Test of various articulations and dynamics:<br>
<br>
> t1 = test (Instr "piano"<br>
> (Phrase [Art (Staccato 0.1)] cms :+:<br>
> cms :+:<br>
> Phrase [Art (Legato 1.1)] cms ))<br>
><br>
> t2 = test (Instr "vibes" <br>
> (Phrase [Dyn (Diminuendo 0.75)] cms :+:<br>
> Phrase [Dyn (Crescendo 4.0), Dyn (Loudness 25)] cms))<br>
><br>
> t3 = test (Instr "flute" <br>
> (Phrase [Dyn (Accelerando 0.3)] cms :+:<br>
> Phrase [Dyn (Ritardando 0.6)] cms ))<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
A function to recursively apply transformations f (to elements in a<br>
sequence) and g (to accumulated phrases):<br>
<br>
> rep :: (Music -> Music) -> (Music -> Music) -> Int -> Music -> Music<br>
> rep f g 0 m = Rest 0<br>
> rep f g n m = m :=: g (rep f g (n-1) (f m))<br>
<br>
An example using "rep" three times, recursively, to create a "cascade"<br>
of sounds.<br>
<br>
> run = rep (Trans 5) (delay tn) 8 (c 4 tn [])<br>
> cascade = rep (Trans 4) (delay en) 8 run<br>
> cascades = rep id (delay sn) 2 cascade<br>
> t4' x = test (Instr "piano" x)<br>
> t4 = test (Instr "piano" <br>
> (cascades :+: revM cascades))<br>
<br>
What happens if we simply reverse the f and g arguments?<br>
<br>
> run' = rep (delay tn) (Trans 5) 4 (c 4 tn [])<br>
> cascade' = rep (delay en) (Trans 4) 6 run'<br>
> cascades' = rep (delay sn) id 2 cascade'<br>
> t5 = test (Instr "piano" cascades')<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
Example from the SelfSim module.<br>
<br>
> t10s = test (rep (delay durss) (Trans 4) 2 ss)<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
Example from the ChildSong6 module.<br>
<br>
> cs6 = test childSong6<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
Midi percussion test. Plays all "notes" in a range. (Requires adding<br>
an instrument for percussion to the UserPatchMap.)<br>
<br>
> drums a b = Instr "drums" <br>
> (line (map (\p-> Note (pitch p) sn []) [a..b]))<br>
> t11 a b = test (drums a b)<br>
<br>
-----------------------------------------------------------------------------<br>
<br>
</tt>
<hr><body bgcolor="#ffffff"><i>The Haskore Tutorial</i><br><a href="index.html">top</a> <a href="TestHaskore.html">back</a> <a href="ChildSong6.html">next</a>
|