-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.nrepl-history
335 lines (324 loc) · 8.85 KB
/
.nrepl-history
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
(use 'midi)
(def launchpad (midi-in))
(defn midi-inst-player [inst]
(let [notes* (atom {})]
(fn [event ts]
(clojure.pprint/pprint event)
(clojure.pprint/pprint ts)
)))
(midi-handle-events launchpad adam-handler)
(use 'midi)
(def launchpad (midi-in))
(defn midi-inst-player [inst]
(let [notes* (atom {})]
(fn [event ts]
(clojure.pprint/pprint event)
(clojure.pprint/pprint ts)
)))
(midi-handle-events launchpad adam-handler)
(defn adam-handler
(let [notes* (atom {})]
(fn [event ts]
(clojure.pprint/pprint event)
(clojure.pprint/pprint ts)
)))
(defn adam-handler []
(let [notes* (atom {})]
(fn [event ts]
(clojure.pprint/pprint event)
(clojure.pprint/pprint ts)
)))
(midi-handle-events launchpad adam-handler)
(defn print-handler []
(let [notes* (atom {})]
(fn [event ts]
(with-open [w (clojure.java.io/writer "test.txt")]
(.write w (with-out-str
(clojure.pprint/pprint event)))
))))
(midi-handle-events launchpad print-handler)
(use 'midi)
(def launchpad (midi-in))
(def notes* (atom {}))
(defn print-handler [notelog]
(fn [event ts]
(cond
(= (:cmd event) :note-on)
(swap! notelog assoc (:note event) (inst :note (:note event) :velocity (:vel event)))
(or (= (:cmd event) :note-off)
(and (not (zero? (:note event)))
(zero? (:vel event))))
(if-let [note-id (get @notes* (:note event))]
(ctl note-id :gate 0)))))
(defn print-handler [notelog]
(fn [event ts]
(cond
(= (:cmd event) :note-on)
(swap! notelog assoc (:note event) "yay!")
(or (= (:cmd event) :note-off)
(and (not (zero? (:note event)))
(zero? (:vel event))))
(if-let [note-id (get @notes* (:note event))]
(ctl note-id :gate 0)))))
(defn print-handler [notelog]
(fn [event ts]
(cond
(= (:cmd event) :note-on)
(swap! notelog assoc (:note event) "yay!")
(or (= (:cmd event) :note-off)
(and (not (zero? (:note event)))
(zero? (:vel event))))
(if-let [note-id (get @notelog* (:note event))]
(swap! notelog dissoc (:note event)) ))))
(defn print-handler [notelog]
(fn [event ts]
(cond
(= (:cmd event) :note-on)
(swap! notelog assoc (:note event) "yay!")
(or (= (:cmd event) :note-off)
(and (not (zero? (:note event)))
(zero? (:vel event))))
(if-let [note-id (get @notelog (:note event))]
(swap! notelog dissoc (:note event)) ))))
(midi-handle-events launchpad (print-handler notes*))
notes
notes*
(use 'midi)
(def notes* (atom {}))
(defn print-handler [notelog]
(fn [event ts]
(cond
(= (:cmd event) :note-on)
(swap! notelog assoc (:note event) "yay!")
)))
(midi-handle-events launchpad (print-handler notes*))
(def launchpad (midi-in))
(midi-handle-events launchpad (print-handler notes*))
note*
notes*
(defn print-handler [notelog]
(fn [event ts]
(swap! notelog assoc :last-e event :last-ts ts)
)))
(defn print-handler [notelog]
(fn [event ts]
(swap! notelog assoc :last-e event :last-ts ts)
))
(midi-handle-events launchpad (print-handler notes*))
notes*
(get @notelog :last-e)
(get @notes :last-e)
(get @notes* :last-e)
(get @notes* :last-ts)
(use 'midi)
(def launchpad (midi-in))
(def notes (atom {}))
(defn print-handler [notelog]
(fn [event ts]
(swap! notelog assoc :last-e event :last-ts ts)
))
; (or (= (:cmd event) :note-off)
; (and (not (zero? (:note event)))
; (zero? (:vel event))))
; (if-let [note-id (get @notelog (:note event))]
; (swap! notelog dissoc (:note event)))
; )))
(midi-handle-events launchpad (print-handler notes))
@notes
(use 'midi)
(def launchpad (midi-in))
(def notes (atom {}))
(defn print-handler [notelog]
(fn [event ts]
(swap! notelog assoc :last-e event :last-ts ts)
))
; (or (= (:cmd event) :note-off)
; (and (not (zero? (:note event)))
; (zero? (:vel event))))
; (if-let [note-id (get @notelog (:note event))]
; (swap! notelog dissoc (:note event)))
; )))
(midi-handle-events launchpad (print-handler notes))
@notes
(use 'midi)
(def launchpad (midi-in))
(def notes (atom {}))
(defn print-handler [notelog]
(fn [event ts]
(swap! notelog assoc :last-e event :last-ts ts)))
(midi-handle-events launchpad (print-handler notes))
@notes
(require 'main(
(require 'main)
@notes
main/@notes
main/notes
(require 'main)
@device-events
@main/device_events
main/@device_events
main/device_events
(require 'main)
main/device-events
(require 'main)
main/device-events
(require 'main)
(map #(%) [{:a 1 :b 2} {:a 3 :b 4}])
(map #(:A %) [{:a 1 :b 2} {:a 3 :b 4}])
(map #(:a %) [{:a 1 :b 2} {:a 3 :b 4}])
(map #([(:a %) %]) [{:a 1 :b 2} {:a 3 :b 4}])
(map #('[(:a %) %]) [{:a 1 :b 2} {:a 3 :b 4}])
(into {} [:a 1 :b 2])
(hash-map :a 1 :b 2)
(reduce #(conj (:a %) %) [{:a 1 :b 2} {:a 3 :b 4}])
(reduce #(conj (:a %) %) [] [{:a 1 :b 2} {:a 3 :b 4}])
(reduce #(-> %1 (conj (:a %2)) (conj %2)) [] [{:a 1 :b 2} {:a 3 :b 4}])
(hash-map (reduce #(-> %1 (conj (:a %2)) (conj %2)) [] [{:a 1 :b 2} {:a 3 :b 4}]))
(apply hash-map (reduce #(-> %1 (conj (:a %2)) (conj %2)) [] [{:a 1 :b 2} {:a 3 :b 4}]))
(def events [{:a 1 :b 2} {:a 3 :b 4}])
(->> events
(reduce #(-> %1 (conj (:a %2)) (conj %2)) [])
(apply hash-map)))
(->> events
(reduce #(-> %1 (conj (:a %2)) (conj %2)) [])
(apply hash-map))
(def r (->> events
(reduce #(-> %1 (conj (:a %2)) (conj %2)) [])
(apply hash-map)))
(r 1)
(require 'main)
(def device-names [:piano])
(reduce
#(assoc %1 %2 {})
{}
(device-names))
(require 'main)
(use 'midi-clj)
(use '[midi-clj])
(use '[midi])
midi-shortmessage-command
(midi-shortmessage-command)
(midi-shortmessage-command :144)
(midi-shortmessage-command :44)
(midi-shortmessage-command 144)
(assoc {:a 1} :a ({} :a))
(into {} (remove (comp nil? second) {:a 1 :b nil}))
(mod 60 12)
(mod 61 12)
(mod 62 12)
(mod 71 12)
([:a :b :c] 0)
([:a :b :c] 1)
([:a :b :c] 2)
:C#
(/ 60 12)
(/ 61 12)
(quot 61 12)
(quot 62 12)
(quot 71 12)
(quot 72 12)
(defn- midi->note [midi-note]
(let [note-num (mod midi-note (count notes))]
(notes note-num)))
(defn- midi->octave [midi-note]
(def notes [:C :C# :D :D# :E :F :F# :G :G# :A :A# :B ])
(defn- midi->note [midi-note]
(let [note-num (mod midi-note (count notes))]
(notes note-num)))
(defn- midi->octave [midi-note]
(quot note-num (count notes)))
(defn- midi->octave [midi-note]
(quot midi-note (count notes)))
(midi->note 60)
(midi->note 61)
(midi->note 62)
(midi->octave 62)
(require '[thi.ng.color.core :as col])
(col/as-hsv (col/rgba 255 0 0))
(col/as-hsva (col/rgba 255 0 0))
(col/as-hsva (col/rgba 255 125 0))
(col/as-hsva (col/rgba 255 255 0))
(col/as-hsva (col/rgba 125 255 0))
(col/as-hsva (col/rgba 0 255 0))
(col/as-hsva (col/rgba 0 255 125))
(col/as-hsva (col/rgba 0 255 255))
(col/as-hsva (col/rgba 0 125 255))
(col/as-hsva (col/rgba 0 0 255))
(col/as-hsva (col/rgba 125 0 255))
(col/as-hsva (col/rgba 255 0 255))
(col/as-hsva (col/rgba 255 0 125))
(conj {:a 1} {:b 2})
(merge {:a 1} {:b 2})
(require 'colours)
(def middle-c { :amp 45 :decay 40 :note 60 })
(def c (colours/note->hsv middle-c))
c
(require 'main)
(/3 2)
(/ 3 2)
(% 3 2)
(/ 3 3)
(/ 3 2)
(ns example
(:use [uncomplicate.fluokitten core jvm]))
(fapply {a: (partial * 2)} {a: 2})
(fapply {:a (partial * 2)} {:a 2})
(fapply {:a #(* % 2)} {:a 2})
(fapply {1 {:a #(* % 2)}} {1 {:a 2}})
(op {1 {:a #(* % 2)}} {1 {:a 2}})
(fmap fapply {1 {:a #(* % 2)}} {1 {:a 2}})
(def state { :piano { 42 { :attack 70 :release 22 :note 42 }}})
(def mutators { :piano { 42 { :attack half :release half }}})
(def half #(/ % 2))
(def mutators { :piano { 42 { :attack half :release half }}})
(fmap fapply mutators state)
(fmap fmap fapply mutators state)
fmap (partial fmap fapply) mutators state)
(fmap (partial fmap fapply) mutators state)
(require 'main)
(require '[java-time :as jt])
(local-time)
(jt/local-time)
(str (jt/local-time))
(str (jt/local-datetime))
(str (jt/local-date-time))
(jt/local-date-time "2019-08-26T12:34:18.679")
(defn uuid [] (str (java.util.UUID/randomUUID)))
(uuid)
(require '[uncomplicate.fluokitten.core :as fk])
(fk/fapply {:a +} {:a 1})
(fk/fapply {:a + :b str} {:a 1})
(str)
(identity {:a 1})
(identity (:a {: 1})))
(identity (:a {:a 1}))
(identity (:a {:a {:b 2}}))
(def m {:a 1 :b 2 :c 3})
(def af identify)
(def af identity)
(def bf identity)
(def cf identity)
(def fs (juxt af bf cf))
(vs (juxt :a :b :c))
(def vs (juxt :a :b :c))
(map apply (zipmap fs vs))
(map apply (zipmap (fs) (vs)))
(zipmap (fs) (vs))
(zipmap fs vs)
(zipmap (fs) vs)
(map fs vs)
(map (fs) vs)
(map fs vs)
(map fs (vs))
(map fs (vs m))
(fs (vs m))
(- [1 2 4] [1 2 3])
(- (set [1 2 4]) (set [1 2 3]))
(if nil nil 0)
(if 1 nil 0)
(require 'main)
(def m {:a 1 :b 2}})
(def m {:a 1 :b 2})
(apply identity m)
(apply identity [m])
(require 'main)