diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-11-06 15:25:16 -0500 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-11-07 13:14:16 -0500 |
| commit | 275450c8c07a4f73e1f6e1da83578cc2ec2248b8 (patch) | |
| tree | 5076790f343ab537d28ff748dea82d2d63a1ef5d /dev | |
| parent | c62ed160a04c1ee5d08297d13a26630a590c5d6a (diff) | |
Vastly simplify controller setup
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/scratch.clj | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/dev/scratch.clj b/dev/scratch.clj index 9775320..8bfa7af 100644 --- a/dev/scratch.clj +++ b/dev/scratch.clj @@ -1,9 +1,7 @@ (ns scratch (:require [unheard.midi :as midi] [unheard.midi.percussion :refer [kick snare hat]] - [unheard.instrument.minilab3 :as minilab3] - [unheard.midi-util :as mu] - [unheard.clock :refer [clock]] + [unheard.instrument.minilab3 :refer [minilab3]] [unheard.theory :refer [note poly]] [missionary.core :as m])) @@ -21,57 +19,53 @@ (note >c 0 32 (m/latest #(+ % 7) >tonic)))) (defn song - [>c >tonic] + [{:keys [clock tonic]}] (poly - (triad >c >tonic) - (triad >c (m/latest #(+ % 12) >tonic)) + (triad clock tonic) + (triad clock (m/latest #(+ % 12) tonic)) ;; The rest of the "song" is a drum pattern. - (note >c 1 1 (m/ap kick)) - (note >c 9 1 (m/ap kick)) - (note >c 17 1 (m/ap kick)) - (note >c 25 1 (m/ap kick)) + (note clock 1 1 (m/ap kick)) + (note clock 9 1 (m/ap kick)) + (note clock 17 1 (m/ap kick)) + (note clock 25 1 (m/ap kick)) - (note >c 1 1 (m/ap hat)) - (note >c 5 1 (m/ap hat)) - (note >c 9 1 (m/ap hat)) - (note >c 13 1 (m/ap hat)) - (note >c 17 1 (m/ap hat)) - (note >c 21 1 (m/ap hat)) - (note >c 25 1 (m/ap hat)) - (note >c 29 1 (m/ap hat)) + (note clock 1 1 (m/ap hat)) + (note clock 5 1 (m/ap hat)) + (note clock 9 1 (m/ap hat)) + (note clock 13 1 (m/ap hat)) + (note clock 17 1 (m/ap hat)) + (note clock 21 1 (m/ap hat)) + (note clock 25 1 (m/ap hat)) + (note clock 29 1 (m/ap hat)) - (note >c 5 1 (m/ap snare)) - (note >c 13 1 (m/ap snare)) - (note >c 21 1 (m/ap snare)) - (note >c 29 1 (m/ap snare)))) + (note clock 5 1 (m/ap snare)) + (note clock 13 1 (m/ap snare)) + (note clock 21 1 (m/ap snare)) + (note clock 29 1 (m/ap snare)))) + +;; TODO: Move into /dev +;; Add logging +(defn debug-flow [f] + ((m/reduce prn nil + (m/ap (m/?< f))) prn prn)) (def run (midi/<bus midi-keyboard (fn [v] (m/ap ;; 2 is the number of message types, e.g. :key - (let [[>c c] (clock) - tonic (atom 0) - >tonic (m/signal (m/watch tonic)) - p (song >c >tonic)] + (let [controls (midi/controller v minilab3) + song-config {:clock (get-in controls [:knob 1]) + :tonic (get-in controls [:knob 2])} + p (song song-config)] (m/amb= - (let [[t f] (m/?> 2 (midi/keyboard v)) - [ch k v] (rest (m/?< f)) - chkv [ch k v]] - (if (mu/control-message? t) - (m/amb - (if (minilab3/is-knob 1 chkv) - (do (reset! c v) (m/amb)) - (m/amb)) - (if (minilab3/is-knob 2 chkv) - (do (reset! tonic v) (m/amb)) - (m/amb))) - (m/amb))) - [:n (m/?< (m/eduction (dedupe) p))] - [:c (m/?< (m/eduction (dedupe) >c))])))))) + [:n (m/?< p)] + [:c (m/?< (get-in controls [:knob 1]))])))))) +#_ (def cancel (run prn prn)) +#_ (cancel) |
