/
flatiron.clj
138 lines (121 loc) · 6.27 KB
/
flatiron.clj
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
(ns cassiopeia.destination.flatiron
" .-. . .-. .-. .-. .-. .-. . .
|- | |-| | | |( | | |\\|
' `-' ` ' ' `-' ' ' `-' ' ``"(:use [overtone.live][mud.core][mud.chords][cassiopeia.waves.synths][cassiopeia.samples][cassiopeia.engine.buffers][cassiopeia.dirt][cassiopeia.waves.buf-effects][cassiopeia.engine.expediency][cassiopeia.destination.flatiron.scores][cassiopeia.engine.scheduled-sampler])(:require [mud.timing :as time][clojure.math.numeric-tower :as math][overtone.studio.fx :as fx] [cassiopeia.destination.flatiron.utils :as fl]))
(ctl-global-clock 0.2)
(nyc)
(defn nyc
"New york city"
[]
(do (def master-vol 3.0) (volume master-vol) (fl/v master-vol))
(ctl-global-clock 0.0)
(defbufs 256 [df-b s-note-b])
(do (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 128 [bass-notes-buf effects-seq-buf]) (defonce hats-amp (buffer 256)) (defonce kick-amp (buffer 256)) (defonce kick-seq-buf (buffer 256)))
(pattern! kick-amp [1.5 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1] (repeat 2 [1.2 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1]) [1.2 1 1 1 1 1 1 1 1.2 1 1 1 1.2 1 1.3 1])
(pattern! hats-amp (repeat 3 [2 2 2 2 2.1 2 2 2 2 2 2 2 2 2 2 2]) [2 2 2 2 2.1 2 2 2 2 2 2.4 2 2.4 2 2 2])
(pattern! bass-notes-buf
(repeat 8 (degrees [1] :minor :F1))
(repeat 2 (repeat 8 (degrees [1] :minor :F1)))
(repeat 2 (repeat 8 (degrees [3] :minor :F1)))
(repeat 2 (repeat 8 (degrees [3] :minor :F1)))
[(degrees [1 1 1 1 5 4 3 1] :minor :F1)])
(def beats (buffer->tap-lite kick-seq-buf (:count time/beat-1th) :measure 8))
(defonce stars-weight (atom 0.0))
(defonce circle-count (atom 4.0))
(defonce color (atom 0.1))
(defonce circle-slice (atom 8.0))
(defonce circle-edge (atom 0.1))
(defonce circular-weight (atom 0.0))
(defonce population-weight (atom 0.0))
(defonce cells-weight (atom 0.0))
(defonce nyc-weight (atom 0.0))
(defonce invert-color (atom 1.0))
(defonce cell-dance-weight (atom 1.0))
(defonce splatter (atom 1.0))
(defonce circle-intensity (atom 0.0025))
(defonce buffer-change-event-nomad (atom 0.0))
(defonce break-parens-in-case-of-emergency (atom 0.0))
(def ibeat (atom {:synth beats :tap "beat"}))
(def beat-tap (get-in (:synth @ibeat) [:taps (:tap @ibeat)]))
(def cell-dance-color (atom 0.01))
(add-watch beat-tap :cell-color
(fn [_ _ old new]
(when (and (= old 0.0) (= 1.0 new))
(reset! cell-dance-color (mod (+ @cell-dance-color 1.0) 100)))))
(defonce converge-zoom-rate (atom 0.2))
(reset! converge-zoom-rate 0.2)
(reset! splatter 1.0)
(add-watch beat-tap :converge-circles
(fn [_ _ old new]
(when (>= @cell-dance-weight 8.0)
(reset! splatter (max 0 (- @splatter @converge-zoom-rate))))
(reset! converge-zoom-rate (max 0.0005 (* @converge-zoom-rate 0.5)))
(when (<= @splatter 0.0)
(remove-watch beat-tap :converge-circles)
)))
(reset! circle-count 4.0)
(reset! color 0.1)
(reset! circle-slice 8.0)
(reset! circle-edge 0.1)
(reset! circular-weight 0.0)
(reset! population-weight 0.0)
(reset! cells-weight 0.0)
(reset! nyc-weight 0.0)
(reset! invert-color 1.0)
(reset! cell-dance-weight 1.0)
(reset! splatter 1.0)
(reset! circle-intensity 0.0025)
(reset! buffer-change-event-nomad 0.0)
(reset! cell-dance-color 0.01)
(reset! break-parens-in-case-of-emergency 0.0)
(def nomad-chord-g nil)
(add-watch
buffer-change-event-nomad
:buffer-change-event-nomad
(fn [& _]
(when nomad-chord-g
(let [n (int (buffer-get (second (:bufs nomad-chord-g)) 0))]
(case n
29 (do (overtime! circle-edge 0.0) (overtime! nyc-weight 0.0 0.005) (reset! invert-color 1.0))
32 (do (overtime! circle-edge -0.3) (overtime! nyc-weight 0.004) (reset! invert-color 2.0))
34 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.01))
36 (do (overtime! circle-edge -0.55) (overtime! nyc-weight 0.0119))
41 (do (overtime! circle-edge 0.0) (overtime! nyc-weight 0.0 0.005) (reset! invert-color 1.0))
44 (do (overtime! circle-edge -0.3) (overtime! nyc-weight 0.004) (reset! invert-color 2.0))
46 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.01))
48 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.012))
53 (do (overtime! circle-edge -0.5) (reset! nyc-weight 0.015))
(do (reset! circle-edge 0.0) (reset! nyc-weight 0.0)))))))
;;(remove-watch buffer-change-event-nomad :buffer-change-event-nomad)
(reset! cell-dance-weight 1.0)
(reset! splatter 1.0)
(fl/v 3.0)
(ctl-global-clock 0.2)
;;(kill beats)
(start-graphics "resources/shaders/nyc.glsl"
:textures [:overtone-audio :previous-frame
"resources/textures/tex16.png"]
:user-data {"iGlobalBeatCount" (atom {:synth beats :tap "global-beat-count"})
"iBeat" ibeat
"iStars" stars-weight
"iColor" color
"iCircleCount" circle-count
"iHalfPi" circle-slice
"iDeformCircles" circle-edge
"iCircularWeight" circular-weight
"iPopulationWeight" population-weight
"iBouncingWeight" cells-weight
"iNycWeight" nyc-weight
"iInvertColor" invert-color
"iCircleDanceWeight" cell-dance-weight
"iCircleDanceColor" cell-dance-color
"iDeath" fl/vol
"iSplatter" splatter
"iCircleDistort" circle-intensity
"iSmashTheParens" break-parens-in-case-of-emergency
})
(comment
(stop-graphics "resources/shaders/nyc.glsl")
(stop-everything!)
(stop))
)