1; webtone-language: webtone://language/webtone@1
2; HELLO, INSTRUMENT
3; Press Play below or use Ctrl/⌘ + Enter.
4; End playback with Stop or Ctrl/⌘ + .
5; Edit the notes in Arrange — webtone://app/example/first-phrase-score
6; First phrase · four bars in 4/4 at 112 BPM
7; Change ending-note from 60 (C4) to 64 (E4), then press Play again.
8
9(def ending-note 60)
10(def key-attack 0.012)
11
12(definst first-phrase-key [note 64 amp 0.17 release 0.4]
13 (let [hz (midicps note)
14 body (env-gen (perc key-attack release 1 -1.3) :action FREE)
15 touch (env-gen (perc key-attack 0.22 1 -2))
16 tone (+ (sin-osc hz)
17 (* (+ 0.12 (* 0.24 touch)) (sin-osc (* 2 hz)))
18 (* (+ 0.02 (* 0.08 touch)) (sin-osc (* 3 hz))))]
19 (pan2 (* amp body tone) 0)))
20
21(let [bpm 112
22 clock (metronome bpm)
23 seconds-per-beat (/ 60 bpm)]
24 ;; Each row gives the beat from the start, MIDI note, length in beats, and level.
25 (doseq [[beat pitch length level]
26 [[0 64 0.9 0.17]
27 [1.5 67 0.34 0.14]
28 [2 69 0.82 0.18]
29
30 [4 67 0.78 0.16]
31 [5 64 0.78 0.15]
32 [6 62 2 0.17]
33
34 [8 64 0.9 0.17]
35 [9.5 67 0.34 0.14]
36 [10 69 0.82 0.18]
37
38 [12 67 0.78 0.16]
39 [13 62 0.78 0.15]
40 [14 ending-note 2 0.17]]]
41 ;; Give the evaluator a beat of lead time before the first note.
42 (at (clock (+ 1 beat))
43 (first-phrase-key :note pitch :amp level
44 :release (- (* length seconds-per-beat) key-attack)))))
45
46; Click a Webtone link to keep exploring.
47; First phrase pattern — webtone://app/example/first-phrase-pattern
48; First signal — webtone://app/example/first-signal
49; 32-bar arrangement — webtone://app/example/fly-me-to-the-moon
50; Instruments — webtone://app/action/instruments
51; Add a file — webtone://app/action/add-file
52; Performances — webtone://app/action/sounds
53; Live editing (experimental) — webtone://app/action/live-mode