Opening your workspace…

Instrument — live coding music in your browser

; webtone-language: webtone://language/webtone@1
; HELLO, INSTRUMENT
; Press Play below or use Ctrl/⌘ + Enter.
; End playback with Stop or Ctrl/⌘ + .
; Edit the notes in Arrange — webtone://app/example/first-phrase-score
; First phrase · four bars in 4/4 at 112 BPM
; Change ending-note from 60 (C4) to 64 (E4), then press Play again.
(def ending-note 60)
(def key-attack 0.012)
(definst first-phrase-key [note 64 amp 0.17 release 0.4]
(let [hz (midicps note)
body (env-gen (perc key-attack release 1 -1.3) :action FREE)
touch (env-gen (perc key-attack 0.22 1 -2))
tone (+ (sin-osc hz)
(* (+ 0.12 (* 0.24 touch)) (sin-osc (* 2 hz)))
(* (+ 0.02 (* 0.08 touch)) (sin-osc (* 3 hz))))]
(pan2 (* amp body tone) 0)))
(let [bpm 112
clock (metronome bpm)
seconds-per-beat (/ 60 bpm)]
;; Each row gives the beat from the start, MIDI note, length in beats, and level.
(doseq [[beat pitch length level]
[[0 64 0.9 0.17]
[1.5 67 0.34 0.14]
[2 69 0.82 0.18]
[4 67 0.78 0.16]
[5 64 0.78 0.15]
[6 62 2 0.17]
[8 64 0.9 0.17]
[9.5 67 0.34 0.14]
[10 69 0.82 0.18]
[12 67 0.78 0.16]
[13 62 0.78 0.15]
[14 ending-note 2 0.17]]]
;; Give the evaluator a beat of lead time before the first note.
(at (clock (+ 1 beat))
(first-phrase-key :note pitch :amp level
:release (- (* length seconds-per-beat) key-attack)))))
; Click a Webtone link to keep exploring.
; First phrase pattern — webtone://app/example/first-phrase-pattern
; First signal — webtone://app/example/first-signal
; 32-bar arrangement — webtone://app/example/fly-me-to-the-moon
; Instruments — webtone://app/action/instruments
; Add a file — webtone://app/action/add-file
; Performances — webtone://app/action/sounds
; Live editing (experimental) — webtone://app/action/live-mode
(demo 4
(* 0.16
(sin-osc [220 221])))
Audio recorder ready