├── resources ├── textures │ ├── space.png │ ├── tex09.jpg │ ├── tex16.png │ ├── time.png │ ├── repl-electric.png │ └── repl-electric-t.png └── shaders │ ├── zoomwave.glsl │ ├── waves.glsl │ ├── spectrograph.glsl │ ├── manhattan.glsl │ ├── fireworks.glsl │ └── space_and_time.glsl ├── .gitignore ├── src └── cassiopeia │ ├── emacs.clj │ ├── data │ └── ruchbah.clj │ ├── warm_up_monome.clj │ ├── engine │ ├── buffers.clj │ ├── monmapper.clj │ ├── expediency.clj │ ├── samples.clj │ ├── scheduled_sampler.clj │ ├── sequencer.clj │ ├── leap.clj │ ├── monome_sequencer.clj │ └── mixers.clj │ ├── speech.clj │ ├── view_screen.clj │ ├── destination │ ├── flatiron │ │ ├── utils.clj │ │ └── scores.clj │ ├── pop2.clj │ ├── beta.clj │ ├── flatiron.clj │ ├── yarra.clj │ ├── eta.clj │ ├── alpha.clj │ ├── chaos.clj │ ├── learning.clj │ ├── tsih.clj │ └── voices.clj │ ├── dirt.clj │ ├── space.clj │ ├── sound_test.clj │ ├── waves │ └── soprano.clj │ ├── samples.clj │ ├── warm_up.clj │ └── scratch.clj ├── README.md └── project.clj /resources/textures/space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/space.png -------------------------------------------------------------------------------- /resources/textures/tex09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/tex09.jpg -------------------------------------------------------------------------------- /resources/textures/tex16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/tex16.png -------------------------------------------------------------------------------- /resources/textures/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/time.png -------------------------------------------------------------------------------- /resources/textures/repl-electric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/repl-electric.png -------------------------------------------------------------------------------- /resources/textures/repl-electric-t.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/repl-electric/cassiopeia/HEAD/resources/textures/repl-electric-t.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | .lein-deps-sum 10 | .lein-failures 11 | .lein-plugins 12 | .lein-repl-history 13 | .nrepl-port 14 | hs_err_pid*.log 15 | .#* 16 | -------------------------------------------------------------------------------- /src/cassiopeia/emacs.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.emacs 2 | (:use [overtone.core] [mud.core] [mud.timing] [cassiopeia.samples])) 3 | 4 | (defonce client (osc-client "localhost" 4558)) 5 | 6 | (dotimes [i 100] 7 | (Thread/sleep 250) 8 | (kick-s) 9 | (osc-send client "/beat" "")) 10 | -------------------------------------------------------------------------------- /src/cassiopeia/data/ruchbah.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.data.ruchbah) 2 | 3 | (def flow-f-buf-record [:A3 :E3 :D3 :C4 :D3 :E3 :A3 :C3]) 4 | 5 | (def flow-buf-record [:A3 :C3 :C3 :C3 :E3 :D3 :E3 :D3 :A3 :A3 :E3 :E3 :D3 :C4 :D3 :A3]) 6 | 7 | (def high-pinging-record [:E3 :B2 :D3 :A3 :D3 :C4 :B3 :A5 :B4 :C3 :D4 :G4 :D3 :D3 :B3 :A3 :F3]) 8 | -------------------------------------------------------------------------------- /src/cassiopeia/warm_up_monome.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.warm-up-monome 2 | (:require [monome.core :as mon] 3 | [monome.fonome :as fon] 4 | [monome.polynome :as poly] 5 | [monome.kit.sampler :as samp] 6 | [cassiopeia.engine.monome-sequencer :as monome-sequencer])) 7 | 8 | (defonce m128 (mon/find-monome "/dev/tty.usbserial-m0000965")) 9 | 10 | (when m128 11 | (defonce ticker128-fon (fon/mk-fonome ::ticker128 16 6)) 12 | (defonce ticker128 (monome-sequencer/mk-ticker ticker128-fon ::ticker128)) 13 | (defonce __dock_ticker__ (poly/dock-fonome! m128 ticker128-fon ::ticker128 0 0)) 14 | ) 15 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/buffers.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.buffers 2 | (:use 3 | [overtone.live] 4 | [overtone.helpers audio-file lib file doc])) 5 | 6 | (defn buffer-mix-to-mono [b] 7 | (ensure-buffer-active! b) 8 | (let [n-chans (:n-channels b) 9 | rate (:rate b)] 10 | (cond 11 | (= 1 n-chans) b 12 | :else 13 | (let [data (buffer-data b) 14 | partitioned (partition n-chans (seq data)) 15 | mixed (mapv (fn [samps] (/ (apply + samps) n-chans)) partitioned) 16 | tmp-file-path (mk-path (mk-tmp-dir!) "mono-file.wav")] 17 | 18 | (write-wav mixed tmp-file-path rate 1) 19 | (let [new-b (buffer-alloc-read tmp-file-path)] 20 | (future (rm-rf! tmp-file-path)) 21 | new-b))))) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](http://s30.postimg.org/v33cwx6hd/Screen_Shot_2014_04_28_at_20_14_35.png) 2 | 3 | ## Experimental musical source code 4 | 5 | Code that makes noises and sounds with Overtone and lots of brackets. 6 | 7 | #### Try our some of our Repl Electric goodness 8 | 9 | Music: https://soundcloud.com/repl-electric 10 | Performances: https://vimeo.com/replelectric/videos 11 | 12 | ## More About Repl Electric 13 | 14 | http://www.repl-electric.com 15 | 16 | #### Want to start Live coding? 17 | 18 | Here is a good place to start: https://github.com/josephwilk/strangeloop2014/blob/master/readme.md 19 | 20 | #### License 21 | 22 | Copyright © 2014-2016 Joseph Wilk 23 | 24 | Distributed under the Eclipse Public License, the same as Clojure. 25 | 26 | ![](http://nadine-rossa.de/made-in-berlin-badge.png) 27 | -------------------------------------------------------------------------------- /src/cassiopeia/speech.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.speech 2 | (:use [overtone.live])) 3 | 4 | (def m1 ((speech-buffer "have you ever transcended space and time?" :voice :victoria) :rate 1 :loop? true :out-bus 0)) 5 | (def m2 ((speech-buffer "have you ever transcended space and time?" :voice :princess) :rate 1 :loop? true :out-bus 0)) 6 | (def m3 ((speech-buffer "have you ever transcended space and time?" :voice :kathy) :rate 1 :loop? true :out-bus 0)) 7 | (def m4 ((speech-buffer "have you ever transcended space and time?" :voice :vicki) :rate 1 :loop? true :out-bus 0)) 8 | 9 | (ctl m1 :rate 0.95) 10 | (ctl m2 :rate 0.85) 11 | (ctl m3 :rate 0.75) 12 | (ctl m4 :rate 0.65) 13 | 14 | (ctl m1 :rate 0.85 :amp 0.2) 15 | (ctl m2 :rate 0.75 :amp 0.2) 16 | (ctl m3 :rate 0.65 :amp 0.2) 17 | (ctl m4 :rate 0.55 :amp 0.2) 18 | 19 | (stop) 20 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/monmapper.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.monmapper 2 | (:use [overtone.live]) 3 | (:require [monome.polynome :as poly] 4 | [monome.fonome :as fon])) 5 | 6 | (defn bind 7 | "Quickly bind an on/off to a button on the monome" 8 | [m128 handle x y handlers] 9 | (let [the-fon (fon/mk-fonome handle 1 1) 10 | event-id (:id the-fon) 11 | led-id (str event-id "-led") 12 | press-id (str event-id "-press")] 13 | 14 | (poly/dock-fonome! m128 the-fon handle x y) 15 | 16 | (on-event [:fonome :led-change event-id] 17 | (fn [{:keys [x y new-leds]}] 18 | (let [on? (get new-leds [x y])] 19 | (if on? 20 | ((:on handlers)) 21 | ((:off handlers))))) 22 | led-id) 23 | 24 | (on-event [:fonome :press event-id] 25 | (fn [{:keys [x y fonome]}] 26 | (fon/toggle-led fonome x y)) 27 | press-id) 28 | 29 | the-fon)) 30 | -------------------------------------------------------------------------------- /src/cassiopeia/view_screen.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.view-screen 2 | (:use [overtone.live]) 3 | (:require [shadertone.tone :as t] 4 | [shadertone.shader :as shader])) 5 | 6 | ;;If we die due to gl errors keep the view screen running. 7 | ;;(shader/throw-exceptions-on-gl-errors false) 8 | 9 | ;;(demo (sin-osc)) 10 | 11 | (defonce color-l (atom 0.0)) 12 | (defonce color-r (atom 0.0)) 13 | (defonce res (atom 0.75)) 14 | (defonce space (atom 0.1)) 15 | (defonce expand (atom 0.0)) 16 | (defonce yinyan (atom 0.0)) 17 | (defonce no-circles (atom 1.0)) 18 | (defonce stars-direction (atom 1.0)) 19 | (defonce cellular-growth (atom 0.0)) 20 | 21 | (defonce cutout-w (atom 0.0)) 22 | (defonce stars-w (atom 0.0)) 23 | (defonce heart-w (atom 0.0)) 24 | (defonce hyper-w (atom 0.0)) 25 | (defonce cellular-w (atom 0.0)) 26 | 27 | (comment 28 | (t/start-fullscreen "resources/shaders/zoomwave.glsl" 29 | :textures [ :overtone-audio :previous-frame] 30 | :user-data {"iLColor" color-l "iRColor" color-r 31 | "iA" (atom {:synth s :tap "a"})}) 32 | 33 | (t/start-fullscreen "resources/shaders/wave.glsl" :textures [ :overtone-audio]) 34 | (t/stop) 35 | (stop)) 36 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/expediency.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.expediency 2 | (:require [shadertone.tone :as t]) 3 | (:use [mud.core] [mud.chords] [overtone.live])) 4 | 5 | (defn flatcat [& things] (flatten (apply concat things))) 6 | (defn stop-everything! [] (remove-all-beat-triggers) (remove-all-sample-triggers) (stop-all-chord-synth-buffers) (full-stop)) 7 | (defn as-chord [note] (flatten [note 0 0 0])) 8 | (defn chord-score [& score] (mapcat (fn [s] (if (sequential? (ffirst s)) (apply concat s) s)) score)) 9 | (defn chord-pattern! [& args] (apply chord-pattern args)) 10 | 11 | (alter-var-root (var ctl) (fn [f] (fn [& args] (if (and (map? (first args)) (:synths (first args))) 12 | (apply f (:synths (first args)) (rest args)) 13 | (apply f args))))) 14 | 15 | (def __graphics_state__ (atom {})) 16 | (defn stop-graphics [file] 17 | (when (get @__graphics_state__ file) 18 | (t/stop) 19 | (swap! __graphics_state__ dissoc file))) 20 | 21 | (defn start-graphics [& [file & args]] 22 | (if (get @__graphics_state__ file) 23 | (do 24 | (t/stop) 25 | (apply t/start-fullscreen file args)) 26 | (do 27 | (swap! __graphics_state__ assoc file true) 28 | (apply t/start-fullscreen file args)))) 29 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/samples.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.samples 2 | (:use overtone.live)) 3 | 4 | (defonce __sample_cache__ (atom {})) 5 | (def SAMPLE-ROOT "/Users/josephwilk/Dropbox/repl-electric/samples/") 6 | 7 | (defn load-local-sample [sample] (load-sample (str SAMPLE-ROOT sample))) 8 | (defn local-recording-start [name] (recording-start (str SAMPLE-ROOT name))) 9 | 10 | (defonce directory-for-samples (clojure.java.io/file "/Users/josephwilk/Workspace/music/samples/")) 11 | (defonce all-files-samples (file-seq directory-for-samples)) 12 | (defonce ether-set (file-seq (clojure.java.io/file "/Users/josephwilk/Workspace/music/samples/Ether"))) 13 | (defonce mountain-set (file-seq (clojure.java.io/file "/Users/josephwilk/Workspace/music/samples/Mountain"))) 14 | 15 | (defn find-sample 16 | ([match idx] (find-sample match idx all-files-samples)) 17 | ([match idx sample-files] 18 | (let [sample-key (str match ":" idx)] 19 | (or (get sample-key @__sample_cache__) 20 | (let [r (->> (filter #(and 21 | (re-find #"\.wav" (.getName %)) 22 | (re-find (re-pattern (str "(?i)" match)) (.getName %))) sample-files) 23 | (map #(.getAbsolutePath %1))) 24 | sample (sample (nth r (mod idx (count r))))] 25 | (swap! __sample_cache__ assoc sample-key sample) 26 | sample))))) 27 | 28 | (defn repl-player [sample & rargs] 29 | (let [args (apply hash-map rargs)] 30 | (if (and (seq args) (< (:rate args) 0)) 31 | (sample-player sample :rate (:rate args) :start-pos (/ (:size sample) 2)) 32 | (apply sample-player sample rargs)))) 33 | 34 | ;;(repl-player (find-sample "cymbal" 11) :rate -1.0) 35 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/flatiron/utils.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.flatiron.utils 2 | (:require [mud.core :as mud]) 3 | (:use overtone.live)) 4 | 5 | (defonce vol (atom 3.0)) 6 | 7 | (defn v [f] (reset! vol (float f)) (volume f)) 8 | 9 | (defn- traced-overtime! 10 | ([trace node field start end] (traced-overtime! trace node field start end 0.01)) 11 | ([trace node field start end rate] 12 | (cond 13 | (and (map? node) (:synths node)) (traced-overtime! (:synths node) field start end rate) 14 | 15 | (sequential? node) (doseq [n node] (traced-overtime! n field start end rate)) 16 | 17 | :else 18 | (letfn [(change-fn [val] (if (< end start) 19 | (if (< (- val rate) end) 20 | end 21 | (- val rate)) 22 | (if (> (+ val rate) end) 23 | end 24 | (+ val rate))))] 25 | (future 26 | (loop [val start] 27 | (Thread/sleep mud/overtime-default-sleep) 28 | (ctl node field val) 29 | (reset! trace (change-fn val)) 30 | (when (not= val end) 31 | (recur (change-fn val))))))))) 32 | 33 | (defn fadeout-master 34 | ([] (fadeout-master 1)) 35 | ([current] 36 | (traced-overtime! vol (foundation-output-group) :master-volume current 0 0.05))) 37 | 38 | (defn binary->pat [b](map #(Integer/parseInt %1) (clojure.string/split (Integer/toBinaryString b) #""))) 39 | 40 | (defn spread 41 | "Euclidean distribution for beats 42 | 43 | ``` 44 | (spread 1 4) => [1.0 0.0 0.0 0.0] 45 | ``` 46 | " 47 | ([num-accents size] (spread num-accents size 0)) 48 | ([num-accents size rotate-amount] 49 | (if (> num-accents size) 50 | (map (fn [_] 1.0) (range 0 size)) 51 | (let [pattern (map #(< (mod (* %1 num-accents) size) num-accents) (range 0 size))] 52 | (loop [rotations rotate-amount 53 | res pattern] 54 | (if (> rotations 0) 55 | (let [res (rotate 1 res) 56 | rotations (if (= true (first res)) (dec rotations) rotations)] 57 | (recur rotations res)) 58 | (map #(if %1 1.0 0.0) res))))))) 59 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/scheduled_sampler.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.scheduled-sampler 2 | "Stolen from the wonderful Meta-ex 3 | http://www.github.com/meta-ex" 4 | (:use [overtone.live]) 5 | (:use [cassiopeia.samples]) 6 | (:require [mud.timing :as tim] 7 | [overtone.helpers.synth :as synth-helpers])) 8 | 9 | (defsynth mono-beat-bus-samp-trig [buf 0 rate 1.0 start-pos 0.0 loop? 0 amp 1 out-bus 0 beat-b (:id (:beat tim/main-beat)) beat-cnt-b (:id (:count tim/main-beat)) mod-size 16] 10 | (let [cnt (mod (in:kr beat-cnt-b) 11 | mod-size) 12 | trg (running-max (= 0 cnt)) 13 | smp (scaled-play-buf 1 buf rate 14 | trg 15 | start-pos loop?) 16 | inv-trg (- 1 trg)] 17 | (detect-silence:ar (+ loop? inv-trg smp) 0.001 10 FREE) 18 | (out out-bus (* amp 19 | trg 20 | smp)))) 21 | 22 | (defsynth stereo-beat-bus-samp-trig [buf 0 rate 1.0 start-pos 0.0 loop? 0 amp 1 out-bus 0 beat-b (:id (:beat tim/main-beat)) beat-cnt-b (:id (:count tim/main-beat)) mod-size 16] 23 | (let [cnt (mod (in:kr beat-cnt-b) 24 | mod-size) 25 | trg (running-max (= 0 cnt)) 26 | smp (scaled-play-buf 2 buf rate 27 | trg 28 | start-pos loop?) 29 | inv-trg (- 1 trg)] 30 | (detect-silence:ar (+ loop? inv-trg smp) 0.001 10 FREE) 31 | (out out-bus (* amp 32 | trg 33 | smp)))) 34 | 35 | (defn schedule-sample [smp beat-bus & pargs] 36 | (assert (sample? smp)) 37 | (assert (tim/beat-bus? beat-bus)) 38 | (let [[target pos pargs] (synth-helpers/extract-target-pos-args 39 | pargs 40 | (foundation-default-group) 41 | :tail)] 42 | (if (= 1 (:n-channels smp)) 43 | (apply mono-beat-bus-samp-trig [pos target] (:id smp) pargs) 44 | (apply stereo-beat-bus-samp-trig [pos target] (:id smp) pargs)))) 45 | 46 | 47 | 48 | ;; (:size glitch1-s) 49 | 50 | ;; (def g (group) ) 51 | ;; (def a (schedule-sample glitch1-s tim/main-beat [:head g])) 52 | 53 | ;; (kill g) 54 | ;; (kill a) 55 | ;; (on-trigger 100 (fn [m] (println m))::foo) 56 | 57 | ;; (glitch1-s) 58 | 59 | ;; a 60 | ;; (glitch1-s) 61 | 62 | ;; (kill short-phrip) 63 | ;; (kill 467) 64 | 65 | (comment 66 | (kill mono-beat-bus-samp-trig) 67 | (kill stereo-beat-bus-samp-trig)) 68 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject stars "0.1.0-SNAPSHOT" 2 | :description "Repl Electric: Cassiopeia" 3 | :license {:name "Eclipse Public License" 4 | :url "http://www.eclipse.org/legal/epl-v10.html"} 5 | 6 | :dependencies [[org.clojure/clojure "1.5.1"] 7 | [overtone "0.9.1"] 8 | 9 | [mud "0.1.0-SNAPSHOT"] 10 | 11 | [korg-nano-kontrol2 "0.1.0-SNAPSHOT"] 12 | [launchpad "0.1.0-SNAPSHOT"] 13 | [monome "0.1.0-SNAPSHOT"] 14 | 15 | ;;[shadertone "0.2.4"] 16 | [shadertone "0.3.0-SNAPSHOT"] 17 | 18 | [rogerallen/leaplib "0.8.1"] 19 | [rogerallen/leaplib-natives "0.8.1"] 20 | 21 | [overtone.synths "0.1.0-SNAPSHOT"] 22 | [overtone.orchestra "0.1.0-SNAPSHOT"] 23 | 24 | [org.clojure/math.numeric-tower "0.0.4"]] 25 | 26 | :jvm-opts [ 27 | ;; "-agentpath:/Applications/YourKit_Java_Profiler_12.0.5.app/bin/mac/libyjpagent.jnilib" 28 | "-Xms512m" "-Xmx1g" ; Minimum and maximum sizes of the 29 | ; heap 30 | "-XX:+UseParNewGC" ; Use the new parallel GC in 31 | ; conjunction with 32 | "-XX:+UseConcMarkSweepGC" ; the concurrent garbage collector 33 | "-XX:+CMSConcurrentMTEnabled" ; Enable multi-threaded concurrent 34 | ; gc work (ParNewGC) 35 | "-XX:MaxGCPauseMillis=20" ; Specify a target of 20ms for max 36 | ; gc pauses 37 | "-XX:+CMSIncrementalMode" ; Do many small GC cycles to 38 | ; minimize pauses 39 | "-XX:MaxNewSize=257m" ; Specify the max and min size of 40 | ; the new 41 | "-XX:NewSize=256m" ; generation to be small 42 | "-XX:+UseTLAB" ; Uses thread-local object 43 | ; allocation blocks. This 44 | ; improves concurrency by reducing 45 | ; contention on 46 | ; the shared heap lock. 47 | "-XX:MaxTenuringThreshold=0" 48 | ;; "-XX:+PrintGC" ; Print GC info to stdout 49 | ;; "-XX:+PrintGCDetails" ; - with details 50 | ;; "-XX:+PrintGCTimeStamps" 51 | ] ; Makes the full NewSize available to 52 | ; every NewGC cycle, and reduces 53 | ; the 54 | ; pause time by not evaluating 55 | ; tenured objects. Technically, 56 | ; this 57 | ; setting promotes all live objects 58 | ; to the older generation, rather 59 | ; than copying them. 60 | ) 61 | -------------------------------------------------------------------------------- /src/cassiopeia/dirt.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.dirt 2 | "Easy access to DIRT's samples: https://github.com/yaxu/Dirt. 3 | Clone the repo and port `dirt-home` to it." 4 | (:use [overtone.live] [clojure.java.io] [overtone.helpers.file]) 5 | (:import java.io.File) 6 | (:import java.io.FileNotFoundException)) 7 | 8 | (defonce dirt-home (resolve-tilde-path "~/Workspace/music/Dirt/samples/")) 9 | (defonce __samples-cache__ (atom {})) 10 | 11 | (defn- walk [^File dir] 12 | (let [children (.listFiles dir) 13 | subdirs (filter #(.isDirectory %) children) 14 | files (filter #(.isFile %) children)] 15 | (concat files (mapcat walk subdirs)))) 16 | 17 | (defn dirt 18 | "Fetches and caches locally dirt samples. All dirt samples are refered to by a containing folder `sample-name` and an int `n` which specifies which file to play. Only wav + aiff are supported by Overtone so ignore anything else. 19 | Example: 20 | (sample-player (dirt :amp 0))" 21 | ([sample-name] (dirt sample-name 1)) 22 | ([sample-name n] 23 | (if-let [sample (@__samples-cache__ (str (name sample-name) ":" n))] 24 | sample 25 | (let [sample-name (name sample-name) 26 | samples (->> (walk (file (str dirt-home sample-name "/"))) 27 | (filter #(re-find #"(?i)wav|aiff" (or (file-extension %1) "")))) 28 | n (if (>= n (count samples)) 0 n) 29 | sample-file (nth samples n)] 30 | (when sample-file 31 | (swap! __samples-cache__ assoc (str sample-name ":" n) (load-sample sample-file)) 32 | (@__samples-cache__ (str sample-name ":" n))))))) 33 | 34 | (comment 35 | ;;Some example choices: 36 | (sample-player (dirt (rand-nth [:ab :ade :ades2 :ades3 :ades4 :alex :alphabet :amencutup :armora :arp :arpy :auto :baa :baa2 :bass :bass0 :bass1 :bass2 :bass3 :bassdm :bassfoo :battles :bd :bend :bev :bin :birds3 :bleep :blip :blue :bottle :breaks125 :breaks152 :breaks152loud :breaks152louder :breaks157 :breaks165 :breath :bubble :can :casio :cc :chin :chink :circus :clak :click :co :cosmicg :cp :cr :crow :d :db :diphone :diphone2 :dist :dork2 :dorkbot :dr :dr2 :dr55 :dr_few :drum :drumtraks :e :east :electro1 :erk :f :feel :feelfx :fest :fire :flick :foo :fuckable :future :gab :gabba :gabbaloud :gabbalouder :glasstap :glitch :glitch2 :gretsch :h :hand :hardcore :haw :hc :hh :hh27 :hit :hmm :ho :house :ht :if :ifdrums :incoming :industrial :insect :invaders :jazz :jungbass :jungle :jvbass :koy :kurt :latibro :led :less :lighter :lt :made :made2 :mash :mash2 :metal :miniyeah :moan :monsterb :moog :mouth :mp3 :msg :mt :mute :newnotes :noise :noise2 :notes :numbers :oc :odx :off :pad :padlong :pebbles :perc :peri :pluck :print :printshort :proc :procshort :psr :rave :rave2 :ravemono :rm :sax :seawolf :sequential :sf :sheffield :short :sid :sine :sitar :sn :space :speech :speechless :speedupdown :stab :stomp :subroc3d :sugar :sundance :tabla :tabla2 :tablex :tacscan :tech :techno :tink :tok :toys :trump :ul :ulgab :uxay :v :voodoo :wind :wobble :world :xmas :yeah]) (rand-int 100)) :rate 1;;(ranged-rand 0.1 1.0) 37 | ) 38 | 39 | (sample-player (dirt (rand-nth [:808 :bass2 :bass1 :bass0 :bend :bev :birds3]) (rand-int 100))) 40 | ) 41 | -------------------------------------------------------------------------------- /src/cassiopeia/space.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.space 2 | " 3 | ██████╗ ███████╗██████╗ ██╗ ███████╗██╗ ███████╗ ██████╗████████╗██████╗ ██╗ ██████╗ 4 | ██╔══██╗██╔════╝██╔══██╗██║ ██╔════╝██║ ██╔════╝██╔════╝╚══██╔══╝██╔══██╗██║██╔════╝ 5 | ██████╔╝█████╗ ██████╔╝██║ █████╗ ██║ █████╗ ██║ ██║ ██████╔╝██║██║ 6 | ██╔══██╗██╔══╝ ██╔═══╝ ██║ ██╔══╝ ██║ ██╔══╝ ██║ ██║ ██╔══██╗██║██║ 7 | ██║ ██║███████╗██║ ███████╗ ███████╗███████╗███████╗╚██████╗ ██║ ██║ ██║██║╚██████╗ 8 | ╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝ ╚══════╝╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ 9 | " 10 | (:use [overtone.live] [cassiopeia.waves.synths] [mud.core] [cassiopeia.waves.soprano] [cassiopeia.view-screen] [mud.core] [cassiopeia.engine.scheduled-sampler] [cassiopeia.samples] [cassiopeia.dirt] [cassiopeia.engine.samples]) 11 | (:require [mud.timing :as time] [overtone.studio.fx :as fx] [shadertone.tone :as t] [cassiopeia.engine.buffers :as b] [cassiopeia.destination.flatiron.utils :as fl])) 12 | 13 | (ctl time/root-s :rate 4) 14 | 15 | (do (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 96 [bass-notes-buf hats-buf kick-seq-buf white-seq-buf effects-seq-buf effects2-seq-buf bass-notes-buf]) 16 | (pattern! kick-seq-buf [0]) 17 | (pattern! bass-notes-buf (repeat 2 (repeat 4 [:B1 :B1 :B1 :B1])) 18 | (repeat 2 (repeat 4 [:E#1 :E#1 :E#1 :E#1])) 19 | (repeat 2 (repeat 4 [:F#1 :F#1 :F#1 :F#1])))) 20 | 21 | (pattern! kick-seq-buf [0]) 22 | (pattern! hats-buf [0]) 23 | (pattern! white-seq-buf [0]) 24 | 25 | (def beats (buffer->tap kick-seq-buf (:count time/beat-1th))) 26 | 27 | (do (reset! color-l 1.0) (reset! color-r 1.0) (reset! expand 1.0) (reset! stars-w 1.0) (reset! yinyan 1.0) (reset! cellular-w 0.0)) 28 | (reset! heart-w 0.0) 29 | (reset! cutout-w 0.0) 30 | (reset! cellular-w 0.0) 31 | (reset! no-circles 1.0) 32 | (reset! cutout-w 0.0) 33 | (reset! heart-w 0.0) 34 | 35 | (comment 36 | (t/stop) 37 | (t/start-fullscreen "resources/shaders/electric.glsl" 38 | :textures [:overtone-audio :previous-frame 39 | "resources/textures/repl-electric-t.png" 40 | "resources/textures/tex16.png"] 41 | :user-data {"iMixRate" color-l "iColorStrength" color-r "iRes" res 42 | "iSpace" space "iExpand" expand "iYinYan" yinyan 43 | "iCircleCount" no-circles "iStarDirection" stars-direction 44 | "iCutoutWeight" cutout-w 45 | "iSpaceLightsWeight" stars-w 46 | "iDistortedWeight" heart-w 47 | "iSpaceyWeight" hyper-w 48 | "iCellularWeight" cellular-w 49 | "iCellGrowth" cellular-growth 50 | "iMeasureCount" (atom {:synth beats :tap "measure-count"}) 51 | "iBeat" (atom {:synth beats :tap "beat"}) 52 | "iBeatCount" (atom {:synth beats :tap "beat-count"})})) 53 | -------------------------------------------------------------------------------- /src/cassiopeia/sound_test.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.sound-test 2 | "Check the settings of audio equipment to sync correct volume levels." 3 | (:use [overtone.live] [cassiopeia.waves.synths] [mud.core] [cassiopeia.waves.soprano] [cassiopeia.view-screen] [mud.core] [cassiopeia.engine.scheduled-sampler] [cassiopeia.samples] [cassiopeia.dirt] [cassiopeia.engine.samples]) 4 | (:require [mud.timing :as time] [overtone.studio.fx :as fx] [shadertone.tone :as t] [cassiopeia.engine.buffers :as b])) 5 | 6 | (ctl time/root-s :rate 4) 7 | 8 | (do 9 | (defonce singers-g (group "singers")) 10 | (defonce note-buf (buffer 128)) 11 | (defonce yeh-seq-buf (buffer 128)) 12 | (doseq [i (range 0 3)] (slow-singer [:head singers-g] :note-buf note-buf :amp 2.9 :beat-b (:beat time/beat-4th) :count-b (:count time/beat-4th) :seq-b yeh-seq-buf :beat-num i :index-b yeh-index-buffer :num-steps 3)) 13 | 14 | (pattern! yeh-seq-buf 15 | [0 0 0 0] 16 | [0 0 0 0] 17 | [0 0 0 0] 18 | [1 0 0 0] 19 | [1 0 0 0] 20 | [1 0 0 0]) 21 | ) 22 | 23 | (do (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 96 [bass-notes-buf hats-buf kick-seq-buf white-seq-buf effects-seq-buf effects2-seq-buf bass-notes-buf]) 24 | (pattern! kick-seq-buf [0]) 25 | (pattern! bass-notes-buf (repeat 2 (repeat 4 [:B1 :B1 :B1 :B1])) 26 | (repeat 2 (repeat 4 [:E#1 :E#1 :E#1 :E#1])) 27 | (repeat 2 (repeat 4 [:F#1 :F#1 :F#1 :F#1])))) 28 | 29 | (pattern! kick-seq-buf [1 0 1 0 0 0 0 0]) 30 | (pattern! hats-buf [0 0 0 0 0 0 1 1]) 31 | (pattern! white-seq-buf [0 1 1 0 1 0 1 1]) 32 | (pattern! effects-seq-buf (repeat 4 [1 0 0 0])) 33 | (pattern! effects2-seq-buf [0 0 0 0] [1 1 1 1] [0 0 0 0] [1 0 1 1]) 34 | (pattern! hats-buf (repeat 6 (concat (repeat 3 [0 1 0 0]) [1 1 0 0]))) 35 | 36 | (def kicker (doseq [i (range 0 96)] (kick2 [:head drums-g] :note-buf bass-notes-buf :seq-buf kick-seq-buf :num-steps 96 :beat-num i :noise 0 :amp 1))) 37 | (ctl drums-g :mod-freq 10.2 :mod-index 0.1 :noise 0) 38 | 39 | (def ghostly-snares (doall (map #(seqer [:head drum-effects-g] :beat-num %1 :pattern effects-seq-buf :amp 0.2 :num-steps 16 :buf (b/buffer-mix-to-mono snare-ghost-s)) (range 0 16)))) 40 | 41 | (def bass-kicks (doall (map #(seqer [:head drum-effects-g] :beat-num %1 :pattern effects2-seq-buf :amp 0.1 :num-steps 8 :buf (b/buffer-mix-to-mono deep-bass-kick-s)) (range 0 8)))) 42 | 43 | (def hats (doall (map #(high-hats [:head drums-g] :amp 0.2 :mix (nth (take 32 (cycle [1.0 1.0])) %1) :room 4 :note-buf bass-notes-buf :seq-buf hats-buf :num-steps 32 :beat-num %1) (range 0 32)))) 44 | (ctl hats :damp 1.9 :mix 0.2 :room 10 :amp 0.2) 45 | 46 | (def white-hats (doall (map #(whitenoise-hat [:head drums-g] :amp 0.2 :seq-buf white-seq-buf :num-steps 16 :beat-num %1) (range 0 16)))) 47 | 48 | 49 | (schedule-sample mm-low-s time/main-beat :mod-size 64 :amp 0.9) 50 | (schedule-sample mm-high-s time/main-beat :mod-size 64 :amp 0.2) 51 | (schedule-sample whisper-s time/main-beat :mod-size 64 :amp 0.09) 52 | (mono-player moore-s :amp 1 :rate 1) 53 | (mono-player the-sound-of-live-coding-s :amp 0.5 :rate 0.99) 54 | (echoey-buf :b moore-s) 55 | (spacy moore-s) 56 | (echoey-buf signals-s) 57 | (spacy signals-s :amp 2.3) 58 | -------------------------------------------------------------------------------- /resources/shaders/zoomwave.glsl: -------------------------------------------------------------------------------- 1 | uniform float iLColor; 2 | uniform float iRColor; 3 | uniform float iA; 4 | uniform float iRes; 5 | uniform float iSpace; 6 | uniform float iExpand; 7 | uniform float iYinYan; 8 | uniform float iOvertoneVolume; 9 | 10 | const float scale=10.5; 11 | const float detail=10.5; 12 | const float width=0.1; 13 | 14 | const int smoothWave=0; 15 | const float waveReducer=0.1; 16 | const int lightOn=0; 17 | 18 | vec3 lightdir=-vec3(.1,.0,0.); 19 | float motion(vec3 p) { 20 | float acceleration = 0.0; 21 | float movementReducer = 10.0; 22 | 23 | float t=iGlobalTime; 24 | float dotp=dot(p,p); 25 | 26 | p = p/dotp*scale; 27 | p = sin(p+vec3(1,t/movementReducer,t*acceleration/movementReducer)); 28 | float d=length(p.yz)-width; 29 | d = min(d,length(p.xz) - width); 30 | d = min(d,length(p.xy) - width); 31 | d = min(d,length(p*p*p)-width*.3); 32 | return d*dotp/scale; 33 | } 34 | 35 | vec3 normal(vec3 p) { 36 | vec3 e = vec3(0.0, detail, 0.0); 37 | 38 | return normalize(vec3(motion(p+e.yxx)-motion(p-e.yxx), 39 | motion(p+e.xyx)-motion(p-e.xyx), 40 | motion(p+e.xxy)-motion(p-e.xxy))); 41 | } 42 | 43 | float light(in vec3 p, in vec3 dir) { 44 | vec3 ldir=normalize(lightdir); 45 | vec3 n=normal(p); 46 | float sh=0.1; 47 | float diff=max(0.,dot(ldir,-n))+.1*max(0.,dot(normalize(dir),-n)); 48 | vec3 r = reflect(ldir,n); 49 | float spec=max(0.,dot(dir,-r))*sh; 50 | return diff+pow(spec,20.)*.7; 51 | } 52 | 53 | float smoothbump(float center, float width, float x, float orien) { 54 | float w2 = width/2.0; 55 | float cp = center+w2; 56 | float cm = center-w2; 57 | float c; 58 | 59 | if(orien > 0.0){ 60 | x = orien-x; 61 | } 62 | 63 | if(iYinYan > 0.0){ 64 | c = iYinYan*smoothstep(cm, center, x); 65 | } 66 | else{ 67 | c = smoothstep(cm, center, x) * 1-smoothstep(center, cp, x); 68 | } 69 | return c; 70 | } 71 | 72 | vec3 hsv2rgb(float time,float mixRate,float v) { 73 | return mix(vec3(1.0), clamp((abs(fract(time+vec3(2.,3.,1.)/3.)*6.-3.)-1.),0.,1.),mixRate)*v; 74 | } 75 | 76 | vec4 generateWave(vec2 uv, float yOffset, float orien){ 77 | float colorChangeRate = 10.0; 78 | vec4 wa = texture2D(iChannel0, vec2(uv.x, iRes*2.9)); 79 | float wave = waveReducer*wa.x; 80 | 81 | if(smoothWave==0){ 82 | wave = smoothbump(0.2,(6.0/iResolution.y), wave+uv.y-yOffset, orien); //0.5 83 | //wave = (-1.0 * wave)+0.5; 84 | } 85 | vec3 wc = wave * hsv2rgb(fract(iGlobalTime/colorChangeRate),iLColor,iRColor); 86 | //0.1 0.1 0.9 0.9 87 | 88 | float zf = -0.05; 89 | vec2 uv2 = (1.0+zf)*uv-(zf/2.0,zf/2.0); 90 | vec3 pc = iSpace*texture2D(iChannel1, uv2).rgb; 91 | 92 | return vec4(vec3(wc+pc), 1.0); 93 | } 94 | 95 | void main(void) 96 | { 97 | float space = 0.1; 98 | float res = 0.75; 99 | 100 | vec2 uv = gl_FragCoord.xy / iResolution.xy; 101 | vec2 uv2 = gl_FragCoord.xy / iResolution.xy; 102 | vec2 uv3 = gl_FragCoord.xy / iResolution.xy; 103 | 104 | vec4 wave1 = generateWave(uv2, 0.1, uv.x * iExpand); 105 | vec4 wave2 = generateWave(uv, 0.3, 0.0 * iExpand); 106 | vec4 wave3 = generateWave(uv3, 0.2, uv.x * iExpand); 107 | vec4 wave4 = generateWave(uv3, 0.25,-uv.x * iExpand); 108 | 109 | vec4 w = mix(mix(mix(wave1,wave2,0.5), wave3, 0.5), wave4,0.5); 110 | 111 | if(lightOn==1){ 112 | vec3 from=vec3(0.,0.1,-1.2); 113 | vec3 dir=normalize(vec3(uv,1.)); 114 | float col = light(from, dir); 115 | gl_FragColor = w*vec4(col); 116 | } 117 | else{ 118 | gl_FragColor = w; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /resources/shaders/waves.glsl: -------------------------------------------------------------------------------- 1 | uniform float iLColor; 2 | uniform float iRColor; 3 | uniform float iA; 4 | uniform float iRes; 5 | uniform float iSpace; 6 | uniform float iExpand; 7 | uniform float iYinYan; 8 | uniform float iOvertoneVolume; 9 | uniform float iBeat; 10 | 11 | const float scale=50.5; 12 | const float detail=50.5; 13 | const float width=0.001; 14 | 15 | const int smoothWave=0; 16 | const float waveReducer=0.1; 17 | const int lightOn=1; 18 | 19 | vec3 lightdir=-vec3(.1,.0,0.); 20 | float motion(vec3 p) { 21 | float acceleration = 10.0; 22 | float movementReducer = 10.0; 23 | 24 | float t=iGlobalTime; 25 | float dotp=dot(p,p); 26 | 27 | p = p/dotp*scale; 28 | p = sin(p+vec3(1,t/movementReducer,t*acceleration/movementReducer)); 29 | float d=length(p.yz)-width; 30 | d = min(d,length(p.xz) - width); 31 | d = min(d,length(p.xy) - width); 32 | d = min(d,length(p*p*p)-width*.3); 33 | return d*dotp/scale; 34 | } 35 | 36 | vec3 normal(vec3 p) { 37 | vec3 e = vec3(0.0, detail, 0.0); 38 | 39 | return normalize(vec3(motion(p+e.yxx)-motion(p-e.yxx), 40 | motion(p+e.xyx)-motion(p-e.xyx), 41 | motion(p+e.xxy)-motion(p-e.xxy))); 42 | } 43 | 44 | float light(in vec3 p, in vec3 dir) { 45 | vec3 ldir=normalize(lightdir); 46 | vec3 n=normal(p); 47 | float sh=0.99; 48 | float diff=max(0.,dot(ldir,-n))+.1*max(0.,dot(normalize(dir),-n)); 49 | vec3 r = reflect(ldir,n); 50 | float spec=max(0.,dot(dir,-r))*sh; 51 | return diff+pow(spec,20.)*.2; 52 | } 53 | 54 | float smoothbump(float center, float width, float x, float orien) { 55 | float lineWidth = width/2.0; 56 | float centerPlus = center+lineWidth; 57 | float centerMinus = center-lineWidth; 58 | float c; 59 | 60 | if(orien > 0.0){ 61 | x = orien-x; 62 | } 63 | 64 | if(iYinYan > 0.0){ 65 | c = iYinYan*smoothstep(centerMinus, center, x); 66 | } 67 | else{ 68 | c = smoothstep(centerMinus, center, x) * 1-smoothstep(center, centerPlus, x); 69 | } 70 | return c; 71 | } 72 | 73 | vec3 hsv2rgb(float time,float mixRate,float v) { 74 | vec3 c = clamp((abs(fract(time+vec3(2.,3.,1.)/3.)*6.-3.)-1.),0.,1.); 75 | //c = c*iBeat; 76 | c = c * clamp(iBeat,0.1, 0.3)+0.7; 77 | return mix(vec3(1.0), c, mixRate)*v; 78 | } 79 | 80 | vec4 generateWave(vec2 uv, float yOffset, float orien){ 81 | float colorChangeRate = 10.0; 82 | vec4 wa = texture2D(iChannel0, vec2(uv.x, iRes*2.9)); 83 | float wave = waveReducer*wa.x; 84 | 85 | if(smoothWave==0){ 86 | wave = smoothbump(0.2,(6.0/iResolution.y), wave+uv.y-yOffset, orien); //0.5 87 | //wave = (-1.0 * wave)+0.5; 88 | } 89 | vec3 wc = wave * hsv2rgb(fract(iGlobalTime/colorChangeRate),iLColor,iRColor); 90 | //0.1 0.1 0.9 0.9 91 | 92 | float zf = -0.05; 93 | vec2 uv2 = (1.0+zf)*uv-(zf/2.0,zf/2.0); 94 | vec3 pc = iSpace*texture2D(iChannel1, uv2).rgb; 95 | 96 | return vec4(vec3(wc+pc), 1.0); 97 | } 98 | 99 | void main(void) 100 | { 101 | float space = 0.1; 102 | float res = 0.75; 103 | 104 | vec2 uv; 105 | vec2 uv2; 106 | vec2 uv3; 107 | 108 | uv = (gl_FragCoord.xy / iResolution.xy); 109 | uv2 = (gl_FragCoord.xy / iResolution.xy); 110 | uv3 = (gl_FragCoord.xy / iResolution.xy); 111 | 112 | //uv.x = uv.x * iBeat; 113 | //uv3.x = uv3.x * iBeat; 114 | 115 | vec4 wave1 = generateWave(uv2, 0.1, uv.x * iExpand); 116 | vec4 wave2 = generateWave(uv, 0.3, 0.0 * iExpand); 117 | vec4 wave3 = generateWave(uv3, 0.2, 1-uv.x * iExpand); 118 | vec4 wave4 = generateWave(uv3, 0.25,-uv.x * iExpand); 119 | 120 | vec4 w = mix(mix(mix(wave1,wave2,0.5), wave3, 0.5), wave4,0.5); 121 | 122 | if(lightOn==1){ 123 | vec3 from=vec3(0.,0.1,-1.2); 124 | vec3 dir=normalize(vec3(uv,1.)); 125 | float col = light(from, dir); 126 | col = col; 127 | gl_FragColor = w*vec4(col); 128 | } 129 | else{ 130 | gl_FragColor = w; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/cassiopeia/waves/soprano.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.waves.soprano 2 | (:use overtone.live)) 3 | 4 | (defonce silent-buffer (buffer 0)) 5 | 6 | (def soprano-root-dir "/Users/josephwilk/Workspace/music/samples/soprano/Samples/Sustains") 7 | 8 | (defonce mm-low-s (load-sample (str soprano-root-dir "/Mm p/vor_sopr_sustain_mm_p_03.wav"))) 9 | (defonce mm-high-s (load-sample (str soprano-root-dir "/Mm p/vor_sopr_sustain_mm_p_04.wav"))) 10 | 11 | (defonce soprano-samples 12 | (doall (map (fn [idx note] [note (load-sample 13 | (str soprano-root-dir (format "/Ee F/vor_sopr_sustain_ee_F_%02d" idx) ".wav"))]) (range 1 14) [60 61 62 63 64 65 66 67 68 69 70 71 72 73 74]))) 14 | 15 | (defonce ah-strong-soprano-samples 16 | (doall (map (fn [idx note] [note (load-sample 17 | (str soprano-root-dir (format "/Ah F/vor_sopr_sustain_ah_F_%02d" idx) ".wav"))]) (range 1 14) [60 61 62 63 64 65 66 67 68 69 70 71 72 73 74]))) 18 | 19 | (defonce ah-soprano-samples 20 | (doall (map (fn [idx note] [note (load-sample 21 | (str soprano-root-dir (format "/Ah p/vor_sopr_sustain_ah_p_%02d" idx) ".wav"))]) (range 1 14) [60 61 62 63 64 65 66 67 68 69 70 71 72 73 74]))) 22 | 23 | (defonce yeh-soprano-samples 24 | (doall (map (fn [idx note] [note (load-sample 25 | (str soprano-root-dir (format "/Yeh p/vor_sopr_sustain_eh_p_%02d" idx) ".wav"))]) (range 1 14) [60 61 62 63 64 65 66 67 68 69 70 71 72 73 74]))) 26 | 27 | (defonce index-buffer 28 | (let [b (buffer 128)] 29 | (buffer-fill! b (:id silent-buffer)) 30 | (doseq [[note val] soprano-samples] 31 | (buffer-set! b note (:id val))) 32 | b)) 33 | 34 | (defonce ah-index-buffer 35 | (let [b (buffer 128)] 36 | (buffer-fill! b (:id silent-buffer)) 37 | (doseq [[note val] ah-soprano-samples] 38 | (buffer-set! b note (:id val))) 39 | b)) 40 | 41 | (defonce ah-strong-index-buffer 42 | (let [b (buffer 128)] 43 | (buffer-fill! b (:id silent-buffer)) 44 | (doseq [[note val] ah-strong-soprano-samples] 45 | (buffer-set! b note (:id val))) 46 | b)) 47 | 48 | (defonce yeh-index-buffer 49 | (let [b (buffer 128)] 50 | (buffer-fill! b (:id silent-buffer)) 51 | (doseq [[note val] yeh-soprano-samples] 52 | (buffer-set! b note (:id val))) 53 | b)) 54 | 55 | (defsynth sing [out-bus 0 note 60 amp 0.1 pos 0] 56 | (let [buf (index:kr (:id index-buffer) note) 57 | env (env-gen (adsr :attack 2 :release 1 :sustain 1 :decay 0.2) :action FREE )] 58 | (out 0 (* env amp (pan2 (scaled-play-buf 1 buf) pos))))) 59 | 60 | (defsynth fast-singer [note-buf 0 amp 1 pos 0 attack 1 release 0.4 count-b 0 beat-b 0] 61 | (let [cnt (in:kr count-b) 62 | trg (in:kr beat-b) 63 | note (buf-rd:kr 1 note-buf cnt) 64 | buf (index:kr (:id index-buffer) note) 65 | env (env-gen (perc :release release :attack attack) :gate trg)] 66 | (out 0 (* env amp (pan2 (scaled-play-buf 1 buf :rate 1 :trigger trg) pos))))) 67 | 68 | (defsynth fast-varied-singer [note-buf 0 amp 1 pos 0 release 0.4 count-b 0 beat-b 0 attack-b 0] 69 | (let [cnt (in:kr count-b) 70 | trg (in:kr beat-b) 71 | note (buf-rd:kr 1 note-buf cnt) 72 | attack (buf-rd:kr 1 attack-b cnt) 73 | buf (index:kr (:id index-buffer) note) 74 | env (env-gen (perc :release release :attack attack) :gate trg)] 75 | (out 0 (* env amp (pan2 (scaled-play-buf 1 buf :rate 1 :trigger trg) pos))))) 76 | 77 | (defsynth slow-singer [note-buf 0 amp 1 pos 0 release 0.2 count-b 0 beat-b 0 seq-b 0 beat-num 0 num-steps 6 78 | attack 0.2 release 6 decay 0.09 index-b 0] 79 | (let [cnt (in:kr count-b) 80 | beat-trg (in:kr beat-b) 81 | note (buf-rd:kr 1 note-buf cnt) 82 | bar-trg (and (buf-rd:kr 1 seq-b cnt) 83 | (= beat-num (mod cnt num-steps)) 84 | beat-trg) 85 | buf (index:kr index-b note) 86 | env (env-gen (adsr :attack attack :sustain 6 :release release :decay decay) :gate bar-trg)] 87 | (out 0 (* amp env (pan2 (scaled-play-buf 1 buf :rate 1 :trigger bar-trg) pos))))) 88 | -------------------------------------------------------------------------------- /resources/shaders/spectrograph.glsl: -------------------------------------------------------------------------------- 1 | // Spectrograph.glsl - display the FFT over time. 2 | float SEC_PER_SCREEN = 30.0; // cursor crosses the screen every 30 3 | // seconds 4 | float AMP_SCALE = (1.0/2.0); // fft data should be in the 0-1 range, 5 | // but everyone's sound level is slightly 6 | // different. Scale the fft results for 7 | // display. 8 | float FREQ_SCALE = (4096.0/4096.0); // By default, 0-20,000Hz is displayed, 9 | // but often we care little about the 10 | // highest frequencies. e.g. ccale max 11 | // freq by 1/2 to display 0-10,000. 12 | 13 | // convert hue saturation & value to vec3(red, green, blue) 14 | vec3 hsv2rgb(float h, float s, float v) { 15 | return mix(vec3(1.),clamp((abs(fract(h+vec3(3.,2.,1.)/3.)*6.-3.)-1.),0.,1.),s)*v; 16 | } 17 | 18 | // this routine is called once for every pixel in our window. 19 | void main(void) 20 | { 21 | // setup uv for indexing into a texture where we need 22 | // normalized [0.0,1.0) coordinate values. 23 | // 24 | // gl_FragCoord.xy communicates the current pixel location to the 25 | // shader. gl_FragCoord.x will range from [0,1024), .y ranges 26 | // [0,512) iResolution.xy is a constant set to the window size = { 27 | // 1024, 512 } 28 | vec2 uv = gl_FragCoord.xy/iResolution.xy; 29 | 30 | // the iChannel0 texture is :overtone-audio and that data is a 512x2 array 31 | // of sound data 32 | // row 1 is the fft data and row 2 is the current sound wave data 33 | // the texture2D call uses the 2nd argument to index into that data. 34 | // the first arg is the current pixel's normalized Y location 35 | // a value of 0.25 for the 2nd arg selects only FFT data 36 | // change the last line to 37 | // gl_FragColor = vec4(vec3(fft),1.0); 38 | // and see the full window filled with the same sonogram data. 39 | float fi = FREQ_SCALE*uv.y; 40 | // add 2x super-sampling to help with narrow frequencies 41 | float fid = FREQ_SCALE/4096.0/2.0; // 1/2 texel 42 | float fft = (AMP_SCALE * 0.5 * 43 | (max(0.0, texture2D(iChannel0,vec2(fi,0.25)).x) + 44 | max(0.0, texture2D(iChannel0,vec2(fi+fid,0.25)).x))); 45 | 46 | // let's have some fun with that fft value...change scalar into a 47 | // hue with red as the peak. Also adjust the value so quiet 48 | // frequencies are black. 49 | vec3 fft3 = hsv2rgb(1.0-fft,0.5,fft); 50 | 51 | // But, we don't want the full screen to show the current FFT. We 52 | // want to only update the data under the cursor. So, we use the 53 | // iGlobalTime input to find a particular X value for a column we 54 | // want to update. The following creates a value that ranges from 55 | // [0,1024) over 30 seconds. 56 | int cur_x = int(fract(iGlobalTime/SEC_PER_SCREEN)*iResolution.x); 57 | 58 | // For the data that is NOT under the cursor, we want the older 59 | // sonogram data that we rendered into the framebuffer. get that 60 | // from the iChannel1 :previous-frame texture. The uv coordinate 61 | // provide a 1:1 mapping from old to new. 62 | vec3 oc = texture2D(iChannel1,uv).rgb; 63 | 64 | // At last, we can derive our current pixel's color. 65 | // the ternary logic here just selects: 66 | // if this pixel's x value is the cursor's x value 67 | // the color is the current fft value 68 | // else if this pixel is one to the right of the cursor 69 | // draw a yellow pixel (makes a vertical line) 70 | // else 71 | // use the old color from the previous frame 72 | // Note that cur_x and int(gl_FragCoord.x) are integers ranging [0,1024) 73 | vec3 c = ((cur_x == int(gl_FragCoord.x)) ? 74 | fft3 : 75 | (((cur_x+1) == int(gl_FragCoord.x)) ? 76 | vec3(0.8,0.8,0.0) : 77 | oc)); 78 | 79 | // finally, tell OpenGL what the color of this pixel is. 80 | gl_FragColor = vec4(c,1.0); 81 | } 82 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/pop2.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.pop2 2 | (:use overtone.live) 3 | (:use mud.core) 4 | (:use cassiopeia.waves.synths) 5 | (:use cassiopeia.samples) 6 | (:use cassiopeia.engine.buffers) 7 | ;; (:use dirt) 8 | (:require [mud.timing :as time])) 9 | 10 | (ctl time/root-s :rate 7) 11 | 12 | (defonce tonal-notes-b (buffer 256)) 13 | (defonce tonal-reverb-b (buffer 256)) 14 | 15 | (pattern! tonal-notes-b 16 | (repeat 8 (degrees [1 3 0 0] :minor :F3)) 17 | (repeat 8 (degrees [3 4 0 0] :minor :F3)) 18 | (repeat 8 (degrees [5 7 0 0] :minor :F3)) 19 | (repeat 8 (degrees [7 8 0 0] :minor :F3))) 20 | 21 | (do 22 | (defsynth tonal [amp 1 notes-buf 0 23 | beat-trg-bus (:beat time/beat-1th) 24 | beat-bus (:count time/beat-1th)] 25 | (let [cnt (in:kr beat-bus) 26 | trg (in:kr beat-trg-bus) 27 | note (buf-rd:kr 1 notes-buf cnt) 28 | 29 | freq (midicps note) 30 | src (mix [(sin-osc freq) 31 | (saw freq) 32 | (blip freq (* 0.5 (sin-osc:kr 0.5)))]) 33 | dly (/ 1 freq) 34 | src (pluck src trg dly dly 0.9 0.4) 35 | src (rlpf src 1000) 36 | t 4 37 | mix-rate 0.8 38 | room-rate 0.5 39 | f-env (env-gen (perc t t) trg 1 0 2) 40 | signal (rlpf (* 0.3 src) 41 | (+ (* 0.6 freq) (* f-env 2 freq)) 0.2) 42 | amt 0.3 43 | k (/ (* 2 amt) (- 1 amt)) 44 | distort (/ (* (+ 1 k) signal) (+ 1 (* k (abs signal)))) 45 | 46 | gate (pulse (* 2 (+ 1 (sin-osc:kr 0.5)))) 47 | compressor (compander distort gate 0.01 1 0.5 0.01 0.01) 48 | 49 | dampener (+ 1 (* 0.5 (sin-osc:kr 0.5))) 50 | reverb (free-verb compressor mix-rate room-rate dampener) 51 | 52 | src (mix [(* 0.5 (rlpf (saw (* 1.0 freq)) 500)) src]) 53 | 54 | src (comb-n src 0.4 0.3 0.5) 55 | 56 | ] 57 | (out 0 (pan2 (* amp src))))) 58 | 59 | (kill tonal) 60 | (tonal :amp 0.6 :notes-buf tonal-notes-b :reverb-buf tonal-reverb-b)) 61 | 62 | 63 | (stop) 64 | 65 | (do (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 128 [bass-notes-buf hats-buf kick-seq-buf white-seq-buf effects-seq-buf effects2-seq-buf bass-notes-buf effects3-seq-buf])) 66 | 67 | (pattern! effects-seq-buf [0]) 68 | 69 | (def bass-kicks (doall (map #(seqer [:head drum-effects-g] :beat-num %1 70 | :pattern effects-seq-buf :amp 0.1 :num-steps 8 :buf virus-kick-s) (range 0 16)))) 71 | 72 | (def kicks (doall (map #(seqer [:head drum-effects-g] :beat-num %1 73 | :pattern effects2-seq-buf :amp 0.5 :num-steps 8 :buf (buffer-mix-to-mono kick-s)) (range 0 16)))) 74 | 75 | (def bell (doall (map #(seqer [:head drum-effects-g] :beat-num %1 76 | :pattern effects3-seq-buf :amp 0.009 :num-steps 8 :buf (buffer-mix-to-mono bell-s)) (range 0 16)))) 77 | 78 | (pattern! effects-seq-buf [0 1 0 0 0 0 1 0]) 79 | (pattern! effects2-seq-buf [1 0 0 0 1 0 0 0]) 80 | (pattern! effects3-seq-buf [1 0 0 0 1 0 0 0]) 81 | 82 | 83 | (kill drum-effects-g) 84 | 85 | (stop) 86 | 87 | (do 88 | (defsynth tonal [amp 1 notes-buf 0 89 | beat-trg-bus (:beat time/beat-1th) 90 | beat-bus (:count time/beat-1th)] 91 | (let [cnt (in:kr beat-bus) 92 | trg (in:kr beat-trg-bus) 93 | note (buf-rd:kr 1 notes-buf cnt) 94 | 95 | freq (midicps note) 96 | src (sum [(sin-osc freq) 97 | (saw freq) 98 | (blip freq (* 0.5 (sin-osc:kr 0.5)))]) 99 | dly (/ 1 freq) 100 | src (pluck src trg dly dly 0.9 0.4) 101 | src (rlpf src 1000) 102 | ;; src (free-verb src 0.7 1 0) 103 | src (g-verb src 200 8)] 104 | (out 0 (pan2 (* amp src))))) 105 | 106 | (kill tonal) 107 | (tonal :amp 0.2 :notes-buf tonal-notes-b :reverb-buf tonal-reverb-b)) 108 | -------------------------------------------------------------------------------- /resources/shaders/manhattan.glsl: -------------------------------------------------------------------------------- 1 | #define MaxSteps 15 2 | #define MinimumDistance 0.0009 3 | #define normalDistance 0.0002 4 | 5 | #define Iterations 5 6 | #define PI 3.141592 7 | #define Scale 3.0 8 | #define FieldOfView 1.0 9 | #define Jitter 0.05 10 | #define FudgeFactor 0.7 11 | #define NonLinearPerspective 2.0 12 | #define DebugNonlinearPerspective false 13 | 14 | #define Ambient 0.32184 15 | #define Diffuse 0.5 16 | #define LightDir vec3(1.0) 17 | #define LightColor vec3(1.0,1.0,0.858824) 18 | #define LightDir2 vec3(1.0,-1.0,1.0) 19 | #define LightColor2 vec3(0.0,0.333333,1.0) 20 | #define Offset vec3(0.92858,0.92858,0.32858) 21 | 22 | vec2 rotate(vec2 v, float a) { 23 | return vec2(cos(a)*v.x + sin(a)*v.y, -sin(a)*v.x + cos(a)*v.y); 24 | } 25 | 26 | // Two light sources. No specular 27 | vec3 getLight(in vec3 color, in vec3 normal, in vec3 dir) { 28 | vec3 lightDir = normalize(LightDir); 29 | float diffuse = max(0.0,dot(-normal, lightDir)); // Lambertian 30 | 31 | vec3 lightDir2 = normalize(LightDir2); 32 | float diffuse2 = max(0.0,dot(-normal, lightDir2)); // Lambertian 33 | 34 | return 35 | (diffuse*Diffuse)*(LightColor*color) + 36 | (diffuse2*Diffuse)*(LightColor2*color); 37 | } 38 | 39 | 40 | // DE: Infinitely tiled Menger IFS. 41 | // 42 | // For more info on KIFS, see: 43 | // http://www.fractalforums.com/3d-fractal-generation/kaleidoscopic-%28escape-time-ifs%29/ 44 | float DE(in vec3 z) 45 | { 46 | // enable this to debug the non-linear perspective 47 | if (DebugNonlinearPerspective) { 48 | z = fract(z); 49 | float d=length(z.xy-vec2(0.5)); 50 | d = min(d, length(z.xz-vec2(0.5))); 51 | d = min(d, length(z.yz-vec2(0.5))); 52 | return d-0.01; 53 | } 54 | // Folding 'tiling' of 3D space; 55 | z = abs(1.0-mod(z,2.0)); 56 | 57 | float d = 1000.0; 58 | for (int n = 0; n < Iterations; n++) { 59 | z.xy = rotate(z.xy,4.0+2.0*cos( iGlobalTime/8.0)); 60 | z = abs(z); 61 | if (z.xtc) //if time is greater than time of collision 51 | { 52 | t-=tc; //process the collision 53 | pos = pos + vel*tc + acc*tc*tc*.5; 54 | vel = vel + acc*tc; 55 | vel.y*=-.5; //make it bounce 56 | vel.x=vel.x*.8+sin(pos.x*4.0)*length(vel)*.5; 57 | } 58 | else break; //it wont collide, yay! 59 | } 60 | 61 | pos = pos + vel*t + acc*t*t*.5; // x = v*t + .5*a*t^2 62 | 63 | float ar = iResolution.x/iResolution.y; 64 | float hwall = 8.0*ar; 65 | 66 | for (int i=0; i+hwall) pos.x = 2.0*hwall-pos.x; 69 | else if (pos.x<-hwall) pos.x = -2.0*hwall-pos.x; 70 | else break; 71 | } 72 | return pos; 73 | } 74 | 75 | float hash(float x) 76 | { 77 | return fract(sin(x*.0127863)*17143.321); //decent hash for noise generation 78 | } 79 | 80 | float hash(vec2 x) 81 | { 82 | return fract(cos(dot(x.xy,vec2(2.31,53.21))*124.123)*412.0); 83 | } 84 | 85 | vec3 cc(vec3 color, float factor,float factor2) // color modifier 86 | { 87 | float w = color.x+color.y+color.z; 88 | return mix(color,vec3(w)*factor,w*factor2); 89 | } 90 | 91 | void main(void) 92 | { 93 | vec2 uv = gl_FragCoord.xy / iResolution.xy -.5; 94 | uv.x *= iResolution.x/iResolution.y; 95 | 96 | uv*=16.0; 97 | 98 | float acc = .0; 99 | 100 | float t = iGlobalTime + time_offset; 101 | 102 | //new simulation after every time_per_simulation seconds 103 | float mt = mod(t,time_per_simulation); 104 | float seed = t-mt; //the seed to generate new variables 105 | 106 | for (int sample = 0; sample sequencer :beat-bus deref :count) 97 | (-> sequencer :beat-bus deref :beat) 98 | (:out-bus sequencer))))) 99 | 100 | (defn sequencer-pause 101 | [s] 102 | (assert (sequencer? s)) 103 | (node-pause (:group s))) 104 | 105 | (defn sequencer-play 106 | [s] 107 | (assert (sequencer? s)) 108 | (node-start (:group s))) 109 | 110 | (defn swap-beat-bus! [sequencer beat-bus] 111 | (assert (sequencer? sequencer)) 112 | (reset! (:beat-bus sequencer) beat-bus)) 113 | 114 | (defn sequencer-write! 115 | [sequencer idx pattern] 116 | (assert (sequencer? sequencer)) 117 | (let [buf (:pattern-buf (nth (:patterns sequencer) idx))] 118 | (buffer-write! buf pattern))) 119 | 120 | (defn sequencer-kill 121 | [s] 122 | (assert (sequencer? s)) 123 | (group-free (:group s)) 124 | (doseq [mixer (:mixers s)] 125 | (mixers/kill-mixer mixer))) 126 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/leap.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.leap 2 | (:use [overtone.live]) 3 | (:import (com.leapmotion.leap Controller 4 | Listener 5 | Frame 6 | Hand Finger Tool Pointable 7 | Vector 8 | HandList FingerList))) 9 | 10 | (set! *warn-on-reflection* true) 11 | 12 | (defrecord LeapPoint [x y z magnitude magsqrd pitch roll yaw vec]) 13 | 14 | (defonce ^Controller controller (Controller.)) 15 | (defonce controller-listeners (agent {})) 16 | (defonce __SET-BG-POLICY__ 17 | (.setPolicyFlags controller com.leapmotion.leap.Controller$PolicyFlag/POLICY_BACKGROUND_FRAMES)) 18 | 19 | (defn ^Frame current-frame 20 | "Returns the most recent frame from the current controller. When 21 | passed the argument prev-idx retrieves the appropriave frame from 22 | history (i.e. (frame 1) will return the first frame from history)" 23 | ([] (.frame controller)) 24 | ([prev-idx] (.frame controller prev-idx))) 25 | 26 | (defn ^Frame frame 27 | ([^Controller c] (.frame c)) 28 | ;; ([^Controller c] (.frame c)) 29 | ) 30 | 31 | (defn ^HandList hands 32 | "Returns a list of hands within the specified frame" 33 | [^Frame f] 34 | (.hands f)) 35 | 36 | (defn ^Hand frontmost-hand 37 | "Returns the frontmost hand within the specified frame" 38 | [^Frame f] 39 | (.frontmost (hands f))) 40 | 41 | (defn ^Hand leftmost-hand 42 | "Returns the leftmost hand within the specified frame" 43 | [^Frame f] 44 | (.leftmost (hands f))) 45 | 46 | (defn ^Hand rightmost-hand 47 | "Returns the rightmost hand within the specified frame" 48 | [^Frame f] 49 | (.rightmost (hands f))) 50 | 51 | (defn ^FingerList fingers [^Hand h] 52 | (.fingers h)) 53 | 54 | (defn ^Vector palm-position [^Hand h] 55 | (.palmPosition h)) 56 | 57 | (defn ^LeapPoint mk-leap-point [^Vector v] 58 | (LeapPoint. (.getX v) 59 | (.getY v) 60 | (.getZ v) 61 | (.magnitude v) 62 | (.magnitudeSquared v) 63 | (.pitch v) 64 | (.roll v) 65 | (.yaw v) 66 | v)) 67 | 68 | (defn mk-listener [handlers] 69 | (let [blank-fn (fn [c] nil)] 70 | (proxy [Listener] [] 71 | (onInit [c] 72 | ((:on-init handlers blank-fn) c)) 73 | (onConnect [c] 74 | ((:on-connect handlers blank-fn) c)) 75 | (onDisconnect [c] 76 | ((:on-disconnect handlers blank-fn) c)) 77 | (onExit [c] 78 | ((:on-exit handlers blank-fn) c)) 79 | (onFrame [c] 80 | ((:on-frame handlers blank-fn) c))))) 81 | 82 | (defn- rm-listener* 83 | [listeners k p] 84 | (if-let [l (get listeners k)] 85 | (do (.removeListener controller l) 86 | (deliver p true) 87 | (dissoc listeners k)) 88 | (do (deliver p false) 89 | listeners))) 90 | 91 | (defn add-listener 92 | "Add listener to controller with specified k. Replaces any previous 93 | listener registered with the same k 94 | 95 | Returns false if removal failed" 96 | [l k] 97 | (let [block (promise)] 98 | (send controller-listeners 99 | (fn [listeners] 100 | (let [listeners (rm-listener* listeners k (promise)) 101 | listeners (assoc listeners k l)] 102 | (.addListener controller l) 103 | (deliver block true) 104 | listeners))) 105 | (deref block 1000 false))) 106 | 107 | (defn rm-listener 108 | "Remove listener with the specified key. Returns false if removal 109 | failed." 110 | [k] 111 | (let [res (promise)] 112 | (send controller-listeners rm-listener* k res) 113 | @res)) 114 | 115 | (defn on-frame 116 | "Executes fn f for each frame. f should therefore be a function with 117 | one argument which will be the new frame. k is a key used to store 118 | the fn and to remove it via rm-listener." 119 | [f k] 120 | (add-listener (mk-listener {:on-frame (fn [^Controller c] 121 | (let [^Frame fr (.frame c)] 122 | (f fr)))}) 123 | k)) 124 | 125 | 126 | (comment 127 | 128 | (defsynth dubstep [bpm 120 wobble 1 note 50 snare-vol 1 kick-vol 1 v 1] 129 | (let [trig (impulse:kr (/ bpm 120)) 130 | freq (midicps note) 131 | swr (demand trig 0 (dseq [wobble] INF)) 132 | sweep (lin-exp (lf-tri swr) -1 1 40 3000) 133 | wob (apply + (saw (* freq [0.99 1.01]))) 134 | wob (lpf wob sweep) 135 | wob (* 0.8 (normalizer wob)) 136 | wob (+ wob (bpf wob 1500 2)) 137 | wob (+ wob (* 0.2 (g-verb wob 9 0.7 0.7))) 138 | 139 | kickenv (decay (t2a (demand (impulse:kr (/ bpm 30)) 0 (dseq [1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0] INF))) 0.7) 140 | kick (* (* kickenv 7) (sin-osc (+ 40 (* kickenv kickenv kickenv 200)))) 141 | kick (clip2 kick 1) 142 | 143 | snare (* 3 (pink-noise) (apply + (* (decay (impulse (/ bpm 240) 0.5) [0.4 2]) [1 0.05]))) 144 | snare (+ snare (bpf (* 4 snare) 2000)) 145 | snare (clip2 snare 1)] 146 | 147 | (out 0 (* v (clip2 (+ wob (* kick-vol kick) (* snare-vol snare)) 1))))) 148 | 149 | (kill ff) 150 | (def ff (dubstep)) 151 | 152 | (on-frame (fn [f] 153 | (let [h (frontmost-hand f) 154 | pv (palm-position h)] 155 | (when (.isValid h) 156 | (let [y (.getY pv) 157 | y (/ y 50)] 158 | (println :y y) 159 | (ctl ff :wooble y))))) ::leap) 160 | 161 | ) 162 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/monome_sequencer.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.monome-sequencer 2 | (:use [overtone.core] 3 | [overtone.helpers.lib :only [uuid]]) 4 | (:require [monome.fonome :as fon] 5 | [mud.timing :as time] 6 | [cassiopeia.engine.sequencer :as seq])) 7 | 8 | (defonce m-sequencers (atom {})) 9 | 10 | (defn- get-row [grid y range-x] 11 | (let [row (for [x (range range-x)] 12 | (get grid [x y] false))] 13 | (map #(if % 1 0) row))) 14 | 15 | (defn sequencer-write-row! [sequencer y range-x grid] 16 | (let [row (get-row grid y range-x)] 17 | (when-not (>= y (:num-samples sequencer)) 18 | (seq/sequencer-write! sequencer y row)))) 19 | 20 | (defn sequencer-write-grid! [sequencer range-x range-y grid] 21 | (doseq [y (range range-x)] 22 | (sequencer-write-row! sequencer y range-x grid))) 23 | 24 | (defn monome-sequencer? 25 | [o] 26 | (isa? (type o) ::monome-sequencer)) 27 | 28 | (defn- update-monome-leds 29 | [tgt-fonome range-x beat] 30 | (let [beat-track-y (dec (:height tgt-fonome))] 31 | (fon/led-on tgt-fonome (mod (dec beat) range-x) beat-track-y) 32 | (fon/led-off tgt-fonome (mod beat range-x) beat-track-y))) 33 | 34 | (defn mk-ticker 35 | ([tgt-fonome handle] (mk-ticker tgt-fonome handle (atom time/main-beat) (uuid) (:width tgt-fonome))) 36 | ([tgt-fonome handle beat-bus-a beat-key range-x] 37 | (let [t-id (:trig-id @beat-bus-a) 38 | key3 (uuid)] 39 | (on-trigger t-id 40 | (fn [beat] 41 | (let [beat-track-y (dec (:height tgt-fonome)) 42 | total-cells (* (:height tgt-fonome) range-x) 43 | x-pos (mod beat range-x) 44 | y-pos (/ (mod beat 96) range-x)] 45 | (when (and (= 0.0 x-pos) (= 0.0 y-pos)) 46 | (doseq [x (range total-cells)] 47 | (fon/led-off tgt-fonome (mod x range-x) (/ x range-x)))) 48 | (fon/led-on tgt-fonome x-pos y-pos))) 49 | key3) 50 | 51 | (with-meta 52 | {:trg-key key3 53 | :beat-key beat-key 54 | :fonome tgt-fonome 55 | :handle handle 56 | :status (atom :running)} 57 | {:type ::monome-ticker})))) 58 | 59 | (defn mk-monome-sequencer 60 | ([nk-group handle samples tgt-fonome] 61 | (mk-monome-sequencer nk-group handle samples tgt-fonome 0)) 62 | ([nk-group handle samples tgt-fonome out-bus] 63 | (mk-monome-sequencer nk-group handle samples tgt-fonome 0 (foundation-default-group))) 64 | ([nk-group handle samples tgt-fonome out-bus tgt-g] 65 | (mk-monome-sequencer nk-group handle samples tgt-fonome out-bus tgt-g true)) 66 | ([nk-group handle samples tgt-fonome out-bus tgt-g with-mixers?] 67 | (mk-monome-sequencer nk-group handle samples tgt-fonome out-bus tgt-g with-mixers? time/main-beat)) 68 | ([nk-group handle samples tgt-fonome out-bus tgt-g with-mixers? beat-bus] 69 | (when-not tgt-fonome 70 | (throw (IllegalArgumentException. "Please pass a valid fonome to mk-monome-sequencer"))) 71 | 72 | (let [range-x (:width tgt-fonome) 73 | range-y (:height tgt-fonome) 74 | t-id (:trig-id beat-bus) 75 | beat-bus-a (atom beat-bus) 76 | sequencer (seq/mk-sequencer nk-group 77 | handle 78 | (take (dec range-y) samples) 79 | range-x 80 | tgt-g 81 | beat-bus-a 82 | out-bus) 83 | seq-atom (atom sequencer) 84 | key1 (uuid) 85 | key2 (uuid) 86 | key3 (uuid) 87 | m-sequencer (with-meta 88 | {:sequencer seq-atom 89 | :led-change-key key1 90 | :press-key key2 91 | :beat-key key3 92 | :fonome tgt-fonome 93 | :handle handle 94 | :status (atom :running) 95 | :nk-group nk-group} 96 | {:type ::monome-sequencer})] 97 | 98 | (swap! m-sequencers (fn [ms] 99 | (when (contains? ms handle) 100 | (seq/sequencer-kill sequencer) 101 | (throw (IllegalArgumentException. 102 | (str "A monome-sequencer with handle " 103 | handle 104 | " already exists.")))) 105 | (assoc ms handle m-sequencer))) 106 | 107 | (sequencer-write-grid! sequencer range-x range-y (fon/led-state tgt-fonome)) 108 | 109 | (on-event [:fonome :led-change (:id tgt-fonome)] 110 | (fn [{:keys [new-leds y]}] 111 | (if y 112 | (sequencer-write-row! @seq-atom y range-x new-leds) 113 | (sequencer-write-grid! @seq-atom range-x range-y new-leds))) 114 | key1) 115 | 116 | (on-event [:fonome :press (:id tgt-fonome)] 117 | (fn [{:keys [x y fonome]}] 118 | (fon/toggle-led fonome x y)) 119 | key2) 120 | 121 | (mk-ticker tgt-fonome ::ticker128 beat-bus-a key3 range-x) 122 | 123 | (oneshot-event :reset (fn [_] (remove-event-handler key1) (remove-event-handler key2)) (uuid)) 124 | 125 | m-sequencer))) 126 | 127 | (defn running? [seq] 128 | (= :running @(:status seq))) 129 | 130 | (defn stop-sequencer [seq] 131 | (assert (monome-sequencer? seq)) 132 | (when (running? seq) 133 | (reset! (:status seq) :stopped) 134 | (swap! m-sequencers dissoc (:handle seq)) 135 | (seq/sequencer-kill @(:sequencer seq)) 136 | (remove-event-handler (:led-change-key seq)) 137 | (remove-event-handler (:press-key seq)) 138 | (remove-event-handler (:beat-key seq)))) 139 | 140 | (defn swap-samples! [m-seq samples] 141 | (assert (monome-sequencer? m-seq)) 142 | (seq/swap-samples! @(:sequencer m-seq) samples)) 143 | 144 | (defn swap-beat-bus! [m-seq beat-bus] 145 | (assert (monome-sequencer? m-seq)) 146 | (seq/swap-beat-bus! @(:sequencer m-seq) beat-bus)) 147 | 148 | (defn sequencer-write! [{fonome :fonome sequencer :sequencer} y pattern] 149 | (let [stretched-pattern (take (:width fonome) (cycle pattern))] 150 | (fon/set-led-row-state! fonome y stretched-pattern))) 151 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/flatiron.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.flatiron 2 | " .-. . .-. .-. .-. .-. .-. . . 3 | |- | |-| | | |( | | |\\| 4 | ' `-' ` ' ' `-' ' ' `-' ' ``"(: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])) 5 | (ctl-global-clock 0.2) 6 | 7 | (nyc) 8 | 9 | 10 | (defn nyc 11 | "New york city" 12 | [] 13 | (do (def master-vol 3.0) (volume master-vol) (fl/v master-vol)) 14 | (ctl-global-clock 0.0) 15 | (defbufs 256 [df-b s-note-b]) 16 | 17 | (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))) 18 | (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]) 19 | (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]) 20 | (pattern! bass-notes-buf 21 | (repeat 8 (degrees [1] :minor :F1)) 22 | (repeat 2 (repeat 8 (degrees [1] :minor :F1))) 23 | (repeat 2 (repeat 8 (degrees [3] :minor :F1))) 24 | (repeat 2 (repeat 8 (degrees [3] :minor :F1))) 25 | [(degrees [1 1 1 1 5 4 3 1] :minor :F1)]) 26 | 27 | (def beats (buffer->tap-lite kick-seq-buf (:count time/beat-1th) :measure 8)) 28 | (defonce stars-weight (atom 0.0)) 29 | (defonce circle-count (atom 4.0)) 30 | (defonce color (atom 0.1)) 31 | (defonce circle-slice (atom 8.0)) 32 | (defonce circle-edge (atom 0.1)) 33 | (defonce circular-weight (atom 0.0)) 34 | (defonce population-weight (atom 0.0)) 35 | (defonce cells-weight (atom 0.0)) 36 | (defonce nyc-weight (atom 0.0)) 37 | (defonce invert-color (atom 1.0)) 38 | (defonce cell-dance-weight (atom 1.0)) 39 | (defonce splatter (atom 1.0)) 40 | (defonce circle-intensity (atom 0.0025)) 41 | (defonce buffer-change-event-nomad (atom 0.0)) 42 | (defonce break-parens-in-case-of-emergency (atom 0.0)) 43 | (def ibeat (atom {:synth beats :tap "beat"})) 44 | (def beat-tap (get-in (:synth @ibeat) [:taps (:tap @ibeat)])) 45 | (def cell-dance-color (atom 0.01)) 46 | (add-watch beat-tap :cell-color 47 | (fn [_ _ old new] 48 | (when (and (= old 0.0) (= 1.0 new)) 49 | (reset! cell-dance-color (mod (+ @cell-dance-color 1.0) 100))))) 50 | 51 | (defonce converge-zoom-rate (atom 0.2)) 52 | (reset! converge-zoom-rate 0.2) 53 | (reset! splatter 1.0) 54 | (add-watch beat-tap :converge-circles 55 | (fn [_ _ old new] 56 | (when (>= @cell-dance-weight 8.0) 57 | (reset! splatter (max 0 (- @splatter @converge-zoom-rate)))) 58 | (reset! converge-zoom-rate (max 0.0005 (* @converge-zoom-rate 0.5))) 59 | (when (<= @splatter 0.0) 60 | (remove-watch beat-tap :converge-circles) 61 | ))) 62 | 63 | (reset! circle-count 4.0) 64 | (reset! color 0.1) 65 | (reset! circle-slice 8.0) 66 | (reset! circle-edge 0.1) 67 | (reset! circular-weight 0.0) 68 | (reset! population-weight 0.0) 69 | (reset! cells-weight 0.0) 70 | (reset! nyc-weight 0.0) 71 | (reset! invert-color 1.0) 72 | (reset! cell-dance-weight 1.0) 73 | (reset! splatter 1.0) 74 | (reset! circle-intensity 0.0025) 75 | (reset! buffer-change-event-nomad 0.0) 76 | (reset! cell-dance-color 0.01) 77 | (reset! break-parens-in-case-of-emergency 0.0) 78 | 79 | (def nomad-chord-g nil) 80 | (add-watch 81 | buffer-change-event-nomad 82 | :buffer-change-event-nomad 83 | (fn [& _] 84 | (when nomad-chord-g 85 | (let [n (int (buffer-get (second (:bufs nomad-chord-g)) 0))] 86 | (case n 87 | 29 (do (overtime! circle-edge 0.0) (overtime! nyc-weight 0.0 0.005) (reset! invert-color 1.0)) 88 | 32 (do (overtime! circle-edge -0.3) (overtime! nyc-weight 0.004) (reset! invert-color 2.0)) 89 | 34 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.01)) 90 | 36 (do (overtime! circle-edge -0.55) (overtime! nyc-weight 0.0119)) 91 | 92 | 41 (do (overtime! circle-edge 0.0) (overtime! nyc-weight 0.0 0.005) (reset! invert-color 1.0)) 93 | 44 (do (overtime! circle-edge -0.3) (overtime! nyc-weight 0.004) (reset! invert-color 2.0)) 94 | 46 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.01)) 95 | 48 (do (overtime! circle-edge -0.5) (overtime! nyc-weight 0.012)) 96 | 97 | 53 (do (overtime! circle-edge -0.5) (reset! nyc-weight 0.015)) 98 | 99 | (do (reset! circle-edge 0.0) (reset! nyc-weight 0.0))))))) 100 | 101 | ;;(remove-watch buffer-change-event-nomad :buffer-change-event-nomad) 102 | 103 | (reset! cell-dance-weight 1.0) 104 | (reset! splatter 1.0) 105 | 106 | (fl/v 3.0) 107 | (ctl-global-clock 0.2) 108 | 109 | ;;(kill beats) 110 | (start-graphics "resources/shaders/nyc.glsl" 111 | :textures [:overtone-audio :previous-frame 112 | "resources/textures/tex16.png"] 113 | :user-data {"iGlobalBeatCount" (atom {:synth beats :tap "global-beat-count"}) 114 | "iBeat" ibeat 115 | 116 | "iStars" stars-weight 117 | "iColor" color 118 | "iCircleCount" circle-count 119 | "iHalfPi" circle-slice 120 | "iDeformCircles" circle-edge 121 | "iCircularWeight" circular-weight 122 | "iPopulationWeight" population-weight 123 | "iBouncingWeight" cells-weight 124 | "iNycWeight" nyc-weight 125 | "iInvertColor" invert-color 126 | "iCircleDanceWeight" cell-dance-weight 127 | "iCircleDanceColor" cell-dance-color 128 | "iDeath" fl/vol 129 | "iSplatter" splatter 130 | "iCircleDistort" circle-intensity 131 | "iSmashTheParens" break-parens-in-case-of-emergency 132 | }) 133 | 134 | (comment 135 | (stop-graphics "resources/shaders/nyc.glsl") 136 | (stop-everything!) 137 | (stop)) 138 | ) 139 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/yarra.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.yarra 2 | (:use [overtone.live][mud.core]) 3 | (:require [mud.timing :as time])) 4 | 5 | (ctl-global-clock 1.0) 6 | 7 | (defsynth dark-ambience 8 | [note 52 9 | note_slide 0 10 | note_slide_shape 5 11 | note_slide_curve 0 12 | 13 | beat-bus (:count time/beat-8th) beat-trg-bus (:beat time/beat-8th) 14 | note-buf 0 15 | 16 | amp 1 17 | amp_slide 0 18 | amp_slide_shape 5 19 | amp_slide_curve 0 20 | 21 | pan 0 22 | pan_slide 0 23 | pan_slide_shape 5 24 | pan_slide_curve 0 25 | 26 | attack 0 27 | decay 0 28 | sustain 0 29 | release 4 30 | attack_level 1 31 | sustain_level 1 32 | env_curve 2 33 | 34 | cutoff 110 35 | cutoff_slide 0 36 | cutoff_slide_shape 5 37 | cutoff_slide_curve 0 38 | res 0.3 39 | res_slide 0 40 | res_slide_shape 5 41 | res_slide_curve 0 42 | 43 | detune1 12 44 | detune1_slide 0 45 | detune1_slide_shape 5 46 | detune1_slide_curve 0 47 | 48 | detune2 24 49 | detune2_slide 0 50 | detune2_slide_shape 5 51 | detune2_slide_curve 0 52 | 53 | noise 0 54 | ring 0.2 55 | room 70 56 | reverb_time 100 57 | out_bus 0] 58 | (let [cnt (in:kr beat-bus) 59 | beat-trg (in:kr beat-trg-bus) 60 | note (buf-rd:kr 1 note-buf cnt) 61 | gate-trg (and (> note 0) beat-trg) 62 | 63 | note (varlag note note_slide note_slide_curve note_slide_shape) 64 | amp (varlag amp amp_slide amp_slide_curve amp_slide_shape) 65 | amp-fudge 1 66 | pan (varlag pan pan_slide pan_slide_curve pan_slide_shape) 67 | cutoff (varlag cutoff cutoff_slide cutoff_slide_curve cutoff_slide_shape) 68 | res (varlag res res_slide res_slide_curve res_slide_shape) 69 | detune1 (varlag detune1 detune1_slide detune1_slide_curve detune1_slide_shape) 70 | detune2 (varlag detune2 detune2_slide detune2_slide_curve detune2_slide_shape) 71 | 72 | freq (midicps note) 73 | freq2 (midicps (+ note detune1)) 74 | freq3 (midicps (+ note detune2)) 75 | cutoff-freq (midicps cutoff) 76 | room (max 0.1 (min 300 (abs room))) ;; stops synth killing scsynth 77 | env (env-gen:kr (env-adsr-ng attack decay sustain release attack_level sustain_level env_curve) :gate gate-trg) 78 | 79 | pn (* 0.005 (pink-noise)) 80 | bn (* 0.002 (brown-noise)) 81 | wn (* 0.002 (white-noise)) 82 | cl (* 0.001 (clip-noise)) 83 | gn (* 0.001 (gray-noise)) 84 | src-noise (select noise [pn bn wn cl gn]) 85 | 86 | src1 (ringz src-noise freq ring) 87 | src2 (ringz src-noise freq2 ring) 88 | src3 (ringz src-noise freq3 ring) 89 | src (g-verb (* env (mix [src1 src1 src2 src3])) room reverb_time) 90 | src (tanh src) 91 | [src-l src-r] (rlpf (* amp-fudge env src) cutoff-freq res) 92 | src (balance2 src-l src-r pan amp)] 93 | (out out_bus src))) 94 | 95 | (defsynth dark-sea-horn 96 | "Dark, rough and sharp sea horn. 97 | Note: we are purposely not using recusion using busses. Just does not have the same feel." 98 | [out_bus 0 99 | 100 | note 52 101 | note_slide 0 102 | note_slide_shape 5 103 | note_slide_curve 0 104 | 105 | pan 0 106 | pan_slide 0 107 | pan_slide_shape 5 108 | pan_slide_curve 0 109 | 110 | beat-bus (:count time/beat-8th) beat-trg-bus (:beat time/beat-4th) 111 | 112 | note-buf 0 113 | 114 | amp 1 115 | amp_slide 0 116 | amp_slide_shape 5 117 | amp_slide_curve 0 118 | 119 | attack 1 120 | decay 0 121 | sustain 0 122 | release 4.0 123 | attack_level 1 124 | sustain_level 1 125 | env_curve 2] 126 | (let [cnt (in:kr beat-bus) 127 | beat-trg (in:kr beat-trg-bus) 128 | note (buf-rd:kr 1 note-buf cnt) 129 | gate-trg (and (> note 0) beat-trg) 130 | 131 | note (varlag note note_slide note_slide_curve note_slide_shape) 132 | amp (varlag amp amp_slide amp_slide_curve amp_slide_shape) 133 | pan (varlag pan pan_slide pan_slide_curve pan_slide_shape) 134 | freq (midicps note) 135 | 136 | a (tanh (* 6 (lf-noise1:ar 3) (sin-osc:ar freq (* (lf-noise1:ar 0.1) 3)))) 137 | 138 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 139 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 140 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 141 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 142 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 143 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 144 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 145 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 146 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 147 | a (tanh a) 148 | 149 | a (tanh (* 6 (lf-noise1:ar 3) (sin-osc:ar freq (* a (lf-noise1:ar 0.1) 3)))) 150 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 151 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 152 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 153 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 154 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 155 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 156 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 157 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 158 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 159 | a (tanh a) 160 | 161 | a (tanh (* 6 (lf-noise1:ar 3) (sin-osc:ar freq (* a (lf-noise1:ar 0.1) 3)))) 162 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 163 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 164 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 165 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 166 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 167 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 168 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 169 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 170 | a (allpass-l:ar a 0.3 [(+ (ranged-rand 0 0.2) 0.1) (+ (ranged-rand 0 0.2) 0.1)] 5) 171 | a (tanh a) 172 | 173 | env (env-gen:kr (env-adsr-ng attack decay sustain release attack_level sustain_level env_curve) :gate gate-trg) 174 | snd (* amp a)] (out out_bus (* env (pan2 snd pan))))) 175 | 176 | (defonce d-notes-b (buffer 256)) 177 | (def river-flowing (dark-sea-horn :note-buf d-notes-b)) 178 | (def nz [33, 35, 37, 40, 42, 45, 47, 49, 52, 54, 57]) 179 | (pattern! d-notes-b (shuffle nz)) 180 | 181 | (ctl river-flowing :release 4.0 :attack 0.5) 182 | 183 | 184 | (pattern! d-notes-b (degrees-seq [:A2 4 4 _ 6 _ 5])) 185 | 186 | (def trigger-g101518 187 | (on-beat-trigger 1 #(do 188 | (ctl river-flowing :release 6.0 :attack 3.0) 189 | ))) 190 | 191 | (remove-beat-trigger trigger-g101518) 192 | (remove-all-beat-triggers) 193 | 194 | 195 | (def trigger-g101517 196 | (on-beat-trigger 32 #(do 197 | (ctl river-flowing :release 4.0 :attack 2.0) 198 | ))) 199 | 200 | (remove-beat-trigger trigger-g101517) 201 | (remove-all-beat-triggers) 202 | 203 | 204 | (def dark-b (buffer 256)) 205 | (def dark (dark-ambience :note-buf dark-b :amp 2)) 206 | 207 | (pattern! dark-b (degrees-seq [:A3 1 0 0 0 208 | :A2 0 0 0 4 209 | :A4 1 :A3 1 0 :A2 4 210 | :A2 0 0 0 4 211 | :A3 5 0 0 0 212 | :A3 0 0 0 4])) 213 | 214 | (stop) 215 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/eta.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.eta "███████╗████████╗ █████╗ 2 | ██╔════╝╚══██╔══╝██╔══██╗ 3 | █████╗ ██║ ███████║ 4 | ██╔══╝ ██║ ██╔══██║ 5 | ███████╗ ██║ ██║ ██║ 6 | ╚══════╝ ╚═╝ ╚═╝ ╚═╝" 7 | (:require [mud.timing :as time] [overtone.studio.fx :as fx] [cassiopeia.engine.mixers :as mix] [overtone.inst.synth :as s] [shadertone.tone :as t] [cassiopeia.engine.buffers :as b]) (:use [overtone.live] [mud.core] [cassiopeia.engine.scheduled-sampler] [cassiopeia.samples] [cassiopeia.engine.samples] [cassiopeia.view-screen] [cassiopeia.waves.synths] [cassiopeia.waves.soprano])) 8 | (do (ctl time/root-s :rate 4) 9 | ;; (ctl (foundation-output-group) :master-volume 1) 10 | (defonce voice-g (group "main voice")) (defonce backing-voice-g (group "backing voices")) (defonce bass-g (group "bass voice")) (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 96 [bass-notes-buf hats-buf kick-seq-buf white-seq-buf effects-seq-buf effects2-seq-buf bass-notes-buf stella-wind-note-buf nebula-note-buf supernova-dur-buf supernova-note-buf helium-note-buf hydrogen-note-buf supernova-dur-buf helium-dur-buf hydrogen-dur-buf metallicity-note-buf])) 11 | 12 | (pattern! kick-seq-buf [1 0 0 0 0 0 0 0]) 13 | (pattern! hats-buf [0 0 0 0 0 0 1 1]) 14 | (pattern! white-seq-buf [0 1 1 0 1 0 1 1]) 15 | 16 | (pattern! hats-buf (repeat 4 [1 0 0 0]) (repeat 4 [1 1 0 0])) 17 | (pattern! kick-seq-buf (repeat 6 [1 0 0 0]) (repeat 2 [1 0 1 1])) 18 | (pattern! white-seq-buf (repeat 3 [1 0 0 0]) [1 1 1 0]) 19 | (pattern! effects-seq-buf (repeat 4 [1 0 0 0])) 20 | (pattern! effects-seq-buf [1 0 0 0] (repeat 3 [0 0 0 0])) 21 | (pattern! effects2-seq-buf [0 0 0 0] [1 1 1 1] [0 0 0 0] [1 0 1 1]) 22 | 23 | (pattern! white-seq-buf (repeat 3 [1 0 0 0]) [1 1 1 1]) 24 | (pattern! hats-buf (repeat 6 (concat (repeat 3 [0 1 0 0]) [1 1 0 0]))) 25 | (pattern! kick-seq-buf (repeat 5 (repeat 4 [1 0 1 1])) (repeat 4 [1 1 1 1])) 26 | (pattern! kick-seq-buf (repeat 5 [1 0 0 0 1 0 0 0 1 0 0 1 1 0 1 1]) 27 | (repeat 1 [1 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1])) 28 | 29 | (def kicker (doseq [i (range 0 96)] (kick2 [:head drums-g] :note-buf bass-notes-buf :seq-buf kick-seq-buf :num-steps 96 :beat-num i :noise 0 :amp 1))) 30 | (ctl drums-g :mod-freq 10.2 :mod-index 0.1 :noise 0) 31 | 32 | (def ghostly-snares (doall (map #(seqer [:head drum-effects-g] :beat-num %1 :pattern effects-seq-buf :amp 0.2 :num-steps 16 :buf (b/buffer-mix-to-mono snare-ghost-s)) (range 0 16)))) 33 | 34 | (def bass-kicks (doall (map #(seqer [:head drum-effects-g] :beat-num %1 :pattern effects2-seq-buf :amp 0.1 :num-steps 8 :buf (b/buffer-mix-to-mono deep-bass-kick-s)) (range 0 8)))) 35 | 36 | (def hats (doall (map #(high-hats [:head drums-g] :amp 0.2 :mix (nth (take 32 (cycle [1.0 1.0])) %1) :room 4 :note-buf bass-notes-buf :seq-buf hats-buf :num-steps 32 :beat-num %1) (range 0 32)))) 37 | (ctl hats :damp 1.9 :mix 0.2 :room 10 :amp 0.2) 38 | 39 | (def white-hats (doall (map #(whitenoise-hat [:head drums-g] :amp 0.2 :seq-buf white-seq-buf :num-steps 16 :beat-num %1) (range 0 16)))) 40 | 41 | (def nebula (growl [:head bass-g] :amp 0.0 :beat-trg-bus (:beat time/beat-16th) :beat-bus (:count time/beat-16th) :note-buf nebula-note-buf)) 42 | 43 | (fadein nebula) 44 | (pattern-at! nebula-note-buf time/main-beat 32 (degrees [] :major :A2)) 45 | 46 | (pattern! hydrogen-dur-buf (repeat 4 [1/8 1/8 1/2 1/2]) (repeat 4 [1/12 1/12 1/12 1/12])) 47 | (pattern! hydrogen-note-buf (degrees [] :major :A2)) 48 | 49 | (def hydrogen (shrill-pong [:head voice-g] :amp 1.2 :note-buf hydrogen-note-buf :duration-bus hydrogen-dur-buf)) 50 | (def helium (shrill-pong [:head voice-g] :amp 1.2 :note-buf helium-note-buf :duration-bus helium-dur-buf)) 51 | (def supernova (shrill-pong [:head voice-g] :amp 0.1 :note-buf supernova-note-buf :duration-bus supernova-dur-buf)) 52 | 53 | (fadeout hydrogen) 54 | (n-overtime! supernova :amp 0.1 1.2 0.01) 55 | 56 | (pattern! helium-dur-buf (repeat 16 [1/9]) (repeat 4 (repeat 16 [1/8]))) 57 | (pattern! supernova-dur-buf (repeat 4 (repeat 2 [1/2 1/4 1/2 1/2 1/4 1/2 1/2 1/12])) (repeat 4 [1/2 1/2 1/2 1/2])) 58 | 59 | (def stellar-wind (pulsar :note-buf stella-wind-note-buf :amp 0.7)) 60 | (def metallicity (fizzy-pulsar [:head backing-voice-g] :amp 0.6 :note-buf metallicity-note-buf :duration-bus supernova-dur-buf)) 61 | 62 | (let [octave 2 63 | [n1 n2 n3 n4] (chord-degree :v (note-at-octave :A octave) :major) 64 | [n11 n12 n13 n14] (chord-degree :i (note-at-octave :A (if (> octave 3) octave (inc octave))) :major)] 65 | (pattern! stella-wind-note-buf 66 | (repeat 4 (repeat 4 [0 0 0 0])) 67 | (repeat 4 [(note-at-octave :F# (+ (if (> octave 3) 0 2) octave)) (note-at-octave :F# (+ (if (> octave 3) 0 2) octave)) 0 0]) 68 | (repeat 2 [(note-at-octave :G# (+ (if (> octave 3) 0 2) octave)) (note-at-octave :G# (+ (if (> octave 3) 0 2) octave)) 0 (note-at-octave :G# (+ (if (> octave 3) 0 2) octave))]) 69 | (repeat 2 [(note-at-octave :G# (+ (if (> octave 3) 0 2) octave)) (note-at-octave :G# (+ (if (> octave 3) 0 2) octave)) 0 0 ])) 70 | (pattern! supernova-note-buf 71 | (repeat 4 [n1 n3 n3 n3]) 72 | [n1 n2 n3 n3] [n3 n3 n1 n1] [n1 n2 n3 n3] [n1 n1 n3 n3] 73 | (repeat 2 [n13 n13 n14 n14]) [n3 n3 n1 n1] [n1 n2 n3 n3] [n1 n1 n13 n13] 74 | [n1 n2 n3 n3] [n3 n3 n1 n1] [n1 n2 n3 n3] [n1 n1 n3 n3] 75 | (repeat 4 [n14 n13 n12 (if (> octave 3) n14 (inc n14))])) 76 | (pattern! helium-note-buf 77 | (degrees [8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 78 | 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 79 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 80 | 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 81 | 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 82 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 83 | :major (note-at-octave :A (cond (= octave 1) octave 84 | true (dec octave))))) 85 | (pattern! metallicity-note-buf 86 | (repeat 3 [n1 n1 n1 n1]) 87 | (repeat 1 [0 0 0 0]) 88 | (repeat 3 [n2 n2 n2 n2]) 89 | (repeat 1 [0 0 0 0]) 90 | (repeat 4 (repeat 4 [0 0 0 0])))) 91 | 92 | (pattern! kick-seq-buf [0]) 93 | (pattern! bass-notes-buf 94 | (repeat 2 (repeat 4 [:B1 :B1 :B1 :B1])) 95 | (repeat 2 (repeat 4 [:E#1 :E#1 :E#1 :E#1])) 96 | (repeat 2 (repeat 4 [:F#1 :F#1 :F#1 :F#1]))) 97 | 98 | (do (reset! color-l 1.0) (reset! color-r 1.0) (reset! expand 1.0) (reset! stars-w 1.0) (reset! yinyan 1.0) (reset! cellular-w 0.0)) 99 | (reset! heart-w 0.0) 100 | (reset! cutout-w 0.0) 101 | (reset! cellular-w 0.0) 102 | 103 | ;;(stop) 104 | 105 | (comment 106 | (def beats (buffer->tap kick-seq-buf (:count time/beat-1th))) 107 | 108 | (reset! heart-w 1.0) 109 | (reset! stars-w 0.0) 110 | 111 | (t/start-fullscreen "resources/shaders/electric.glsl" 112 | :textures [:overtone-audio :previous-frame 113 | "resources/textures/repl-electric-t.png" 114 | "resources/textures/tex16.png"] 115 | :user-data {"iMixRate" color-l "iColorStrength" color-r "iRes" res 116 | "iSpace" space "iExpand" expand "iYinYan" yinyan 117 | "iCircleCount" no-circles "iStarDirection" stars-direction 118 | "iCutoutWeight" cutout-w 119 | "iSpaceLightsWeight" stars-w 120 | "iDistortedWeight" heart-w 121 | "iSpaceyWeight" hyper-w 122 | "iCellularWeight" cellular-w 123 | "iCellGrowth" cellular-growth 124 | "iMeasureCount" (atom {:synth beats :tap "measure-count"}) 125 | "iBeat" (atom {:synth beats :tap "beat"}) 126 | "iBeatCount" (atom {:synth beats :tap "beat-count"})}) 127 | 128 | ;;(t/stop) 129 | (reset! color-l 1.0) 130 | (reset! color-r 1.0) 131 | (reset! expand 1.0) 132 | (reset! yinyan 1.0) 133 | (reset! res 1.0) 134 | (reset! color-l 0.0) 135 | (reset! space 0.5) 136 | 137 | (overtime! stars-direction 10.0 0.001) 138 | 139 | (reset! cutout-w 0.0) 140 | (reset! heart-w 1.0) 141 | (reset! stars-w 0.0) 142 | 143 | (reset! no-circles 1.0) 144 | 145 | (kill drums-g) 146 | (kill voice-g) 147 | (kill backing-voice-g) 148 | (kill bass-g) 149 | (ctl drums-g :amp 0) 150 | (ctl drum-effects-g :amp 0) 151 | (ctl supernova :amp 0) 152 | (ctl helium :amp 0) 153 | (ctl hydrogen :amp 0) 154 | (ctl stellar-wind :amp 0) 155 | (ctl metallicity :amp 0) 156 | (ctl nebula :amp 0) 157 | ) 158 | 159 | (defn full-stop [] 160 | (reset! cutout-w 0.0) 161 | (reset! stars-w 0.0) 162 | (reset! heart-w 0.0) 163 | (reset! cellular-w 0.0) 164 | (remove-on-beat-trigger) 165 | (fadeout-master)) 166 | -------------------------------------------------------------------------------- /resources/shaders/space_and_time.glsl: -------------------------------------------------------------------------------- 1 | //Space and Time by Joseph Wilk 2 | 3 | uniform float iOvertoneVolume; 4 | uniform float iGlobalBeatCount; 5 | 6 | vec3 hsv2rgb(float h, float s, float v) { 7 | return mix(vec3(1.), clamp((abs(fract(h+vec3(3.,2.,1.)/3.)*6.-3.)-1.),0.,1.),s)*v; 8 | } 9 | 10 | vec3 hsvToRgb(float mixRate, float colorStrength){ 11 | float colorChangeRate = 18.0; 12 | float time = fract(iGlobalTime/colorChangeRate); 13 | float movementStart = (mod(iGlobalBeatCount,16) == 0) ? 1.0 : 0.5; 14 | vec3 x = abs(fract((mod(iGlobalBeatCount,16)-1+time) + vec3(2.,3.,1.)/3.) * 6.-3.) - 1.; 15 | vec3 c = clamp(x, 0.,1.); 16 | //c = c*iBeat; 17 | //c = c * clamp(iBeat, 0.1, 0.4)+0.6; 18 | return mix(vec3(1.0), c, mixRate) * colorStrength; 19 | } 20 | 21 | 22 | vec4 lineDistort(vec4 cTextureScreen, vec2 uv1){ 23 | float sCount = 900.; 24 | float nIntensity=0.1; 25 | float sIntensity=0.2; 26 | float noiseEntry = 0.0; 27 | float accelerator= 1000.0; 28 | 29 | float x = uv1.x * uv1.y * iGlobalTime * accelerator; 30 | x = mod( x, 13.0 ) * mod( x, 123.0 ); 31 | float dx = mod( x, 0.05 ); 32 | vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 ); 33 | vec2 sc = vec2( sin( uv1.y * sCount ), cos( uv1.y * sCount ) ); 34 | cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity; 35 | cResult = cTextureScreen.rgb + clamp(nIntensity, noiseEntry,1.0 ) * (cResult - cTextureScreen.rgb); 36 | return vec4(cResult, cTextureScreen.a); 37 | } 38 | 39 | vec2 rotate(vec2 p, float a){ 40 | return vec2(p.x * cos(a) - p.y * sin(a), p.x * sin(a) + p.y * cos(a)); 41 | } 42 | 43 | float smoothedVolume; 44 | 45 | vec4 generateSpaceLights(vec2 uv1){ 46 | vec2 uv = uv1 * 2.0 - 1.0; 47 | uv.x *= iResolution.x / iResolution.y; 48 | 49 | float v = 0.0; 50 | 51 | vec3 ray = vec3(sin(iGlobalTime * 0.1) * 0.2, cos(iGlobalTime * 0.13) * 0.2, 1.5); 52 | vec3 dir; 53 | dir = normalize(vec3(uv, 1.0)); 54 | 55 | ray.z += iGlobalTime * 0.001 - 20.0; 56 | dir.xz = rotate(dir.xz, sin(iGlobalTime * 0.001) * 0.1); 57 | dir.xy = rotate(dir.xy, iGlobalTime * 0.01); 58 | 59 | #define STEPS 8 60 | 61 | smoothedVolume += (iOvertoneVolume - smoothedVolume) * 0.1; 62 | 63 | float inc = smoothedVolume / float(STEPS); 64 | if (iOvertoneVolume<=0.01){ 65 | inc = 0; 66 | } 67 | else{ 68 | inc = clamp(inc, 0.2,0.8); 69 | } 70 | 71 | vec3 acc = vec3(0.0); 72 | 73 | for(int i = 0; i < STEPS; i ++){ 74 | vec3 p = ray * 0.1; 75 | 76 | for(int i = 0; i < 14; i ++){ 77 | p = abs(p) / dot(p, p) * 2.0 - 1.0; 78 | } 79 | float it = 0.001 * length(p * p); 80 | v += it; 81 | 82 | acc += sqrt(it) * texture2D(iChannel1, ray.xy * 0.1 + ray.z * 0.1).xyz; 83 | ray += dir * inc; 84 | } 85 | 86 | float br = pow(v * 4.0, 3.0) * 0.1; 87 | vec3 col = pow(acc * 0.5, vec3(1.2)) + br; 88 | return vec4(col, 1.0); 89 | } 90 | 91 | float normpdf(in float x, in float sigma) 92 | { 93 | return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma; 94 | } 95 | 96 | 97 | 98 | float time = iGlobalTime; 99 | vec2 mouse = iMouse.xy/iResolution.xy; 100 | vec2 resolution = iResolution.xy; 101 | 102 | const float PI = 3.141592653589; 103 | 104 | float cap(vec2 a, vec2 b) { 105 | vec2 abd = vec2(a.x*b.x+a.y*b.y, a.y*b.x-a.x*b.y); 106 | float y_x = abd.y/(abd.x-1.); 107 | 108 | return atan(-y_x)-y_x/(1.+y_x*y_x)+PI/2.; 109 | } 110 | 111 | float cap1(float p) { 112 | p = max(min(p,1.),-1.); 113 | return asin(p)+p*sqrt(1.-p*p)+PI/2.; 114 | } 115 | 116 | float ebok(vec2 p, vec2 a, vec2 b) { 117 | vec2 an = vec2(a.y,-a.x); 118 | vec2 bn = vec2(b.y,-b.x); 119 | 120 | float surface; 121 | if (dot(normalize(an),normalize(bn))>.9999) { 122 | // This is neccessary to remove dot crawl around corners 123 | surface = 0.; 124 | } else if (dot(p,p) < .99) { 125 | float pa = dot(p,a); 126 | float ra = -pa+sqrt(pa*pa-dot(p,p)+1.); 127 | vec2 pac = ra*a; 128 | 129 | float pb = dot(p,b); 130 | float rb = -pb+sqrt(pb*pb-dot(p,p)+1.); 131 | vec2 pbc = rb*b; 132 | 133 | surface = cap(p+pac,p+pbc)+(pac.x*pbc.y-pac.y*pbc.x)*.5; 134 | } else { 135 | float d1 = dot(an,p); 136 | float d2 = -dot(bn,p); 137 | float sda = step(dot(p,a),0.); 138 | float sdb = step(dot(p,b),0.); 139 | surface = PI*(sda+sdb-sda*sdb) - cap1(-d1)*sda - cap1(-d2)*sdb; 140 | 141 | } 142 | return surface; 143 | } 144 | 145 | float handleCorner(vec2 p, vec2 a, vec2 b, vec2 c) { 146 | vec2 ba = normalize(a-b); 147 | vec2 bc = normalize(c-b); 148 | float h = dot(a-p,vec2(ba.y,-ba.x)); 149 | return ebok(p-b, bc, ba) - cap1(h); 150 | } 151 | 152 | float bokehtria(vec2 p, vec2 a, vec2 b, vec2 c) { 153 | vec2 mi = min(min(a,b),c)-1.; 154 | vec2 ma = max(max(a,b),c)+1.; 155 | return (a.x-b.x)*(a.y-c.y)<(a.y-b.y)*(a.x-c.x)||p.xma.x||p.y>ma.y ? 0. : handleCorner(p,a,b,c) + handleCorner(p,b,c,a) + handleCorner(p,c,a,b) + PI; 156 | } 157 | 158 | float bokehsquare(vec2 p, vec2 a, vec2 b, vec2 c, vec2 d, float scale) { 159 | p *= scale; a *= scale; b *= scale; c *= scale; d *= scale; 160 | vec2 mi = min(min(a,b),min(c,d))-1.; 161 | vec2 ma = max(max(a,b),max(c,d))+1.; 162 | return (a.x-b.x)*(a.y-c.y)<(a.y-b.y)*(a.x-c.x)||p.xma.x||p.y>ma.y ? 0. : handleCorner(p,a,b,c) + handleCorner(p,b,c,d) + handleCorner(p,c,d,a) + handleCorner(p,d,a,b) + PI; 163 | } 164 | 165 | vec2 project(vec3 v) { 166 | return v.xy/(v.z+14.); 167 | } 168 | 169 | vec4 shade(vec3 v, float f) { 170 | float highlight = pow(f*.5+.5,100.); 171 | return vec4(pow(f*.5+.5,10.)*v*1.5*(1.-highlight)+highlight,1.)/PI; 172 | } 173 | 174 | 175 | 176 | // Bluring fn froms: 177 | // Bokeh disc. 178 | // by David Hoskins. 179 | // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 180 | #define PI 3.141596 181 | 182 | // This is (3.-sqrt(5.0))*PI radians, which doesn't precompiled for some reason. 183 | // The compiler is a dunce I tells-ya!! 184 | #define GOLDEN_ANGLE 2.39996323 185 | 186 | #define NUMBER 150.0 187 | 188 | #define ITERATIONS (GOLDEN_ANGLE * NUMBER) 189 | 190 | //------------------------------------------------------------------------------------------- 191 | // This creates the 2D offset for the next point. 192 | // (r-1.0) is the equivalent to sqrt(0, 1, 2, 3...) 193 | vec2 Sample(in float theta, inout float r){ 194 | r += 1.0 / r; 195 | return (r-1.0) * vec2(cos(theta), sin(theta)); 196 | } 197 | 198 | vec3 Bokeh(sampler2D tex, vec2 uv, float radius, float amount){ 199 | vec3 acc = vec3(0.0); 200 | vec3 div = vec3(0.0); 201 | vec2 pixel = vec2(iResolution.y/iResolution.x, 1.0) * radius * .002; 202 | float r = 1.0; 203 | for (float j = 0.0; j < ITERATIONS; j += GOLDEN_ANGLE){ 204 | vec2 idx = uv + pixel * Sample(j, r); 205 | idx.y=0.25; 206 | vec3 col = texture2D(tex, idx).xyz; 207 | col = col * col * 1.4; // ...contrast it for better highlights 208 | vec3 bokeh = vec3(5.0) + pow(col, vec3(9.0)) * amount; 209 | acc += col * bokeh; 210 | div += bokeh; 211 | } 212 | return acc / div; 213 | } 214 | 215 | vec4 blur(vec2 uv){ 216 | vec2 uv2 = gl_FragCoord.xy / iResolution.xy; 217 | float r = 0.3; 218 | float a = 0.0; 219 | uv2 = vec2(iResolution.y/uv.y, 0.25); 220 | 221 | float d = clamp(uv.y/8, 0.0, iResolution.y); 222 | uv2 = vec2(pow(d, 1.0), 0.25); 223 | return vec4(Bokeh(iChannel0, uv2, r, a), 1.0); 224 | } 225 | 226 | vec4 textureCutout(vec4 w, vec4 tex){ 227 | vec4 logoAlpha = tex.aaaa; 228 | vec4 negAlpha = logoAlpha * vec4(-1.,-1.,-1.,0.) + vec4(1.,1.,1.,0.); 229 | w = negAlpha - (w + logoAlpha); 230 | return w; 231 | } 232 | 233 | vec3 mod289(vec3 x){ 234 | return x - floor(x * (1.0 / 289.0)) * 289.0; 235 | } 236 | 237 | vec2 mod289(vec2 x) { 238 | return x - floor(x * (1.0 / 289.0)) * 289.0; 239 | } 240 | 241 | vec3 permute(vec3 x){ 242 | return mod289(((x*34.0)+1.0)*x); 243 | } 244 | 245 | float snoise(vec2 v){ 246 | const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); 247 | vec2 i = floor(v + dot(v, C.yy)); 248 | vec2 x0 = v - i + dot(i, C.xx); 249 | 250 | vec2 i1; 251 | i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); 252 | vec4 x12 = x0.xyxy + C.xxzz; 253 | x12.xy -= i1; 254 | 255 | i = mod289(i); // Avoid truncation effects in permutation 256 | vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); 257 | vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); 258 | m = m*m; 259 | m = m*m; 260 | 261 | vec3 x = 2.0 * fract(p * C.www) - 1.0; 262 | vec3 h = abs(x) - 0.5; 263 | vec3 ox = floor(x + 0.5); 264 | vec3 a0 = x - ox; 265 | 266 | m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h); 267 | 268 | vec3 g; 269 | g.x = a0.x * x0.x + h.x * x0.y; 270 | g.yz = a0.yz * x12.xz + h.yz * x12.yw; 271 | return 130.0 * dot(m, g); 272 | } 273 | 274 | vec2 warpedCords(vec2 p){ 275 | float distortion=0.0001; 276 | float distortion2=0.5; 277 | float speed=0.02; 278 | float rollSpeed=0.0; 279 | float ty = iGlobalTime* speed; 280 | float yt = p.y - ty; 281 | float offset = snoise(vec2(yt*3.0,0.0))*0.2; 282 | offset = pow(offset*distortion, 3.0)/distortion ; 283 | offset += snoise(vec2(yt*50.0,0.0))*distortion2*0.001; 284 | vec2 o = vec2(fract(p.x + offset), fract(p.y-iGlobalTime*rollSpeed)); 285 | return o; 286 | } 287 | 288 | 289 | void main(void){ 290 | vec2 uv = gl_FragCoord.xy / iResolution.x; 291 | vec4 r = generateSpaceLights(uv) + vec4(hsvToRgb(0.0,0.0),1.0); 292 | 293 | float time = 0.0; 294 | float space = 0.0; 295 | float blurWeight = 0.0; 296 | 297 | uv.y += 0.0; 298 | // uv.x= uv.x*1.0; 299 | // uv.y= uv.y*1; 300 | 301 | //r = r+blur(uv); 302 | // vec4 poop = vec4(texture2D(iChannel0, uv).xyz, 1.0); 303 | vec4 blurR = blur(uv); 304 | 305 | if(blurWeight > 0.0){ 306 | r += blurR;} 307 | else{ 308 | // 309 | // float d = clamp(uv.y/8, 0.0, iResolution.y); 310 | //r += texture2D(iChannel0, vec2(pow(d, 1.0), 0.25)); 311 | } 312 | 313 | r = r - time*(textureCutout(vec4(0.0,0.0,0.0,1.0), texture2D(iChannel2, warpedCords(uv)))); 314 | r = r - space*(textureCutout(vec4(0.0,0.0,0.0,1.0),texture2D(iChannel3, warpedCords(uv)))); 315 | 316 | 317 | gl_FragColor = lineDistort(r, uv); 318 | } 319 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/flatiron/scores.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.flatiron.scores 2 | (:use [overtone.live] 3 | [cassiopeia.engine.expediency] 4 | [mud.core] 5 | [mud.chords])) 6 | 7 | (def dark-chords-score 8 | (let [_ [0 0 0 0] 9 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 3)] 10 | (chords-seq [:F3 :1*16 :3*16 :4*16 :6*8 :m+5*8 11 | :F3 :1*16 :3*16 :4*16 :6*8 :m7+5*8]) 12 | (concat 13 | (repeat 16 f31) 14 | (repeat 16 f33) 15 | (repeat 16 f34) 16 | (repeat 8 f36) (repeat 8 (chord :F3 :m+5)) 17 | 18 | (repeat 16 f31) 19 | (repeat 16 f33) 20 | (repeat 16 f34) 21 | (repeat 8 f36) (repeat 8 (chord :F3 :m7+5))))) 22 | 23 | (def darker-pinger-score 24 | (let [_ [0 0 0 0] 25 | [c31 c32 c33 c34 c35 c36 c37] (chords-for :C3 :minor 1) 26 | [c41 c42 c43 c44 c45 c46 c47] (chords-for :C4 :minor 1) 27 | [f21 f22 f23 f24 f25 f26 f27] (chords-for :F2 :minor 1) 28 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 29 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1)] 30 | (chord-score (repeat 6 [c41 f31 f33 f34 f31 f31 f41 f31 c41 f31 f33 f34 f31 f31 f41 f31]) 31 | [c37 f31 f33 f34 f31 f31 f41 f31 c37 f31 f33 f34 f31 f31 f41 f31] 32 | [c41 f31 f33 f34 f31 f31 f41 f31 c34 f31 f33 f31 f31 f31 f41 f31] 33 | 34 | (repeat 6 [c41 f31 f33 f34 f31 f31 f41 f31 c41 f31 f33 f34 f31 f31 f41 f31]) 35 | [c37 f31 f33 f34 f31 f31 f41 f31 c37 f31 f33 f34 f31 f31 f41 f31] 36 | [c41 f31 f33 f41 f27 f31 f31 f31 c31 f31 f33 f41 f31 f31 f41 f31]))) 37 | 38 | (def apeg-swell 39 | (chord-score 40 | (repeat 16 (degrees [1] :minor :F3)) 41 | (repeat 16 (degrees [1] :minor :F3)) 42 | (repeat 16 (degrees [4] :minor :F3)) 43 | (repeat 8 (degrees [4] :minor :F3)) 44 | (repeat 4 (degrees [5] :minor :F3)) 45 | (repeat 4 (degrees [4] :minor :F3)))) 46 | 47 | ;;ia/b/c iia/b/c IIIa/b/c iva/b/c va/b/c VIa/b/c VIIa/b/c 48 | (def chords-score 49 | (let [_ [0 0 0 0] 50 | [f21b f22b f23b f24b f25b f26b f27b] (chords-with-inversion [1] :F2 :minor :up 3) 51 | [f21c f22c f23c f24c f25c f26c f27c] (chords-with-inversion [1 2] :F2 :minor :up 3) 52 | [f21 f22 f23 f24 f25 f26 f27] (chords-for :F2 :minor 3)] 53 | 54 | ;; (chords-seq [:F2 :1c*8 :6*8 :3b*8 :4b*6 :sus4c*2 :F2 :1c*8 :1c*8 :3b*8 :5b*6 :7sus4c*2] :minor) 55 | ;; (chords-seq "F2 1c*8 6*8 3b*8 4b*6 sus4c*2 F2 1c*8 1c*8 3b*8 5b*6 7sus4c*2" :minor) 56 | 57 | (concat 58 | (repeat 8 f21c) 59 | (repeat 8 f26) 60 | (repeat 8 f23b) 61 | [f24b f24b f24b f24b f24b f24b (chord :F2 :sus4 2) (chord :F2 :sus4 2)] 62 | 63 | (repeat 8 f21c) 64 | (repeat 8 f21c) 65 | (repeat 8 f23b) 66 | [f25b f25b f25b f25b f25b f25b (chord :F2 :7sus4 2) (chord :F2 :7sus4 2)]))) 67 | 68 | (def pinger-score-alternative 69 | (let [_ [0 0 0 0] 70 | [c31 c32 c33 c34 c35 c36 c37] (chords-for :C3 :minor 1) 71 | [c41 c42 c43 c44 c45 c46 c47] (chords-for :C4 :minor 1) 72 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 73 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1)] 74 | 75 | [f43 _ f43 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 76 | f41 f43 f41 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 77 | 78 | c41 f35 f31 f34 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 79 | c41 f35 f31 f34 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 80 | 81 | f41 _ f43 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 82 | f41 f43 f41 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 83 | 84 | f37 f41 _ f41 c35 _ (as-chord (degrees [1] :minor :F3)) (as-chord (degrees [1] :minor :F3)) 85 | f37 f41 _ f41 c41 _ (as-chord (degrees [1] :minor :F3)) (as-chord (degrees [1] :minor :F3)) 86 | ;;-- 87 | f41 _ f43 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 88 | f41 f43 f41 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 89 | 90 | f41 _ f43 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 91 | f41 f43 f41 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 92 | 93 | f41 _ f43 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 94 | f41 f43 f41 f44 f37 f36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 95 | 96 | f37 f41 _ f41 c35 _ (as-chord (degrees [1] :minor :F3)) (as-chord (degrees [1] :minor :F3)) 97 | f37 f41 _ f41 c41 _ (as-chord (degrees [1] :minor :F3)) (as-chord (degrees [1] :minor :F3))])) 98 | 99 | (def pinger-score-highlighted 100 | (let [_ [0 0 0 0] 101 | [c31 c32 c33 c34 c35 c36 c37] (chords-for :C3 :minor 1) 102 | [c41 c42 c43 c44 c45 c46 c47] (chords-for :C4 :minor 1) 103 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 104 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1) 105 | [f312 f322 f332 f342 f352 f362 f372] (chords-for :F3 :minor 2)] 106 | 107 | (comment 108 | (degrees-seq :minor 109 | (repeat 2 [:F4 1 3 1 4 :F3 7 :C3 6 :F3 7 7]) 110 | (repeat 2 [:F4 1 3 1 4 :C3 7 :C3 6 :F3 7 7]) 111 | 112 | (repeat 2 [:F4 1 3 1 4 :F3 7 :C3 6 :F3 7 7]) 113 | [:F4 1 3 1 4 :C4 3 :C3 6 :F3 7 7] 114 | [:F4 1 3 1 :C4 4 7 6 :C4 3 :F3 5] 115 | )) 116 | 117 | 118 | [f41 f43 f41 f44 f37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 119 | f41 f43 f41 f44 f37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 120 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 121 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 122 | 123 | f41 f43 f41 f44 f37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 124 | f41 f43 f41 f44 f37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 125 | f41 f43 f41 f44 c43 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 126 | f41 f43 f41 c44 c47 c46 (as-chord (degrees [3] :minor :C4)) (as-chord (degrees [5] :minor :F3)) 127 | 128 | ;;- 129 | 130 | f41 f43 f41 f44 f37 c36 (degrees [1] :minor :F3) (as-chord (degrees [7] :minor :F3)) 131 | f41 f43 f41 f44 f37 c36 (degrees [1] :minor :F3) (as-chord (degrees [7] :minor :F3)) 132 | f41 f43 f41 f44 f41 c36 (degrees [1] :minor :F3) (as-chord (degrees [7] :minor :F3)) 133 | f41 f43 f41 f44 f41 c36 (degrees [1] :minor :F3) (as-chord (degrees [7] :minor :F3)) 134 | 135 | f41 f43 f41 f44 c43 c36 (degrees [7] :minor :F3) (as-chord (degrees [7] :minor :F3)) 136 | f41 f43 f41 f44 c43 c36 (degrees [7] :minor :F3) (as-chord (degrees [7] :minor :F3)) 137 | f41 f43 f41 f44 c41 c36 (degrees [1] :minor :F3) (as-chord (degrees [7] :minor :F3)) 138 | f41 f43 f41 c44 c47 c36 f352 f312])) 139 | 140 | (def pinger-score 141 | (let [_ [0 0 0 0] 142 | [c31 c32 c33 c34 c35 c36 c37] (chords-for :C3 :minor 1) 143 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 144 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1)] 145 | (let [new-pat (chord-score 146 | (repeat 15 [f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3))]) 147 | [f41 _ f43 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3))])] 148 | 149 | [f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 150 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 151 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 152 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 153 | 154 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 155 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 156 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 157 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 158 | 159 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 160 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 161 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 162 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 163 | 164 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 165 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 166 | f41 f43 f41 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3)) 167 | f41 _ f43 f44 c37 c36 (as-chord (degrees [7] :minor :F3)) (as-chord (degrees [7] :minor :F3))]))) 168 | 169 | (def pinger-growth-score-spair 170 | (let [_ [0 0 0 0] 171 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 172 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1) 173 | ;;_ (concat (degrees-seq [:f4 1 _ 34 :f3 7677] (repeat 3 (degrees-seq [:f4 1314 :f3 7677])))) 174 | ] 175 | 176 | [f41 _ f43 f44 f37 f36 (flatten [(degrees [7] :minor :F3) 0 0 0]) (flatten [(degrees [7] :minor :F3) 0 0 0]) 177 | f41 f43 f41 f44 f37 f36 (flatten [(degrees [7] :minor :F3) 0 0 0]) (flatten [(degrees [7] :minor :F3) 0 0 0]) 178 | f41 f43 f41 f44 f37 f36 (flatten [(degrees [7] :minor :F3) 0 0 0]) (flatten [(degrees [7] :minor :F3) 0 0 0]) 179 | f41 f43 f41 f44 f37 f36 (flatten [(degrees [7] :minor :F3) 0 0 0]) (flatten [(degrees [7] :minor :F3) 0 0 0])])) 180 | 181 | (def pinger-score-spair 182 | (let [_ [0 0 0 0] 183 | [c31 c32 c33 c34 c35 c36 c37] (chords-for :C3 :minor 1) 184 | [f31 f32 f33 f34 f35 f36 f37] (chords-for :F3 :minor 1) 185 | [f41 f42 f43 f44 f45 f46 f47] (chords-for :F4 :minor 1)] 186 | [f41 f43 f41 f44 c37 c36 (flatten [(degrees [7] :minor :F3) 0 0 0]) (flatten [(degrees [7] :minor :F3) 0 0 0])])) 187 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/alpha.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.alpha 2 | " 3 | 4 | .'. | |`````````, | | .'. 5 | .''```. | |''''''''' |_________| .''```. 6 | .' `. | | | | .' `. 7 | .' `. |_______ | | | .' `. 8 | 9 | * Surface temperature: 4530 K 10 | * Mass: 8.95E30 kg 11 | * Radius: 29,280,000 km 12 | * Magnitude: 2.24 13 | " 14 | (:use [overtone.live] 15 | ;;[cassiopeia.warm-up] 16 | [cassiopeia.samples] 17 | [overtone.synth.sampled-piano] 18 | [mud.core]) 19 | (:require [mud.timing :as time] 20 | ;;[launchpad.sequencer :as lp-sequencer] 21 | ;;[launchpad.plugin.beat :as lp-beat] 22 | [cassiopeia.engine.expediency :refer :all] 23 | [cassiopeia.engine.mixers :as m] 24 | [overtone.inst.synth :as s] 25 | [overtone.synths :as syn] 26 | [cassiopeia.waves.synths :as cs])) 27 | 28 | (do 29 | (def star-into-the-sun (load-sample "~/Workspace/music/samples/star-into-the-sun.wav")) 30 | (def space-and-time-sun (load-sample "~/Workspace/music/samples/space_and_time.wav")) 31 | 32 | (def windy (sample (freesound-path 17553))) 33 | 34 | (defonce rhythm-g (group "Rhythm" :after time/timing-g)) 35 | (defonce saw-bf1 (buffer 256)) 36 | (defonce saw-bf2 (buffer 256)) 37 | 38 | (defonce saw-x-b1 (control-bus 1 "Timing Saw 1")) 39 | (defonce saw-x-b2 (control-bus 1 "Timing Saw 2")) 40 | (defonce saw-x-b3 (control-bus 1 "Timing Saw 3")) 41 | 42 | (defonce phasor-b1 (control-bus 1 "Timing Saw Phasor 1")) 43 | (defonce phasor-b2 (control-bus 1 "Timing Saw Phasor 2")) 44 | 45 | (defonce phasor-b3 (control-bus 1 "Timing Saw Phasor 3")) 46 | (defonce phasor-b4 (control-bus 1 "Timing Saw Phasor 4")) 47 | (defonce phasor-b5 (control-bus 1 "Timing Saw Phasor 5")) 48 | 49 | (defonce saw-s1 (time/saw-x [:head rhythm-g] :out-bus saw-x-b1)) 50 | (defonce saw-s2 (time/saw-x [:head rhythm-g] :out-bus saw-x-b2)) 51 | 52 | (defonce saw-s3 (time/saw-x [:head rhythm-g] :out-bus saw-x-b3)) 53 | 54 | (defonce phasor-s1 (time/buf-phasor [:after saw-s1] saw-x-b1 :out-bus phasor-b1 :buf saw-bf1)) 55 | (defonce phasor-s2 (time/buf-phasor [:after saw-s2] saw-x-b2 :out-bus phasor-b2 :buf saw-bf2)) 56 | 57 | (def space-notes-buf (buffer 5)) 58 | (def space-tones-buf (buffer 3)) 59 | 60 | (defonce phasor-s3 (time/buf-phasor [:after saw-s3] saw-x-b3 :out-bus phasor-b3 :buf space-notes-buf)) 61 | 62 | (defsynth buffered-plain-space-organ [out-bus 0 duration 4 amp 1] 63 | (let [tone (/ (in:kr phasor-b2) 2) 64 | tones (map #(blip (* % 2) (mul-add:kr (lf-noise1:kr 1/8) 1 4)) [tone])] 65 | (out out-bus (pan2 (* amp (g-verb (sum tones) 200 8)))))) 66 | 67 | (defsynth ratatat [out-bus 0 amp 1] 68 | (let [freq (in:kr phasor-b2) 69 | sin1 (sin-osc (* 1.01 freq)) 70 | sin2 (sin-osc (* 1 freq)) 71 | sin3 (sin-osc (* 0.99 freq)) 72 | src (mix [sin1 sin2 sin3]) 73 | src (g-verb src :spread 10)] 74 | (out out-bus (* amp (pan2 src))))) 75 | 76 | (defn transpose [updown notes] 77 | (map #(+ updown %1) notes)) 78 | 79 | (def space-notes [8 16 32 16 8]) 80 | (def space-tones [8 16 24]) 81 | 82 | (defsynth crystal-space-organ [out-bus 0 amp 1 size 200 r 8 numharm 0 trig 0 t0 8 t1 16 t2 24 d0 1 d1 1/2 d2 1/4 d3 1/8] 83 | (let [notes (map #(midicps (duty:kr % (mod trig 16) (dseq space-notes INF))) [d0 d1 d2 d3]) 84 | tones (map (fn [note tone] (blip (* note tone) numharm)) notes [t0 t1 t2])] 85 | (out out-bus (* amp (g-verb (sum tones) size r))))) 86 | 87 | (comment (def csp (crystal-space-organ :numharm 0 :amp 0.5))) 88 | 89 | (def space-notes [8 16 32 16 8]) 90 | (defsynth high-space-organ [cutoff 90 out-bus 0 amp 1 size 200 r 8 noise 10 trig 0 t0 8 t1 16 t2 24 d0 1 d1 1/2 d2 1/4] 91 | (let [space-notes1-buf (buf-rd:kr 1 space-notes-buf 0) 92 | space-notes2-buf (buf-rd:kr 1 space-notes-buf 1) 93 | space-notes3-buf (buf-rd:kr 1 space-notes-buf 2) 94 | space-notes4-buf (buf-rd:kr 1 space-notes-buf 3) 95 | space-notes5-buf (buf-rd:kr 1 space-notes-buf 4) 96 | space-notes-in [space-notes1-buf space-notes2-buf space-notes3-buf space-notes4-buf space-notes5-buf] 97 | notes (map #(duty:kr % (mod trig 16) (dseq space-notes-in INF)) [d0 d1 d2]) 98 | tones (map (fn [note tone] 99 | (println :none note :tone tone) 100 | (blip (* note tone) (mul-add:kr (lf-noise1:kr noise) 3 4))) notes [t0 t1 t2]) 101 | _ (println tones) 102 | src (* amp (g-verb (sum tones) size r)) 103 | src (lpf src cutoff)] 104 | (out out-bus src))) 105 | 106 | (println (map midi->hz [8 16 32 16 8])) 107 | 108 | (ctl so :t0 1 :t1 1 :t2 1) 109 | 110 | (pattern! space-notes-buf (map midi->hz (degrees-seq [:C#0 1 :C#0 3 :C#1 5]))) 111 | 112 | ;;:t0 2 :t1 4 :t2 8 :out-bus 0 113 | (pattern! space-notes-buf (map midi->hz [8 16 32 16 8])) 114 | (def so (high-space-organ :amp 0.4 115 | :trig time/beat-count-b 116 | :noise 220 :t0 1 :t1 1 :t2 2 :out-bus 0)) 117 | (ctl so :cutoff 2000a) 118 | (ctl so :amp 0.5) 119 | (ctl so :t0 2) 120 | (ctl so :t1 4) 121 | (ctl so :t2 8) 122 | (kill high-space-organ) 123 | 124 | (comment (high-space-organ)) 125 | 126 | (defsynth timed-high-space-organ [out-bus 0 amp 1 size 200 r 8 noise 10 ] 127 | (let [note (in:kr phasor-b3) 128 | tone1 (buf-rd:kr 1 space-tones-buf 0) 129 | tone2 (buf-rd:kr 1 space-tones-buf 1) 130 | tone3 (buf-rd:kr 1 space-tones-buf 2) 131 | 132 | trig1 (t-duty:kr (dseq [1] INFINITE)) 133 | trig2 (t-duty:kr (dseq [1/2] INFINITE)) 134 | trig3 (t-duty:kr (dseq [1/4] INFINITE)) 135 | 136 | note1 (midicps (demand:kr trig1 0 (drand note INFINITE))) 137 | note2 (midicps (demand:kr trig2 0 (drand note INFINITE))) 138 | note3 (midicps (demand:kr trig3 0 (drand note INFINITE))) 139 | 140 | all-tones [tone1 tone2 tone3] 141 | all-notes [note1 note2 note3] 142 | 143 | tones (map (fn [note tone] (blip (* note tone) 144 | (mul-add:kr (lf-noise1:kr noise) 3 4))) all-notes all-tones)] 145 | (out out-bus (* amp (g-verb (sum tones) size r))))) 146 | 147 | (comment 148 | (show-graphviz-synth timed-high-space-organ) 149 | (ctl saw-s3 :freq-mul 1/32) 150 | (buffer-write! space-notes-buf [8 16 32 16 8]) 151 | 152 | (buffer-write! space-tones-buf [2 4 8]) 153 | (buffer-write! space-tones-buf [8 12 16]) 154 | (buffer-write! space-tones-buf [8 16 24]) 155 | 156 | (def thso (timed-high-space-organ :noise 220 :amp 0.4)) 157 | 158 | (ctl thso :noise 10) 159 | (ctl thso :size 0) 160 | (ctl thso :size 200) 161 | 162 | (def so (high-space-organ :amp 0.4 :trig time/beat-count-b :noise 220 :t0 2 :t1 4 :t2 8 :out-bus 0)) 163 | 164 | (show-graphviz-synth high-space-organ) 165 | 166 | (stop)) 167 | 168 | (defsynth plain-space-organ [out-bus 0 tone 1 duration 3 amp 1] 169 | (let [tones (map #(blip (* % 2) (mul-add:kr 1/8 1 4)) [tone])] 170 | (out out-bus (* amp (g-verb (sum tones) 200 8) (line 1 0 duration FREE))))) 171 | 172 | (defsynth space-organ [out-bus 0 tone 1 duration 3 amp 1] 173 | (let [f (map #(midicps (duty:kr % 0 (dseq 2 4))) 174 | [1]) 175 | tones (map #(blip (* % %2) (mul-add:kr (lf-noise1:kr 1/8) 2 4)) 176 | f 177 | [tone])] 178 | (out out-bus (* amp (g-verb (sum tones) 200 8) (line 1 0 duration FREE)))))) 179 | 180 | ;;SCORE 181 | 182 | (def sun (sample-player star-into-the-sun :rate 0.99 :amp 8 :out-bus 0)) 183 | 184 | (def space-and-time (sample-player space-and-time-sun :rate 0.8)) 185 | (ctl space-and-time :rate 0.7) 186 | (ctl space-and-time :rate 0.8) 187 | 188 | (syn/fallout-wind) 189 | (syn/soft-phasing :amp 0.0) 190 | (def dark (syn/dark-sea-horns :amp 0.3)) 191 | (ctl dark :amp 1) 192 | 193 | (kill dark) 194 | (kill syn/soft-phasing) 195 | (kill syn/fallout-wind) 196 | 197 | ;;Rythm 198 | 199 | (def score (map note [:F5 :G5 :G5 :G5 :G5 :BB5 :BB5 :D#5])) 200 | 201 | (buffer-write! saw-bf2 (repeat 256 (midi->hz (note :A3)))) 202 | 203 | (buffer-write! saw-bf2 (map midi->hz 204 | (map (fn [midi-note] (+ -12 midi-note)) 205 | (map note (take 256 (cycle score)))))) 206 | 207 | (buffer-write! saw-bf2 (map midi->hz 208 | (map (fn [midi-note] (+ -5 midi-note)) 209 | (map note (take 256 (cycle score)))))) 210 | 211 | (buffer-write! saw-bf2 (map midi->hz 212 | (map (fn [midi-note] (+ 0 midi-note)) 213 | (map note (take 256 (cycle score)))))) 214 | 215 | (ratatat :amp 0.9) 216 | (ctl saw-s2 :freq-mul 1/40) 217 | (kill ratatat) 218 | 219 | (buffered-plain-space-organ :amp 0.8) 220 | (kill buffered-plain-space-organ) 221 | 222 | (stop) 223 | 224 | ;;Jaming 225 | 226 | (plain-space-organ :tone (/ 24 2) :duration 16) 227 | 228 | (def note-cycle (degrees [1 2 3] :major :C#2)) 229 | (def note-inc (atom 0)) 230 | (def trigger-g99018 231 | (on-beat-trigger 8 (fn [] 232 | (swap! note-inc inc) 233 | (plain-space-organ :tone (/ (midi->hz (nth (degrees [1 2 3] :major :C#1) (mod @note-inc 3) ) ) 1) :duration 16.0 :amp 0.2) 234 | ))) 235 | (remove-beat-trigger trigger-g99018) 236 | (remove-all-beat-triggers) 237 | 238 | 239 | (def so (high-space-organ :amp 0.4 :trig time/beat-count-b :noise 220 :t0 2 :t1 4 :t2 8 :out-bus 0)) 240 | (def so (high-space-organ :amp 0.4 :trig time/beat-count-b :noise 220 :t0 1 :t1 1 :t2 1 :out-bus 0)) 241 | 242 | (ctl so :cutoff 250) 243 | 244 | (kill so) 245 | 246 | (ctl so :noise 50) 247 | (ctl so :vol 1) 248 | 249 | (ctl so :t0 1 :t1 1 :t2 1) 250 | (ctl so :t0 8 :t1 12 :t2 16) 251 | (ctl so :t0 8 :t1 16 :t2 24) 252 | 253 | (ctl so :r 10) 254 | (ctl so :size 0) 255 | (ctl so :size 200) 256 | (ctl so :amp 0.1) 257 | 258 | 259 | (volume 1.0) 260 | (comment (stop)) 261 | (comment 262 | (defonce kick-seq-buf (buffer 256)) 263 | (def beats (cs/buffer->tap-lite kick-seq-buf (:count time/beat-1th) :measure 8)) 264 | 265 | (start-graphics "resources/shaders/space_and_time.glsl" 266 | :textures [:overtone-audio 267 | :previous-frame 268 | "resources/textures/tex16.png" 269 | "resources/textures/time.png" 270 | ;;"resources/textures/space.png" 271 | ] 272 | :user-data {"iGlobalBeatCount" (atom {:synth beats :tap "global-beat-count"})}) 273 | (stop-graphics "resources/shaders/space_and_time.glsl") 274 | ) 275 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/chaos.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.chaos 2 | " 3 | ██████╗██╗ ██╗ █████╗ ██████╗ ███████╗ 4 | ██╔════╝██║ ██║██╔══██╗██╔═══██╗██╔════╝ 5 | ██║ ███████║███████║██║ ██║███████╗ 6 | ██║ ██╔══██║██╔══██║██║ ██║╚════██║ 7 | ╚██████╗██║ ██║██║ ██║╚██████╔╝███████║ 8 | ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝ 9 | 10 | * it must be sensitive to initial conditions 11 | * it must be topologically mixing 12 | * its periodic orbits must be dense." 13 | (:use [overtone.live] 14 | [cassiopeia.samples] 15 | [cassiopeia.engine.buffers] 16 | [cassiopeia.warm-up]) 17 | (:require [mud.timing :as timing] 18 | [launchpad.sequencer :as lp-sequencer] 19 | [cassiopeia.engine.mixers :as m] 20 | [overtone.inst.synth :as s] 21 | [overtone.synths :as syn] 22 | 23 | [monome.core :as mon] 24 | [monome.fonome :as fon] 25 | [monome.polynome :as poly] 26 | [monome.kit.sampler :as samp] 27 | [cassiopeia.engine.monmapper :as monmapper] 28 | [cassiopeia.engine.monome-sequencer :as monome-sequencer])) 29 | 30 | ;;;;;;;;;;;;;;; 31 | ;;Instruments;; 32 | ;;;;;;;;;;;;;;; 33 | (do 34 | (defn fade 35 | "Fade amplitude out over time" 36 | [node start rate] 37 | (loop [vol start] 38 | (when (>= vol 0) 39 | (println vol) 40 | (Thread/sleep 200) 41 | (ctl node :amp vol) 42 | (recur (- vol rate))))) 43 | 44 | (defn over-time 45 | "Over time change val of `field` to end" 46 | [node field start end rate] 47 | (loop [vol start] 48 | (when (>= vol end) 49 | (println vol) 50 | (Thread/sleep 200) 51 | (ctl node field vol) 52 | (recur (- vol rate))))) 53 | 54 | (defn sputter 55 | "returns a sequence of length maxlen with the items partly repeated (random choice of given probability)." 56 | ([list] (sputter list 0.5 100 [])) 57 | ([list prob] (sputter list prob 100 [])) 58 | ([list prob max] (sputter list prob max [])) 59 | ([[head & tail] prob max-length result] 60 | (if (and head (< (count result) max-length)) 61 | (if (< (rand) prob) 62 | (recur (cons head tail) prob max-length (conj result head)) 63 | (recur tail prob max-length (conj result head))) 64 | result))) 65 | 66 | (def pitch-pattern (sputter [62 64 65 67 69 71 72 74 76])) 67 | 68 | (def detune-buf (buffer (count pitch-pattern))) 69 | (def notes-buf (buffer (count pitch-pattern))) 70 | 71 | (def space-and-time-sun (load-sample "~/Workspace/music/samples/chaos.wav")) 72 | 73 | (def pinging (load-sample "~/Workspace/music/samples/pinging.wav")) 74 | 75 | (defsynth granulate [in-buf 0 amp 1] 76 | (let [trate (mouse-y:kr 2 120 1) 77 | b in-buf 78 | dur (/ 1.2 trate) 79 | src (t-grains:ar :num-channels 1 80 | :trigger (impulse:ar trate) 81 | :bufnum b 82 | :rate 1 83 | :center-pos (mouse-x:kr 0 (buf-dur b)) 84 | :dur dur 85 | :pan (* 0.6 (white-noise:kr)) 86 | :amp amp)] 87 | (out 0 src))) 88 | 89 | (defsynth noisemator [in-bus 0 out-bus 0] 90 | (let [f (in:ar in-bus)] 91 | (out out-bus (lf-noise1:ar f)))) 92 | 93 | (def main-b (audio-bus)) 94 | 95 | (comment 96 | (sample-player space-and-time-sun :out-bus main-b :loop? 1)) 97 | 98 | (defsynth playit [in-bus 0 out-bus 0 amp 1] 99 | (let [src (in:ar in-bus 1) 100 | n (lf-noise0)] 101 | (out [0 1] (* amp n src) ))) 102 | 103 | (comment 104 | (def noisey (playit :in-bus main-b)) 105 | 106 | (ctl noisey :amp 0.9)) 107 | 108 | (defsynth glitchift [amp 1 out-bus 0] 109 | (let [l (local-in:ar 2) 110 | k (+ 1 (* l (lf-saw:ar l 0))) 111 | j (range-lin k 0.25 4.0) 112 | s (pitch-shift:ar (sin-osc-fb (pow j [l k]) k) [0.05 0.03] j)] 113 | (local-out:ar s) 114 | (out out-bus (* amp (pan2 s))))) 115 | 116 | (defsynth drone [amp 1 out-bus 0 f1 1 f2 1] 117 | (let [l (local-in:ar 2) 118 | k (+ 1 (* l (lf-saw:ar l 0))) 119 | j (range-lin:ar 0.2 10.0) 120 | s (pitch-shift (sin-osc-fb:ar (pow j [f1 f2]) k) [0.05 0.03] j)] 121 | (local-out:ar s) 122 | (out out-bus (* amp (pan2 (free-verb s :room 1 :damp 1 :mix 1)))))) 123 | 124 | (defsynth phasing-ping [out-bus 0 amp 0.1 gate 1] 125 | (let [cnt (in:kr timing/beat-count-b) 126 | detune (buf-rd:kr 1 detune-buf cnt) 127 | note (buf-rd:kr 1 notes-buf cnt) 128 | freq (midicps note) 129 | 130 | trig (t-duty:kr (dseq [1/8] INFINITE)) 131 | freqd (demand:kr trig 0 (drand freq INFINITE)) 132 | 133 | env (env-gen:ar (env-perc (ranged-rand 0.001 0.01) (lin-rand 0.2 0.4) amp (ranged-rand -9 -1) FREE) trig) 134 | snd (mix (sin-osc:ar (+ freqd [0 (* 0.2 detune)]) (* 2 Math/PI env)))] 135 | (out out-bus (pan2:ar (* snd env amp) (t-rand:kr -1 1 trig))))) 136 | 137 | (defonce p-g (group "Group for p2s")) 138 | (defsynth p2 [out-bus 0 group-size 5 idx 0 amp 1] 139 | (let [b-trig (in:kr timing/beat-b) 140 | cnt (in:kr timing/beat-count-b) 141 | detune (buf-rd:kr 1 detune-buf cnt) 142 | note (buf-rd:kr 1 notes-buf cnt) 143 | freq (midicps note) 144 | 145 | lin-detune (lin-lin detune 62 76 1 9) 146 | 147 | trg (and b-trig (= 0 (mod (+ (rand-int 2) idx cnt) group-size))) 148 | freq (latch freq trg) 149 | 150 | env (env-gen (env-adsr :sustain (+ 1 (/ (lin-lin note 62 76 1 9) 1)) 151 | :attack (t-rand:kr 0.001 0.01 trg) 152 | :release (t-rand:kr 0.2 0.4 trg) amp (t-rand:kr -9 -1 trg)) trg) 153 | snd (mix (sin-osc:ar (+ freq [0 (* 0.1 lin-detune)]) (* 2 Math/PI env)))] 154 | (out out-bus (pan2:ar (* amp env snd) (t-rand:kr -1 1 trg) )))) 155 | 156 | (comment 157 | (show-graphviz-synth p2) 158 | (dotimes [x 16] (p2 [:head p-g] 0 16 x)) 159 | 160 | (ctl timing/root-s :rate 190) 161 | 162 | (kill p-g) 163 | (stop) 164 | ) 165 | 166 | (def drum-buf (buffer 4)) 167 | (def factor-buf (buffer 3)) 168 | 169 | (defsynth growing-drum-beat [amp 1 out-bus 0 speed 2 pop-speed 1 m 0 r 0 d 0] 170 | (let [mod (+ (* (+ 128 (* 32 (saw:ar 1))) 171 | (saw:ar [(* pop-speed 3) (* pop-speed 4)])) 172 | (duty:ar 1 0 (map vector (* (dseq [0 8 1 5]) [1 4 8])))) 173 | snd (/ (sin-osc:ar (+ 99 (* 64 (saw:ar speed))) mod) 9) 174 | src (comb-n snd 1/4 (/ 1 4.125) (range-lin (sin-osc:kr 0.005 (* 1.5 Math/PI)) 0 6))] 175 | (out out-bus (* amp (free-verb src m r d))))) 176 | 177 | (defsynth drum-beat [amp 1 out-bus 0 speed 0.005 pop-speed 1 m 0 r 0 d 0] 178 | (let [mod (* (+ 128 (* 32 (saw:ar 1))) (saw:ar [(* pop-speed 3) (* pop-speed 4)])) 179 | snd (/ (sin-osc:ar (+ 99 (* 64 (saw:ar 2))) mod) 9) 180 | src (comb-n snd 1/4 (/ 1 4.125) (range-lin (sin-osc:kr speed (* 1.5 Math/PI)) 0 6))] 181 | (out out-bus (* amp (free-verb src m r d))))) 182 | 183 | (comment 184 | (def d (drum-beat)) 185 | (def gd (growing-drum-beat)) 186 | 187 | (ctl d :speed 0.005) 188 | (ctl d :pop-speed 0) 189 | 190 | (ctl d :d 0 :m 0 :r 0) 191 | (ctl d :d 1 :m 1 :r 0.5) 192 | 193 | (over-time d :d 1 0.1 0) 194 | 195 | (kill drum-beat) 196 | ) 197 | 198 | (def count-buf (buffer 8)) 199 | 200 | (defsynth flow [out-bus 0 cnt 1 amp 1 jump 99] 201 | (let [del (* 1 (delay-n:ar (in-feedback:ar 0 2) (in-feedback:ar 100 2) 1)) 202 | src (/ (sin-osc:ar (+ (* cnt jump) [0 2]) (range-lin del 1 0)) 4)] 203 | (out out-bus (* amp (pan2 src) (line 2 0 16 FREE))))) 204 | 205 | (comment 206 | (flow :cnt 1 :jump (* 60)) 207 | (kill flow) 208 | ) 209 | 210 | (defsynth pluckey [out-bus 0 amp 1] 211 | (let [snd (pluck:ar (crackle:ar [1.9 1.8]) (mix (impulse:ar [(+ 1 (lin-rand 0 5)) (+ 1 (lin-rand 0 5))] -0.125)) 0.05 (lin-rand 0 0.05)) 212 | src (bpf:ar snd (+ 100 (ranged-rand 0 2000) (lin-rand 0.25 1.75)))] 213 | (out 62 src))) 214 | 215 | (defsynth pluckey-wrapping [out-bus 0 amp 1] 216 | (let [src (* (in-feedback:ar 62 2) (range-lin (sin-osc:kr 0.006) 0.25 1))] 217 | (out out-bus (* amp src)))) 218 | 219 | (defsynth noise-wind [out-bus 0 amp 1] 220 | (let [lfos (lf-noise1:ar 0.5) 221 | snd (crackle:ar (range-lin lfos 1.8 1.98)) 222 | src (formlet:ar snd (lag (t-exp-rand:ar 200 2000 lfos) 2) (range-lin lfos 5e-4 1e-3) 0.0012)] 223 | (out out-bus (* amp src)))) 224 | 225 | (declare drum-t) 226 | 227 | (defonce pops-fon (monmapper/bind m128 ::pops 14 7 228 | {:on #(ctl drum-t :pop-speed 1) 229 | :off #(ctl drum-t :pop-speed 0)})) 230 | 231 | (defonce beaty-fon (monmapper/bind m128 ::beaty 13 7 232 | {:on #(ctl drum-t :speed 2) 233 | :off #(ctl drum-t :speed 0)}))) 234 | 235 | ;;;;;;;;; 236 | ;;Score;; 237 | ;;;;;;;;; 238 | 239 | (def grain-g (group "grains")) 240 | (def grainy (granulate [:head grain-g] :in-buf (buffer-mix-to-mono chaos-s) :amp 0)) 241 | (kill grain-g) 242 | 243 | (ctl grain-g :amp 0.4) 244 | (def d (drone :amp 0.2)) 245 | (ctl d :f1 0.5 :f2 1 :amp 0.2) 246 | (ctl d :f2 0.5 :f1 1 :amp 0.2) 247 | (ctl d :f1 1) 248 | (ctl d :f2 1) 249 | 250 | (ctl d :f1 0.1) 251 | (ctl d :f2 0.1) 252 | (kill drone) 253 | 254 | (fade d 0.2 0.01) 255 | 256 | (def dark (syn/dark-sea-horns :amp 0.04)) 257 | (ctl dark :amp 0.01) 258 | 259 | (kill dark) 260 | 261 | (def drum-t (growing-drum-beat :amp 0.5)) 262 | (ctl drum-t :amp 0.0) 263 | 264 | (ctl drum-t :speed 0) 265 | (ctl drum-t :speed 1) 266 | (ctl drum-t :speed 2) 267 | 268 | (ctl drum-t :pop-speed 2) 269 | 270 | (ctl drum-t :speed 0) 271 | 272 | (ctl drum-t :d 0 :m 0 :r 0) 273 | (ctl drum-t :d 1 :m 1 :r 0.5) 274 | (over-time drum-t :d 1 0.1 0) 275 | 276 | (glitchift :amp 0.2) 277 | (kill glitchift) 278 | 279 | (do 280 | (pluckey) 281 | (pluckey-wrapping :amp 0.11)) 282 | (kill pluckey-wrapping) 283 | 284 | (buffer-write! detune-buf pitch-pattern) 285 | (buffer-write! notes-buf pitch-pattern) 286 | 287 | (buffer-write! notes-buf (take (count pitch-pattern) (repeat (note :G4)))) 288 | (buffer-write! notes-buf (take (count pitch-pattern) (repeat (nth (distinct pitch-pattern) (mod 0 (count (distinct pitch-pattern))))))) 289 | 290 | (dotimes [x 8] (p2 [:head p-g] 0 8 x)) 291 | (kill p-g) 292 | 293 | (ctl timing/root-s :rate 100) 294 | 295 | (phasing-ping :amp 0.4) 296 | (kill phasing-ping) 297 | 298 | (kill drum-t) 299 | (fade dark 0.04 0.01) 300 | 301 | (sample-player chaos-s :amp 0.9 :rate 0.9) 302 | (sample-player pinging) 303 | 304 | (ctl grain-g :amp 0) 305 | (ctl grain-g :amp 0.4) 306 | 307 | (def s (flow :cnt 1 :amp 0.6)) 308 | (def s (flow :cnt 2 :amp 0.6)) 309 | (def s (flow :cnt 3 :amp 0.6)) 310 | (def s (flow :cnt 4 :amp 0.5)) 311 | (def s (flow :cnt 5 :amp 0.5)) 312 | (def s (flow :cnt 6 :amp 0.5)) 313 | (def s (flow :cnt 7 :amp 0.5)) 314 | 315 | (kill flow) 316 | 317 | (noise-wind :amp 0.1) 318 | (kill noise-wind) 319 | 320 | (stop) 321 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/learning.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.mr 2 | (:use overtone.live) 3 | (:use mud.core) 4 | (:use cassiopeia.waves.synths) 5 | (:use cassiopeia.samples) 6 | (:use cassiopeia.engine.buffers) 7 | (:use cassiopeia.dirt) 8 | (:require [mud.timing :as time] 9 | [clojure.math.numeric-tower :as math] 10 | [overtone.studio.fx :as fx])) 11 | 12 | (ctl time/root-s :rate 8.) 13 | 14 | (defonce note1-dur-b (buffer 256)) 15 | 16 | (defonce w-note-b (buffer 256)) 17 | (defonce w-note2-b (buffer 256)) 18 | (defonce w-release-b (buffer 256)) 19 | (definst deep-basz2 [amp 1 20 | notes-buf 0 21 | noise-level 0.05 22 | beat-trg-bus (:beat time/beat-4th) 23 | beat-bus (:count time/beat-4th) 24 | attack 0.4 25 | release 0.9 26 | sustain 1 27 | decay 1 28 | saw-cutoff 300 29 | wave 0] 30 | (let [trg (in:kr beat-trg-bus) 31 | cnt (in:kr beat-bus) 32 | note (buf-rd:kr 1 notes-buf cnt) 33 | ;; release 34 | gate-trg (and (> note 0) trg) 35 | freq (midicps note) 36 | noize (* noise-level (pink-noise)) 37 | wave (select:ar wave [(saw freq) (pulse freq) (mix [(saw freq) (pulse freq)])]) 38 | src (mix [(lpf wave saw-cutoff) 39 | (lpf noize 100)]) 40 | src (g-verb src 200 1 0.2) 41 | e (env-gen (adsr :attack attack :sustain sustain :decay decay :release release) :gate gate-trg) 42 | amp (+ (* amp 5) amp)] 43 | (* amp e src))) 44 | 45 | 46 | 47 | (definst deep-basz [amp 1 48 | notes-buf 0 49 | noise-level 0.05 50 | beat-trg-bus (:beat time/beat-4th) 51 | beat-bus (:count time/beat-4th) 52 | attack 0.4 53 | release 0.9 54 | saw-cutoff 300 55 | wave 0] 56 | (let [trg (in:kr beat-trg-bus) 57 | cnt (in:kr beat-bus) 58 | note (buf-rd:kr 1 notes-buf cnt) 59 | ;; release 60 | gate-trg (and (> note 0) trg) 61 | freq (midicps note) 62 | noize (* noise-level (pink-noise)) 63 | wave (select:ar wave [(saw freq) (pulse freq) (mix [(saw freq) (pulse freq)])]) 64 | src (mix [(lpf wave saw-cutoff) 65 | (lpf noize 100)]) 66 | src (g-verb src 200 1 0.2) 67 | e (env-gen (perc attack release) :gate gate-trg) 68 | amp (+ (* amp 5) amp) 69 | ] 70 | (* amp e src))) 71 | 72 | (kill deep-basz) 73 | 74 | (defonce w-note3-b (buffer 256)) 75 | 76 | (defonce w-note4-b (buffer 256)) 77 | (def per-per (deep-basz :amp 0.0 :noise-level 0.05 78 | :notes-buf w-note4-b 79 | :beat-trg-bus (:beat time/beat-1th) 80 | :beat-bus (:count time/beat-1th) 81 | :attack 0.1 82 | :release 1.5 83 | :saw-cutoff 700 84 | :wave 1)) 85 | 86 | (kill deep-basz) 87 | (defonce w-note5-b (buffer 256)) 88 | 89 | (do 90 | ;; (kill deep-basz) 91 | 92 | ;;(ctl slow-deep :saw-cutoff 200) 93 | ;;(ctl highlight-deep :saw-cutoff 500) 94 | ;;(kill highlight-deep) 95 | 96 | 97 | (pattern! w-note4-b [(degrees [1] :major :F4) 0 (degrees [4] :major :F4) (degrees [6] :major :F4) (degrees [4] :major :F4) (degrees [6] :major :F4) (degrees [3] :major :F4) 0 ]) 98 | 99 | ) 100 | 101 | (comment 102 | (stop) 103 | (ctl sd-g :release 0.0 :attack 0.0 :beat-trg-bus (:beat time/beat-1th) :beat-bus (:count time/beat-1th) :amp 0) 104 | (ctl apeg-deep :saw-cutoff 300) 105 | 106 | (ctl time/root-s :rate 0) 107 | (kill drums-g) 108 | 109 | (map #(ctl %1 :saw-cutoff 600 :amp 0.2) slow-deep-chord-group) 110 | (map #(ctl %1 :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) slow-deep-chord-group) 111 | 112 | (map #(ctl %1 :saw-cutoff 1500 :noise-level 0.5 :amp 0.5 :attack 0.8 :release 20.0 :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th)) slow-deep-chord-group) 113 | (map #(ctl %1 :saw-cutoff 2000 :noise :amp 0.05) slow-deep-chord-group) 114 | 115 | ) 116 | (def slow-deep-chord-group 117 | (do 118 | ;;(kill deep-basz2) 119 | (defonce sd-g (group "slow deep chords")) 120 | (defonce sd-note1-b (buffer 256)) 121 | (defonce sd-note2-b (buffer 256)) 122 | (defonce sd-note3-b (buffer 256)) 123 | (defonce sd-note4-b (buffer 256)) 124 | [(deep-basz2 [:head sd-g] :saw-cutoff 0 :attack 0.3 :release 6.0 :amp 0.1 :noise-level 0.05 :notes-buf sd-note1-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 125 | (deep-basz2 [:head sd-g] :saw-cutoff 0 :attack 0.3 :release 6.0 :amp 0.1 :noise-level 0.05 :notes-buf sd-note2-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 126 | (deep-basz2 [:head sd-g] :saw-cutoff 0 :attack 0.3 :release 6.0 :amp 0.1 :noise-level 0.05 :notes-buf sd-note3-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 127 | (deep-basz2 [:head sd-g] :saw-cutoff 0 :attack 0.3 :release 6.0 :amp 0.1 :noise-level 0.05 :notes-buf sd-note4-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th))])) 128 | 129 | (def fast-deep-chord-group 130 | [(deep-basz [:head sd-g] :wave 1 :saw-cutoff 2000 :attack 0.2 :release 0.3 :amp 0.1 :noise-level 0.05 :notes-buf sd-note1-b :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th)) 131 | (deep-basz [:head sd-g] :wave 1 :saw-cutoff 2000 :attack 0.2 :release 0.3 :amp 0.1 :noise-level 0.05 :notes-buf sd-note2-b :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th)) 132 | (deep-basz [:head sd-g] :wave 1 :saw-cutoff 2000 :attack 0.2 :release 0.3 :amp 0.1 :noise-level 0.05 :notes-buf sd-note3-b :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th)) 133 | (deep-basz [:head sd-g] :wave 1 :saw-cutoff 2000 :attack 0.2 :release 0.3 :amp 0.1 :noise-level 0.05 :notes-buf sd-note4-b :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th))]) 134 | 135 | (let [_ [0 0 0 0] 136 | [c21 c22 c23 c24 c25 c26 c27] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 137 | [f21 f22 f23 f24 f25 f26 f27] (map #(chord-degree %1 :F2 :major 4) [:i :ii :iii :iv :v :vi :vii]) 138 | [fm21 fm22 fm23 fm24 fm25 fm26 fm27] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 139 | [f31 f32 f33 f34 f35 f36 f37] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 140 | [f41 f42 f43 f44 f45 f46 f47] (map #(chord-degree %1 :F4 :major 4) [:i :ii :iii :iv :v :vi :vii])] 141 | (let [chord-pat 142 | [ 143 | c21 _ 144 | c23 _ 145 | c24 _ 146 | c23 c25 147 | 148 | c21 _ 149 | c23 _ 150 | c24 _ 151 | c25 c27 152 | ]] 153 | (let [chord-bufs (shuffle [sd-note1-b sd-note2-b sd-note3-b sd-note4-b])] ;; Play around with some random inversions 154 | (dotimes [chord-idx (count chord-bufs)] 155 | (pattern! (nth chord-bufs chord-idx) (map #(if (> (count %1) chord-idx) (nth %1 chord-idx) 0) chord-pat)))))) 156 | 157 | 158 | (do 159 | (doseq [chord-g slow-deep-chord-group] (ctl chord-g :saw-cutoff 3000 :amp 0.7 :attack 0.6 :noise-level 0 :sustain 10.0 :decay 10.0 :release 10.0 :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-8th))) 160 | (ctl per-per :amp 0.4)) 161 | 162 | (do (defonce drums-g (group "drums")) (defonce drum-effects-g (group "drums effects for extra sweetness")) (defbufs 128 [bass-notes-buf bass-notes2-buf hats-buf kick-seq-buf white-seq-buf effects-seq-buf effects2-seq-buf bass-notes-buf])) 163 | 164 | (do 165 | (def kicker (doseq [i (range 0 96)] (kick2 [:head drums-g] :note-buf bass-notes-buf :seq-buf kick-seq-buf :num-steps 96 :beat-num i :noise 0.05 :amp 4.2 :mod-index 0.4 :mod-freq 21.0 :mode-freq 20))) 166 | 167 | (def white (doall (map 168 | #(whitenoise-hat 169 | [:head drums-g] 170 | :amp 5.5 171 | :seq-buf white-seq-buf 172 | :beat-bus (:count time/beat-1th) 173 | :beat-trg-bus (:beat time/beat-1th) 174 | :num-steps 24 175 | :beat-num %1) (range 0 24)))) 176 | 177 | (pattern! white-seq-buf [1]) 178 | 179 | (pattern! white-seq-buf [0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0]) 180 | (pattern! kick-seq-buf [1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0]) 181 | 182 | (pattern! bass-notes-buf (degrees [3] :major :F1))) 183 | 184 | 185 | ;;BEGIN 186 | ;;3 voices 187 | 188 | ;;Drums enter + melody 189 | ;;High voice enters 190 | ;;Drums stop, rising tension 191 | ;;Drums kick back in, background note pushing 192 | ;;Drumsdrop 193 | ;;END 194 | (stop) 195 | 196 | (kill slow-deep-chord-group) 197 | (kill fast-deep-chord-group) 198 | 199 | (let [_ [0 0 0 0] 200 | [c21 c22 c23 c24 c25 c26 c27] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 201 | [f21 f22 f23 f24 f25 f26 f27] (map #(chord-degree %1 :F2 :major 4) [:i :ii :iii :iv :v :vi :vii]) 202 | [fm21 fm22 fm23 fm24 fm25 fm26 fm27] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 203 | [f31 f32 f33 f34 f35 f36 f37] (map #(chord-degree %1 :F3 :major 4) [:i :ii :iii :iv :v :vi :vii]) 204 | [f41 f42 f43 f44 f45 f46 f47] (map #(chord-degree %1 :F4 :major 4) [:i :ii :iii :iv :v :vi :vii])] 205 | (let [chord-pat 206 | [ 207 | c23 c23 c23 c23 c21 c23 c23 c24 c21 208 | c24 c24 c24 c24 c25 c27 c27 c24 c21 209 | ]] 210 | (let [chord-bufs (shuffle [sd-note1-b sd-note2-b sd-note3-b sd-note4-b])] ;; Play around with some random inversions 211 | (dotimes [chord-idx (count chord-bufs)] 212 | (pattern! (nth chord-bufs chord-idx) (map #(if (> (count %1) chord-idx) (nth %1 chord-idx) 0) chord-pat)))))) 213 | 214 | (def melody [(deep-basz [:head sd-g] :wave 0 :saw-cutoff 800 :attack 1.9 :release 0.6 :amp 0.2 :noise-level 0.05 :notes-buf sd-note1-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 215 | (deep-basz [:head sd-g] :wave 1 :saw-cutoff 800 :attack 1.9 :release 0.6 :amp 0.2 :noise-level 0.05 :notes-buf sd-note2-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 216 | (deep-basz [:head sd-g] :wave 0 :saw-cutoff 800 :attack 1.9 :release 0.6 :amp 0.2 :noise-level 0.05 :notes-buf sd-note3-b :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th)) 217 | (deep-basz [:head sd-g] :wave 1 :saw-cutoff 800 :attack 1.9 :release 0.6 :amp 0.2 :noise-level 0.05 :notes-buf sd-note4-b :beat-trg-bus (:beat time/beat-8th) :beat-bus (:count time/beat-4th))]) 218 | 219 | (do 220 | (map #(ctl %1 :amp 0) (flatten [melody])) 221 | (ctl drums-g :amp 0) 222 | 223 | (ctl per-per :beat-bus (:count time/beat-2th) :beat-trg-bus (:count time/beat-2th) :release 10 :attack 0.01) 224 | 225 | (pattern! w-note4-b (degrees [1] :major :F4 ) 0 226 | (degrees [3] :major :F4) 0 227 | (degrees [4] :major :F4) 0 228 | (degrees [3] :major :F4) (degrees [5] :major :F4) 229 | 230 | (degrees [1] :major :F4) 0 231 | (degrees [3] :major :F4) 0 232 | (degrees [4] :major :F4) 0 233 | (degrees [5] :major :F4) (degrees [7] :major :F4) 234 | )) 235 | 236 | (stop) 237 | -------------------------------------------------------------------------------- /src/cassiopeia/warm_up.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.warm-up 2 | (:use 3 | [overtone.live] 4 | [overtone.helpers.lib :only [uuid]] 5 | [nano-kontrol2.config :only [mixer-init-state basic-mixer-init-state]] 6 | [cassiopeia.samples]) 7 | (:require 8 | [launchpad.core :as lp-core] 9 | [launchpad.plugin.metronome :as metronome] 10 | [launchpad.plugin.beat :as beat] 11 | [launchpad.plugin.beat-scroll :as beat-scroll] 12 | 13 | [launchpad.plugin.sample-rows :as sr] 14 | 15 | [launchpad.sequencer :as lp-sequencer] 16 | 17 | [nano-kontrol2.core :as nk2] 18 | [nano-kontrol2.buttons :as btn] 19 | 20 | [monome.core :as mon] 21 | [monome.fonome :as fon] 22 | [monome.polynome :as poly] 23 | [monome.kit.sampler :as samp] 24 | [cassiopeia.engine.monome-sequencer :as monome-sequencer] 25 | 26 | [mud.timing :as timing] 27 | [cassiopeia.engine.sequencer :as sequencer] 28 | [cassiopeia.engine.mixers :as mixers])) 29 | 30 | (do 31 | (defonce default-mixer-g (group :tail (foundation-safe-post-default-group))) 32 | (def drum-g (group "Drums")) 33 | (defonce drum-trigger-mix-g (group "Drum triggers" :after drum-g)) 34 | (defonce drum-basic-mixer-g (group "Drum basic mix" :after default-mixer-g)) 35 | (def samples-set-1 (take 10 (cycle [tom-s]))) 36 | 37 | (defn nk-bank 38 | "Returns the nk bank number for the specified bank key" 39 | [bank-k] 40 | (case bank-k 41 | :master btn/record 42 | :lp64 btn/play 43 | :m128 btn/stop 44 | :riffs btn/fast-forward 45 | :synths btn/rewind))) 46 | 47 | (def cfg 48 | {:synths {:s0 mixer-init-state :s1 mixer-init-state :s2 mixer-init-state :m0 mixer-init-state :m1 mixer-init-state :r0 mixer-init-state :r7 basic-mixer-init-state} 49 | :riffs {:s0 mixer-init-state :s1 mixer-init-state :m0 mixer-init-state :m1 mixer-init-state :r7 basic-mixer-init-state} 50 | :master {:s7 mixer-init-state :m7 mixer-init-state :r7 mixer-init-state} 51 | :m128 { 52 | :s0 ["m128-0" mixer-init-state] 53 | :m0 ["m128-1" mixer-init-state] 54 | :r0 ["m128-2" mixer-init-state] 55 | :s1 ["m128-3" mixer-init-state] 56 | :m1 ["m128-4" mixer-init-state] 57 | :r1 ["m128-5" mixer-init-state] 58 | :s2 ["m128-6" mixer-init-state] 59 | :r2 ["m128-7" mixer-init-state] 60 | :m2 ["m128-8" mixer-init-state] 61 | :s3 ["m128-9" mixer-init-state] 62 | } 63 | :lp64 { 64 | ;;Beats 65 | :s0 ["lp64-0" mixer-init-state] 66 | :m0 ["lp64-1" mixer-init-state] 67 | :r0 ["lp64-2" mixer-init-state] 68 | :s1 ["lp64-3" mixer-init-state] 69 | :m1 ["lp64-4" mixer-init-state] 70 | :r1 ["lp64-5" mixer-init-state] 71 | :s2 ["lp64-6" mixer-init-state] 72 | :r2 ["lp64-7" mixer-init-state] 73 | :m2 ["lp64-8" mixer-init-state] 74 | :s3 ["lp64-9" mixer-init-state] 75 | 76 | :m3 ["lp64-triggers" mixer-init-state] 77 | :r7 ["lp64-master" basic-mixer-init-state] 78 | 79 | ;;Row mapped samples 80 | :s4 ["lp64-seq-0" mixer-init-state] 81 | :m4 ["lp64-seq-1" mixer-init-state] 82 | :r4 ["lp64-seq-2" mixer-init-state] 83 | :s5 ["lp64-seq-3" mixer-init-state] 84 | :m5 ["lp64-seq-4" mixer-init-state] 85 | :r5 ["lp64-seq-5" mixer-init-state] 86 | :s6 ["lp64-seq-6" mixer-init-state] 87 | :m6 ["lp64-seq-7" mixer-init-state]}}) 88 | 89 | (def banks 90 | {:master btn/record 91 | :lp64 btn/play 92 | :m128 btn/stop 93 | :riffs btn/fast-forward 94 | :synths btn/rewind}) 95 | 96 | (try 97 | (lp-core/boot!) 98 | (catch Exception e 99 | (println "LP not connected"))) 100 | 101 | (try 102 | (nk2/start! banks cfg) 103 | (def lp (first lp-core/launchpad-kons)) 104 | (catch Exception e 105 | (def lp []) 106 | (println "NK2 not connected"))) 107 | 108 | (def phrase-size 8) 109 | 110 | (when-not (seq lp) 111 | (defonce seq-b (audio-bus 2 "basic-mixer")) 112 | (defonce bas-mix-seq (mixers/basic-mixer [:head drum-basic-mixer-g] :in-bus seq-b :mute 0)) 113 | (defonce trig-seq-mixer (mixers/add-nk-mixer (nk-bank :lp64) "lp64-triggers" drum-trigger-mix-g seq-b)) 114 | ;;(ctl bas-mix-seq :mute 1) 115 | 116 | (def sequencer-64 117 | (sequencer/mk-sequencer 118 | (nk-bank :lp64) 119 | "seq" 120 | samples-set-1 121 | phrase-size 122 | drum-g 123 | (atom timing/main-beat) 124 | seq-b))) 125 | 126 | (when (seq lp) 127 | (defonce beat-rep-key (uuid)) 128 | (metronome/start lp :mixer timing/count-trig-id beat-rep-key) 129 | 130 | (defonce lp64-b (audio-bus 2 "lp64 basic-mixer")) 131 | (defonce bas-mix-s64 (mixers/basic-mixer [:head drum-basic-mixer-g] :in-bus lp64-b :mute 0)) 132 | (defonce trig64-mixer (mixers/add-nk-mixer (nk-bank :lp64) "lp64-triggers" drum-trigger-mix-g lp64-b)) 133 | 134 | ;; (ctl bas-mix-s64 :mute 1) 135 | 136 | (defonce sequencer-64 137 | (sequencer/mk-sequencer 138 | (nk-bank :lp64) 139 | "lp64" 140 | samples-set-1 141 | phrase-size 142 | drum-g 143 | (atom timing/main-beat) 144 | lp64-b)) 145 | 146 | (defonce refresh-beat-key (uuid)) 147 | 148 | (on-trigger timing/count-trig-id (beat-scroll/grid-refresh lp sequencer-64 phrase-size :up) refresh-beat-key) 149 | (beat/setup-side-controls :up sequencer-64) 150 | 151 | ;;Adjust bpm 152 | (lp-core/bind :up :7x6 (fn [] (ctl timing/divider-s :div (swap! timing/current-beat inc)))) 153 | (lp-core/bind :up :7x5 (fn [] (ctl timing/divider-s :div (swap! timing/current-beat dec)))) 154 | 155 | ;;Shutdown 156 | (lp-core/bind :up :arm (fn [lp] 157 | (ctl bas-mix-s64 :mute 0) 158 | (beat/off lp sequencer-64))) 159 | 160 | 161 | ;; (ctl bas-mix-s64 :mute 1) 162 | 163 | (defonce seq-g (group)) 164 | (def seq-mixer-group (group "lp-mixers" :after seq-g)) 165 | (defonce seq-trigger-mix-g (group :after seq-g)) 166 | (defonce seq-basic-mixer-g (group :after default-mixer-g)) 167 | (defonce seq-mix-s64 (mixers/basic-mixer [:head seq-basic-mixer-g] :in-bus lp64-b :mute 0)) 168 | 169 | ;; (ctl seq-mix-s64 :mute 1) 170 | 171 | (def sample-selection []) 172 | 173 | (defonce seq-mixers (vec (doall (map-indexed (fn [idx _] (mixers/add-nk-mixer (nk-bank :lp64) (str "lp64-seq-" idx) seq-mixer-group lp64-b)) sample-selection)))) 174 | ;;(def seq-mixers []) 175 | 176 | (get-in seq-mixers [1]) 177 | 178 | (defonce rate-b (control-bus 1 "Rate")) 179 | (defonce rater-s (sequencer/rater :out-bus rate-b)) 180 | 181 | (def all-row-samples 182 | (doall (map-indexed 183 | (fn [idx sample] {:row idx 184 | :sample sample 185 | :sequencer (sequencer/phasor-skipping-sequencer [:tail seq-g] 186 | :buf (to-sc-id sample) 187 | :loop? true 188 | :bar-trg 0 189 | :amp 0 190 | :beat-b timing/beat-b 191 | :rate-b rate-b 192 | :out-bus (:in-bus (get-in seq-mixers [idx] {:in-bus 0})))}) 193 | sample-selection))) 194 | 195 | (sr/sample-rows lp :left all-row-samples)) 196 | 197 | (defonce synth-bus (audio-bus 2)) 198 | (defonce riffs-bus (audio-bus 2)) 199 | 200 | (defonce mixer-s0 (mixers/add-nk-mixer (nk-bank :synths) :s0 default-mixer-g synth-bus)) 201 | (defonce mixer-s1 (mixers/add-nk-mixer (nk-bank :synths) :s1 default-mixer-g synth-bus)) 202 | (defonce mixer-m0 (mixers/add-nk-mixer (nk-bank :synths) :m0 default-mixer-g synth-bus)) 203 | (defonce mixer-m1 (mixers/add-nk-mixer (nk-bank :synths) :m1 default-mixer-g synth-bus)) 204 | (defonce mixer-s2 (mixers/add-nk-mixer (nk-bank :synths) :s2 default-mixer-g synth-bus)) 205 | (defonce mixer-r0 (mixers/add-nk-mixer (nk-bank :synths) :r0 default-mixer-g synth-bus)) 206 | 207 | (defonce basic-synth-mix (mixers/basic-mixer [:after default-mixer-g] :in-bus synth-bus)) 208 | (defonce basic-riffs-mix (mixers/basic-mixer [:after default-mixer-g] :in-bus riffs-bus)) 209 | 210 | (defonce mixer-riff-s0 (mixers/add-nk-mixer (nk-bank :riffs) :s0 default-mixer-g riffs-bus)) 211 | (defonce mixer-riff-s1 (mixers/add-nk-mixer (nk-bank :riffs) :s1 default-mixer-g riffs-bus)) 212 | (defonce mixer-riff-m0 (mixers/add-nk-mixer (nk-bank :riffs) :m0 default-mixer-g riffs-bus)) 213 | (defonce mixer-riff-m1 (mixers/add-nk-mixer (nk-bank :riffs) :m1 default-mixer-g riffs-bus)) 214 | (defonce mixer-riff-s2 (mixers/add-nk-mixer (nk-bank :riffs) :s2 default-mixer-g riffs-bus)) 215 | (defonce mixer-riff-r0 (mixers/add-nk-mixer (nk-bank :riffs) :r0 default-mixer-g riffs-bus)) 216 | 217 | (on-latest-event [:v-nanoKON2 (nk-bank :synths) :r7 :control-change :slider7] 218 | (fn [{:keys [val]}] 219 | (ctl basic-synth-mix :amp val)) 220 | ::synths-master-amp) 221 | 222 | (on-latest-event [:v-nanoKON2 (nk-bank :riffs) :r7 :control-change :slider7] 223 | (fn [{:keys [val]}] 224 | (ctl basic-riffs-mix :amp val)) 225 | ::riffs-master-amp) 226 | 227 | (defonce m128 (mon/find-monome "/dev/tty.usbserial-m0000965")) 228 | 229 | (when m128 230 | (defonce seq128-fon (fon/mk-fonome ::seq128 16 6)) 231 | (defonce insta-pause128-fon (fon/mk-fonome ::pauser128 1 1)) 232 | (defonce insta-pause-all-fon (fon/mk-fonome ::pauser-all 1 1)) 233 | 234 | (defonce seq-b (audio-bus 2 "basic-mixer")) 235 | (defonce bas-mix-seq (mixers/basic-mixer [:head drum-basic-mixer-g] :in-bus seq-b :mute 0)) 236 | (defonce trig-seq-mixer (mixers/add-nk-mixer (nk-bank :m128) "m128-triggers" drum-trigger-mix-g seq-b)) 237 | (defonce seq128 (monome-sequencer/mk-monome-sequencer (nk-bank :m128) "m128" (take 5 samples-set-1) seq128-fon seq-b drum-g)) 238 | 239 | (defonce samples-g (group "samples")) 240 | (def trigger-samples [star-into-the-sun-s 241 | space-and-time-s 242 | chaos-s 243 | dreamers-of-the-dreams-s 244 | one-moment-please-s 245 | afraid-s 246 | glitch1-s 247 | glitch2-s 248 | pulse-s 249 | boom-s 250 | crunch-woosh-s 251 | collect-coin-s 252 | whisper-s 253 | mystical-aura-s]) 254 | 255 | (defonce trigger-sampler128 (samp/mk-sampler ::trigger-sampler128 trigger-samples samples-g 0 16)) 256 | 257 | (defonce __dock_trigger__ (poly/dock-fonome! m128 (:fonome trigger-sampler128) ::trigger-sampler128 0 6)) 258 | (defonce __dock128___ (poly/dock-fonome! m128 seq128-fon ::seq128 0 0)) 259 | (defonce __dock_pause128__ (poly/dock-fonome! m128 insta-pause128-fon ::pause128 15 7)) 260 | 261 | (on-event [:fonome :led-change (:id insta-pause128-fon)] 262 | (fn [{:keys [x y new-leds]}] 263 | (let [on? (get new-leds [x y])] 264 | (if on? 265 | (ctl bas-mix-seq :mute 1) 266 | (ctl bas-mix-seq :mute 0)))) 267 | ::seq128) 268 | 269 | (on-event [:fonome :press (:id insta-pause128-fon)] 270 | (fn [{:keys [x y fonome]}] 271 | (fon/toggle-led fonome x y)) 272 | ::seq128-press)) 273 | 274 | (comment 275 | (monome-sequencer/swap-samples! seq128 trigger-samples) 276 | ) 277 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/tsih.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.tsih 2 | " 3 | _______ _______ _____ _ _ 4 | | |______ | |_____| 5 | | ______| __|__ | | 6 | 7 | An eruptive variable star, whose brightness changes irregularly between 8 | +2.15 mag and +3.40 mag 9 | " 10 | (:require [mud.timing :as time] 11 | [overtone.studio.fx :as fx] 12 | [cassiopeia.engine.mixers :as mix] 13 | [overtone.inst.synth :as s] 14 | [shadertone.tone :as t]) 15 | (:use [overtone.live] 16 | [cassiopeia.scratch] 17 | [mud.core] 18 | [cassiopeia.samples] 19 | [cassiopeia.view-screen] 20 | [cassiopeia.waves.synths])) 21 | (stop) 22 | 23 | (do 24 | (ctl time/root-s :rate 4) 25 | 26 | (declare p q growl-synth) 27 | 28 | (defonce voice-g (group "main voice")) 29 | (defonce bass-g (group "bass voice")) 30 | (defonce drums-g (group "drums")) 31 | (defonce glass-g (group "glass")) 32 | (defonce mid-glass-g (group "A little more classey glass")) 33 | 34 | (defonce power-kick-seq-buf (buffer 16)) 35 | (defonce kick-seq-buf (buffer 16)) 36 | (defonce pulsar-buf (buffer 128)) 37 | (defonce shrill-buf (buffer 128)) 38 | (defonce growl-buf (buffer 128)) 39 | (defonce mid-ping-notes-buf (buffer 32)) 40 | (defonce mid-ping-seq-buf (buffer 32)) 41 | (defonce bass-notes-buf (buffer 32)) 42 | (defonce ping-bass-seq-buf (buffer 32)) 43 | (defonce phase-bass-buf (buffer 32)) 44 | (defonce white-seq-buf (buffer 24)) 45 | (defonce shrill-dur-buf (buffer 32)) 46 | (defonce fizzy-dur-buf (buffer 128)) 47 | (defonce shrill-pong-buf (buffer 128)) 48 | (defonce shrill-pong-final-buf (buffer 128))) 49 | 50 | (do 51 | (kill high-hats) 52 | (kill quick-kick) 53 | (kill kick2) 54 | 55 | (reset! color-l 0.9) 56 | (reset! color-r 0.9) 57 | 58 | (pattern! phase-bass-buf (repeat 3 [0 0 1 1 0 0]) [0 0 1 0 1 0]) 59 | (pattern! bass-notes-buf [:A1]) 60 | 61 | (def hats 62 | (doall (map #(high-hats 63 | [:head drums-g] 64 | :amp 0.7 65 | :mix (nth (take 32 (cycle [0.02 0.2])) %1) 66 | :room 2 67 | ;;:damp 0.6 68 | :note-buf bass-notes-buf 69 | :seq-buf phase-bass-buf 70 | :beat-bus (:count time/beat-1th) 71 | :beat-trg-bus (:beat time/beat-1th) :num-steps 32 :beat-num %1) (range 0 32)))) 72 | (ctl hats :damp 0.6) 73 | 74 | (def qk 75 | (doall (map 76 | #(quick-kick 77 | [:head drums-g] 78 | :amp 0.5 79 | :note-buf bass-notes-buf 80 | :seq-buf power-kick-seq-buf 81 | :beat-bus (:count time/beat-1th) 82 | :beat-trg-bus (:beat time/beat-1th) :num-steps 16 :beat-num %1) (range 0 16)))) 83 | 84 | (pattern! power-kick-seq-buf [0 0 1 0 0 0] (repeat 3 [0 0 0 0 0 0])) 85 | 86 | (doseq [i (range 0 32)] 87 | (kick2 88 | [:head drums-g] 89 | :note-buf bass-notes-buf 90 | :seq-buf kick-seq-buf 91 | :beat-bus (:count time/beat-1th) 92 | :beat-trg-bus (:beat time/beat-1th) 93 | :num-steps 32 94 | :beat-num i)) 95 | 96 | (def s (shrill-pong [:head voice-g] :amp 1.1 :note-buf shrill-pong-buf :duration-bus shrill-dur-buf :beat-bus (:count time/beat-1th) :beat-trg-bus (:beat time/beat-1th))) 97 | 98 | (ctl time/root-s :rate 4) 99 | (pattern! kick-seq-buf (repeat 3 [0 0 1 0 0 0]) 100 | [0 1 1 1 0 0]) 101 | (pattern! white-seq-buf [0])) 102 | 103 | (overtime! res 0.9 0.01) 104 | (ctl time/root-s :rate 0) 105 | 106 | (def white (doall (map 107 | #(whitenoise-hat 108 | [:head drums-g] 109 | :amp (+ 0.1 (/ %1 10)) 110 | :seq-buf white-seq-buf 111 | :beat-bus (:count time/beat-1th) 112 | :beat-trg-bus (:beat time/beat-1th) 113 | :num-steps 24 114 | :beat-num %1) (range 0 24)))) 115 | 116 | (pattern! white-seq-buf [1]) 117 | (pattern! white-seq-buf [0 0 0 1 1 0] (repeat 3 [0 0 0 0 0 0])) 118 | 119 | (pattern! kick-seq-buf [0 0 1 0 0 1 0 0 1 1]) 120 | 121 | (doall (map #(glass-ping [:head glass-g] :amp 1 :note-buf bass-notes-buf :seq-buf ping-bass-seq-buf :beat-bus (:count time/beat-1th) :beat-trg-bus (:beat time/beat-1th) :num-steps 18 :beat-num %1) (range 0 18))) 122 | 123 | (do 124 | (def mid-pings (doall (map-indexed #(glass-ping [:head mid-glass-g] :amp 1 :note-buf mid-ping-notes-buf :seq-buf mid-ping-seq-buf :beat-bus (:count time/beat-1th) :beat-trg-bus (:beat time/beat-1th) :num-steps 18 :beat-num %2) (range 0 18)))) 125 | 126 | (when (node-live? p) (ctl p :amp 0)) 127 | (when (node-live? q) (ctl q :amp 0)) 128 | 129 | (pattern! mid-ping-seq-buf [0]) 130 | 131 | (pattern! growl-buf [:D3 :D3 :D3 :E3 :E3 :E3 132 | :A4 :A4 :A4 133 | :C#4 :C#4 :C#4 :F#4 :F#4 :F#4]) 134 | (kill glass-g)) 135 | 136 | (pattern! ping-bass-seq-buf [1 1 0 0]) 137 | 138 | (pattern! bass-notes-buf [:A2 :A2 :A4 :A5 :A2 :A6 :A5]) 139 | (pattern! bass-notes-buf [:E2 :E2 :E4 :E5 :E2 :E5 :E4]) 140 | (pattern! bass-notes-buf [:C#2 :C#2 :C#5 :C#6 :C#2 :C#6 :C#5]) 141 | (pattern! bass-notes-buf [:B2 :B2 :B5 :B6 :B2 :B6 :B5]) 142 | 143 | (pattern! bass-notes-buf [:A4 :E4 :E2 :E2 :D5 :D4 144 | :E4 :E4 :A2 :A2 :D5 :D4 145 | :C#5 :C#6 :A2 :E2 :C#6 :C#5]) 146 | 147 | (pattern! bass-notes-buf [:A1 :A1 :A1 :A1 :A1 :A1]) 148 | 149 | (pattern! growl-buf [:D4 :D4 0 :A4 :A4 0]) 150 | 151 | (pattern! power-kick-seq-buf [0 0 0 1]) 152 | (pattern! kick-seq-buf [1 1 0 0]) 153 | (pattern! mid-ping-seq-buf [1 1 0 0]) 154 | (pattern! mid-ping-notes-buf [:A4 :A4 :D4 :D4 :D4 :E4]) 155 | (pattern! mid-ping-notes-buf [:A4 :A4 :D4 :D4 :D4 :E4 156 | 0 0 0 0 0 0 157 | :A4 :A4 :D4 :D4 :D4 :F#4 158 | 0 0 0 0 0 0 159 | :A4 :A4 :D4 :D4 :D4 :F#4 160 | 0 0 0 0 0 0]) 161 | 162 | (pattern! phase-bass-buf [0 1]) 163 | (pattern! phase-bass-buf [1 1 0 0 0 0 0 0]) 164 | 165 | (pattern! kick-seq-buf [1 0 0 0]) 166 | 167 | (def p (pulsar :beat-trg-bus (:beat time/beat-1th) :beat-bus (:count time/beat-1th) :note-buf pulsar-buf :amp 0.7)) 168 | 169 | (def q (shrill-pulsar :beat-trg-bus (:beat time/beat-1th) :beat-bus (:count time/beat-1th) :note-buf shrill-buf :amp 0.7)) 170 | 171 | (overtime! color-r 0.9) 172 | (def dark (dark-ambience :mul 0.2 :amp 0.4 :ring-freq (midi->hz (note :A3)))) 173 | (sing :note 60 :amp 0.09 :pos 1) 174 | (sing :note 60 :amp 0.09 :pos -1) 175 | 176 | (ctl dark :ring-freq (midi->hz (note :A3))) 177 | (s/rise-fall-pad :freq (midi->hz (note :A3))) 178 | 179 | (pattern! growl-buf [:C#3 :C#3 0 :A3 :A3 0 :C#3 :C#3]) 180 | (pattern! growl-buf [:D3 :D3 0 :D3 :D3]) 181 | 182 | (reset! color-l 0.0) 183 | (reset! color-r 0.9) 184 | 185 | (pattern! pulsar-buf [:A3 0 :A3]) 186 | (pattern! pulsar-buf [:E3 0 :E3]) 187 | 188 | (pattern! pulsar-buf [:C#3 0 :C#3]) 189 | (pattern! shrill-buf [0 0 :A3 0 :A3 0]) 190 | (pattern! shrill-pong-buf [0 0 :E3]) 191 | 192 | (pattern! pulsar-buf [:D3 0 :D3]) 193 | (pattern! shrill-buf [0 :F#3 0 :F#3 0]) 194 | (pattern! shrill-pong-buf [0 0 :B3]) 195 | 196 | (def growl-synth (growl [:head bass-g] :amp 1.8 :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th) :note-buf growl-buf)) 197 | 198 | (pattern! pulsar-buf [0]) 199 | (pattern! shrill-buf [0]) 200 | 201 | (def fizzy-p (fizzy-pulsar :beat-trg-bus (:beat time/beat-1th) :beat-bus (:count time/beat-1th) :note-buf pulsar-buf :duration-bus fizzy-dur-buf)) 202 | 203 | (ctl growl-synth :amp 0) 204 | (def g (growler [:head bass-g] :amp 0.8 :beat-trg-bus (:beat time/beat-4th) :beat-bus (:count time/beat-4th) :note-buf growl-buf)) 205 | 206 | (ctl bass-g :beat-bus (:count time/beat-1th) :beat-trg-bus (:beat time/beat-1th)) 207 | 208 | (pattern! growl-buf [:E3 :E3 :E3 :E3 :E3 :E3 209 | :E3 :E3 :E3 :E3 :E3 :E3 210 | :E3 :E3 :E3 :E3 :E3 :E3 211 | :E3 :E3 :E3 :E3 :E3 :E3 212 | 213 | :C#3 :C#3 :C#3 :C#3 :C#3 :C#3 214 | :C#3 :C#3 :C#3 :C#3 :C#3 :C#3 215 | 216 | :F#3 :F#3 :F#3 :F#3 :F#3 :F#3 217 | :F#3 :F#3 :F#3 :F#3 :F#3 :F#3 218 | 219 | :A3 :A3 :A3 :A3 :A3 :A3 220 | :A3 :A3 :A3 :A3 :A3 :A3 221 | 222 | ;; :B3 :B3 :B3 :B3 :B3 :B3 223 | ;; :B3 :B3 :B3 :B3 :B3 :B3 224 | ]) 225 | 226 | (pattern! fizzy-dur-buf [1 1/2 1/2]) 227 | (pattern! pulsar-buf [0 0 :D4 0 0 :D4 228 | 0 0 :D4 0 0 :D4 229 | 0 0 :E4 0 0 :E4 230 | :E4 :E4 :E4 0 0 :E4]) 231 | 232 | (pattern! shrill-pong-final-buf 233 | [:G#4 :E4 :D4 :G#4 :E4 :D4 234 | :G#4 :E4 :D4 :G#4 :E4 :A4 235 | 236 | :A4 :E4 :G#4 :A4 :E4 :G#4 237 | :A4 :E4 :G#4 :A4 :E4 :G#4 238 | 239 | :A5 :E5 :G#5 :A5 :E5 :G#5 240 | :A5 :E5 :G#5 :A5 :E5 :G#5 241 | 242 | :G#4 :E4 :D4 :G#4 :E4 :D4 243 | :G#4 :E4 :D4 :G#4 :E4 :A4 244 | 245 | :A4 :E4 :G#4 :A4 :E4 :G#4 246 | :A4 :E4 :G#4 :A4 :E4 :G#4 247 | :A4 :E4 :G#4 :A4 :E4 :G#4 248 | :A4 :E4 :G#4 :A4 :E4 :G#4 249 | 250 | :B5 :E5 :G#5 :A5 :E5 :G#5 251 | :B5 :E5 :G#5 :A5 :E5 :G#5]) 252 | 253 | (pattern! shrill-pong-final-buf 254 | [:A4 :E4 :G#4 :A4 :E4 :G#4 255 | :A4 :E4 :G#4 :A4 :E4 :G#4]) 256 | 257 | (pattern! shrill-pong-final-buf 258 | [:G#3 :E3 :D3 :G#3 :E3 :D3 259 | :G#3 :E3 :D3 :G#3 :E3 :A4 260 | :G#3 :E3 :D3]) 261 | 262 | (ctl glass-g :amp 0) 263 | (ctl mid-glass-g :amp 0) 264 | (kill glass-g) 265 | (kill mid-glass-g) 266 | ;;(kill high-hats) 267 | 268 | (pattern! kick-seq-buf (repeat 3 [1 0 0 1 0 0]) [1 1 0 1 0 1]) 269 | (pattern! white-seq-buf [0 0 0 1 1 0] (repeat 3 [0 0 0 0 0 0])) 270 | (pattern! power-kick-seq-buf [0 0 1 0 0 0] (repeat 3 [0 0 0 0 0 0])) 271 | 272 | ;;(ctl drums-g :amp 0.) 273 | ;;(ctl white :amp 0.4) 274 | 275 | (ctl time/root-s :rate 4) 276 | 277 | (overtime! space 0.9 0.05 ) 278 | (ctl voice-g :note-buf shrill-pong-final-buf) 279 | ;;(ctl s :amp 1.2) 280 | 281 | (pattern! shrill-dur-buf [1/12]) 282 | 283 | (pattern! shrill-dur-buf [1/8 1/16 1/16]) 284 | (pattern! shrill-dur-buf [1/4 1/8 1/8]) 285 | (pattern! shrill-dur-buf [1/2 1/4 1/4]) 286 | 287 | ;;(mono-player moore-s :amp 1 :rate 1) 288 | ;;(echoey-buf :b moore-s) 289 | ;;(spacy moore-s) 290 | ;;(echoey-buf signals-s) 291 | ;;(spacy signals-s :amp 2.3) 292 | 293 | 294 | (pattern! shrill-dur-buf [1/12]) 295 | (pattern! pulsar-buf [0]) 296 | (pattern! growl-buf [:D3 :D3 0 :D3 :D3]) 297 | (reset! color-l 0.0) 298 | (reset! color-r 0.0) 299 | (reset! space 0.0) 300 | (reset! res 0.15) 301 | 302 | (def view-port "journey.glsl") 303 | (def view-port "zoomwave.glsl") 304 | 305 | (t/start-fullscreen (str "resources/shaders/" view-port) 306 | :textures [:overtone-audio :previous-frame] 307 | :user-data {"iLColor" color-l "iRColor" color-r 308 | "iRes" res 309 | "iSpace" space 310 | "iA" (atom {:synth s :tap "a"}) 311 | "iG" (atom {:synth growl-synth :tap "g"})}) 312 | 313 | 314 | (comment 315 | (t/stop) 316 | (def fx2 (fx/fx-chorus 0)) 317 | (def fx3 (fx/fx-echo 0)) 318 | 319 | (kill fx2) 320 | (kill fx3) 321 | 322 | (kill whitenoise-hat) 323 | (kill kick2) 324 | (kill high-hats) 325 | (kill quick-kick) 326 | (kill mid-pings) 327 | (kill fizzy-pulsar) 328 | (kill pulsar) 329 | (kill glass-ping) 330 | (kill growl) 331 | (kill growler) 332 | 333 | (kill drums-g) 334 | (kill bass-g) 335 | 336 | (kill shrill-pong) 337 | (kill shrill-pulsar) 338 | (kill dark-ambience) 339 | 340 | (stop) 341 | ) 342 | -------------------------------------------------------------------------------- /src/cassiopeia/scratch.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.scratch 2 | "Here lies demons and a splatter gun of ideas and experiments." 3 | (:use overtone.live) 4 | (:use cassiopeia.waves.synths) 5 | (:use mud.core) 6 | (:use cassiopeia.waves.soprano) 7 | (require [mud.timing :as time] 8 | [overtone.studio.fx :as fx])) 9 | 10 | (do 11 | (def singers-g (group "singers")) 12 | 13 | (defonce note-buf (buffer 128)) 14 | (defonce note2-buf (buffer 128)) 15 | (defonce sing-attack (buffer 128)) 16 | 17 | (defonce seq-b1 (buffer 128)) 18 | (defonce seq-b2 (buffer 128)) 19 | (defonce seq-b3 (buffer 128)) 20 | (defonce seq-b4 (buffer 128))) 21 | 22 | 23 | (def singers-ah-p (doseq [i (range 0 3)] 24 | (slow-singer 25 | [:head singers-g] 26 | :note-buf note-buf :amp 2.9 27 | :beat-b (:beat time/beat-4th) :count-b (:count time/beat-4th) 28 | :seq-b seq-b1 29 | :beat-num i 30 | :index-b ah-index-buffer 31 | :num-steps 3))) 32 | 33 | (def singers-ah-f (doseq [i (range 0 3)] 34 | (slow-singer 35 | [:head singers-g] 36 | :note-buf note-buf :amp 2.9 37 | :beat-b (:beat time/beat-4th) :count-b (:count time/beat-4th) 38 | :seq-b seq-b3 39 | :beat-num i 40 | :index-b ah-strong-index-buffer 41 | :num-steps 3))) 42 | 43 | (def singers-yeh (doseq [i (range 0 3)] 44 | (slow-singer 45 | [:head singers-g] 46 | :note-buf note-buf :amp 2.9 47 | :beat-b (:beat time/beat-4th) :count-b (:count time/beat-4th) 48 | :seq-b seq-b4 49 | :beat-num i 50 | :index-b yeh-index-buffer 51 | :num-steps 3))) 52 | 53 | (pattern! seq-b1 54 | [1 0 0 0] 55 | [1 0 0 0] 56 | [1 0 0 0] 57 | [0 0 0 0] 58 | [0 0 0 0]) 59 | 60 | (pattern! seq-b3 61 | [0 0 0 0] 62 | [0 0 0 0] 63 | [0 0 0 0] 64 | [0 0 0 0] 65 | [1 0 0 0]) 66 | 67 | (pattern! seq-b4 68 | [0 0 0 0] 69 | [0 0 0 0] 70 | [0 0 0 0] 71 | [1 0 0 0] 72 | [1 0 0 0]) 73 | 74 | ;;63 62 64 62 62 62 64 75 | (pattern! note-buf [:Eb4 :D4 :E4 :D4 :D4 :D4 :E4]) 76 | (pattern! note-buf [70 70 69 69 68 68 70 70]) 77 | (pattern! note-buf (shuffle [:Eb4 :D4 :E4 :D4 :D4 :D4 :E4])) 78 | 79 | (on-trigger (:trig-id time/main-beat) 80 | (fn [x] 81 | (when (= 0 (mod x 16))) 82 | (pattern! b (shuffle [:Eb4 :D4 :E4 :D4 :D4 :D4 :E4]))) 83 | ::shuffle-trig) 84 | 85 | (remove-event-handler ::shuffle-trig) 86 | 87 | (ctl singers-g :attack 0.2) 88 | (ctl singers-g :release 6.) 89 | 90 | (pattern! note2-buf [:Eb4 :D4 :E4 :D4 :D4 :D4 :E4]) 91 | (pattern! note-buf [:Eb4 :D4 :E4 :D4 :D4 :D4 :E4]) 92 | (pattern! seq-b2 [1 1 1]) 93 | 94 | (def fast-singing (fast-singer 95 | [:head singers-g] 96 | :note-buf note2-buf :amp 0 97 | :beat-b (:beat time/beat-1th) :count-b (:count time/beat-1th))) 98 | 99 | 100 | (kill fast-singer) 101 | 102 | (def fast-singing (fast-varied-singer 103 | [:head singers-g] 104 | :note-buf note2-buf :amp 0 105 | :beat-b (:beat time/beat-1th) :count-b (:count time/beat-1th) 106 | :attack-b sing-attack)) 107 | 108 | (ctl singers-g :amp 1) 109 | 110 | (pattern! sing-attack 111 | (repeat 2 [1 1 1/12 1/12]) 112 | (repeat 2 [2 2 2 2])) 113 | 114 | (pattern! sing-attack 115 | (repeat 2 [1/32])) 116 | 117 | (pattern! note2-buf 118 | (repeat 2 [70 68 70 69]) 119 | (repeat 2 [69 70 0 0]) 120 | (repeat 2 [69 68 69 68]) 121 | (repeat 2 [69 69 0 0]) 122 | (repeat 4 [70 68 70 68]) 123 | (repeat 4 [69 68 0 0]) 124 | (repeat 4 [70 69 70 69]) 125 | (repeat 4 [70 70 70 70])) 126 | 127 | (pattern! note-buf [70 70 69 69 68 68 70 70]) 128 | 129 | (pattern! note2-buf [:Eb4 :D4 :F4 :G4 :G4 :G4 :E4 :Eb4 :D4 :E4 :D4 :D4 :D4 :E4]) 130 | 131 | (n-overtime! fast-singing :amp 0.0 0.2 0.01) 132 | (ctl fast-singing :release 0.1 :attack 0.1) 133 | (ctl fast-singing :release 0.4 :attack 1.0) 134 | 135 | (kill fast-singer) 136 | (kill slow-singer) 137 | 138 | (comment 139 | (sing :note 60 :amp 1.49 :pos 0) 140 | (sing :note 64 :amp 1.09 :pos 0) 141 | (sing :note 67 :amp 1.09 :pos 0) 142 | (sing :note 68 :amp 1.09 :pos 0) 143 | 144 | (fx/fx-chorus) 145 | (fx/fx-reverb) 146 | (fx/fx-limiter) 147 | (fx/fx-compressor) 148 | (fx/fx-rlpf) 149 | (fx/fx-noise-gate) 150 | 151 | (fx/fx-distortion-tubescreamer) 152 | (fx/fx-echo)) 153 | (stop) 154 | 155 | 156 | 157 | 158 | ;;(recording-stop) 159 | 160 | 161 | ;;(recording-start "~/Desktop/eta-v8.wav") 162 | 163 | (defsynth ding [freq 880 dur 0.2 level 0.25 pan 0.0 out-bus 0] 164 | (let [amp (env-gen:ar (env-perc) :action FREE :time-scale dur) 165 | snd (* (sin-osc:ar freq) amp level)] 166 | (out out-bus (pan2:ar snd pan)))) 167 | 168 | (defsynth tick [freq 880 dur 0.1 level 0.25 pan 0.0 out-bus 0] 169 | (let [amp (env-gen (env-perc) :action FREE :time-scale dur) 170 | snd (lpf:ar (white-noise:ar) freq)] 171 | (out out-bus (pan2:ar (* snd amp level) pan)))) 172 | - 173 | (tick) 174 | (ding :dur 0.5) 175 | 176 | (def note-offset-b (buffer 128)) 177 | (def duration-b (buffer 128)) 178 | 179 | (def note-offsets [:F4 :F4 :F4 :F4 :F4 :F4 :F4 180 | :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 :G4 181 | :BB4 :BB4 :BB4 :BB4 :BB4 :BB4 182 | :D#4 :D#4 :D#4]) 183 | 184 | (def duration [1/7]) 185 | 186 | (def score (concat 187 | (map #(+ -5 (note %)) note-offsets) 188 | (map #(+ -5 (note %)) note-offsets) 189 | (map #(+ -10 (note %)) note-offsets) 190 | (map #(+ -5 (note %)) note-offsets) 191 | (map #(+ -1 (note %)) note-offsets))) 192 | 193 | (buffer-write! note-offset-b (take 128 score)) 194 | 195 | (buffer-write! duration-b (take 128 (cycle duration))) 196 | 197 | (ctl timing/root-s :rate 100) 198 | 199 | (do 200 | (defsynth woody-beep [duration-bus 0 beat-count-bus 0 offset-bus 0 amp 1 out-bus 0] 201 | (let [cnt (in:kr beat-count-bus) 202 | offset (buf-rd:kr 1 offset-bus cnt) 203 | durs (buf-rd:kr 1 duration-bus cnt) 204 | trig (t-duty:kr (dseq durs INFINITE)) 205 | freq (demand:kr trig 0 (drand offset INFINITE)) 206 | freq (midicps freq) 207 | 208 | env (env-gen:ar (env-asr :release 0.25 :sustain 0.8) trig) 209 | tri (* 0.5 (lf-tri:ar freq)) 210 | sin (sin-osc:ar (* 1 freq)) 211 | sin2 (sin-osc:ar (* 1.01 freq)) 212 | wood (bpf:ar (* (white-noise:ar) (line:kr 5 0 0.02)) freq 0.02) 213 | src (mix [sin sin2 tri wood]) 214 | src (free-verb src)] 215 | (out:ar out-bus (* amp env (pan2 src))))) 216 | 217 | (kill woody-beep) 218 | 219 | (def w (woody-beep :duration-bus duration-b :beat-count-bus timing/beat-count-b :offset-bus note-offset-b :amp 4))) 220 | 221 | (defsynth deep-saw [freq 100 beat-count-bus 0 offset-bus 0 duration-bus 0 out-bus 0 amp 1 pan 0] 222 | (let [cnt (in:kr beat-count-bus) 223 | offset (buf-rd:kr 1 offset-bus cnt) 224 | durs (buf-rd:kr 1 duration-bus cnt) 225 | trig (t-duty:kr (dseq durs INFINITE)) 226 | freq (demand:kr trig 0 (drand offset INFINITE)) 227 | freq (midicps freq) 228 | 229 | saw1 (lf-saw:ar (* 0.5 freq)) 230 | saw2 (lf-saw:ar (* 0.25 freq)) 231 | sin1 (sin-osc freq) 232 | sin2 (sin-osc (* 1.01 freq)) 233 | src (mix [saw1 saw2 sin1 sin2]) 234 | env (env-gen:ar (env-asr) trig) 235 | src (lpf:ar src) 236 | src (free-verb src 0.33 1 1)] 237 | (out out-bus (* amp [src src])))) 238 | 239 | (def bass-duration-b (buffer 32)) 240 | (def bass-notes-b (buffer 32)) 241 | 242 | (buffer-write! bass-duration-b (take 32 (cycle [(/ 1 3.5)]))) 243 | (buffer-write! bass-notes-b (take 32 (cycle (map note [:F2 :F2 :G3 :G2 :G3 :BB2 :BB2 :G2 :G2])))) 244 | 245 | (def ps (deep-saw 100 :duration-bus bass-duration-b :beat-count-bus timing/beat-count-b :offset-bus bass-notes-b :amp 0.5)) 246 | 247 | (ctl ps :freq 200) 248 | 249 | (stop) 250 | (kill deep-saw) 251 | 252 | (def melody-part2-buf (buffer 128)) 253 | (require '[overtone.orchestra.cello :as cello-src]) 254 | 255 | (cello :length 3 :note (note :A3)) 256 | (defsynth cello 257 | "length options: 258 | 0 -> 0.25 259 | 1 -> 0.5 260 | 2 -> 1 261 | 3 -> 1.5" 262 | [level 1 rate 1 loop? 0 attack 0 decay 0.5 sustain 1 release 0.1 curve -4 gate 1 beat-count-bus 0 263 | offset-bus 0 duration-bus 0 beat-trg-bus 0] 264 | (let [cnt (in:kr beat-count-bus) 265 | note (buf-rd:kr 1 offset-bus cnt) 266 | length (buf-rd:kr 1 duration-bus cnt) 267 | trig (in:kr beat-trg-bus) 268 | 269 | l-buf (index:kr (:id cello-src/length-buffer) length) 270 | buf (index:kr l-buf note) 271 | env (env-gen (adsr attack decay sustain release level curve))] 272 | (out 0 (pan2 (* env (scaled-play-buf 1 buf :trigger trig :loop 1 :start-pos 0)))))) 273 | 274 | 275 | (defonce cello-buf (buffer 128)) 276 | (defonce cello-dur (buffer 128)) 277 | 278 | (cello :beat-count-bus (:count timing/beat-2th) :offset-bus zello-buf :duration-bus zello-dur :beat-trg-bus (:beat timing/beat-2th)) 279 | 280 | (buffer-write! cello-buf (take 128 (cycle 281 | (map note 282 | [0 0 0 0 0 0 0 0 283 | 0 0 0 0 0 0 0 0 284 | 0 0 0 0 0 0 0 0 285 | :A3 :E3 :D3 :C4 :D3 :E3 :A3 :C3])))) 286 | 287 | (buffer-write! cello-dur (take 128 (cycle [0 0 0 0 0 0 0 0 288 | 0 0 0 0 0 0 0 0 289 | 0 0 0 0 0 0 0 0 290 | 2 2 2 2 2 2 2 1]))) 291 | 292 | (kill cello) 293 | 294 | (require '[overtone.orchestra.oboe :as oboe-src]) 295 | (defsynth oboe 296 | "length options: 297 | 0 -> 0.25 298 | 1 -> 0.5 299 | 2 -> 1 300 | 3 -> 1.5" 301 | [level 1 rate 1 loop? 0 attack 0 decay 0.5 sustain 1 release 0.1 curve -4 gate 1 beat-count-bus 0 beat-trg-bus 0 offset-bus 0 302 | duration-bus 0] 303 | (let [cnt (in:kr beat-count-bus) 304 | note (buf-rd:kr 1 offset-bus cnt) 305 | length (buf-rd:kr 1 duration-bus cnt) 306 | trig (in:kr beat-trg-bus) 307 | 308 | l-buf (index:kr (:id oboe-src/length-buffer) length) 309 | buf (index:kr l-buf note) 310 | env (env-gen (adsr attack decay sustain release level curve) 311 | :gate gate)] 312 | (out 0 (pan2 (* env (scaled-play-buf 1 buf :level level :loop 1 :trigger trig :start-pos 0)))))) 313 | 314 | (oboe :beat-count-bus (:count time/beat-1th) :offset-bus zello-buf :duration-bus zello-dur :beat-trg-bus (:beat time/beat-1th)) 315 | 316 | (defonce zello-buf (buffer 128)) 317 | (defonce zello-dur (buffer 128)) 318 | 319 | (buffer-write! zello-buf (take 128 (cycle 320 | (map note 321 | [:A3 :C4 :C5 :C4 :G4 :E4 :A4 :C4])))) 322 | 323 | (buffer-write! zello-buf (take 128 (cycle 324 | (map note 325 | [:A4 :C4 :C5 :C4 :G4 :E4 :A4 :C4])))) 326 | 327 | (buffer-write! zello-dur (take 128 (cycle [3 3 3 3 3 3 3 3 3]))) 328 | 329 | (ctl timing/root-s :rate 4) 330 | 331 | (kill oboe) 332 | (stop) 333 | 334 | 335 | ;; Nice way to play with chords 336 | 337 | (let [_ [0 0 0] 338 | [f21 f22 f23 f24 f25 f26 f27] (map #(chord-degree %1 :F2 :major 3) [:i :ii :iii :iv :v :vi :vii]) 339 | [f31 f32 f33 f34 f35 f36 f37] (map #(chord-degree %1 :F3 :minor 3) [:i :ii :iii :iv :v :vi :vii]) 340 | [f41 f42 f43 f44 f45 f46 f47] (map #(chord-degree %1 :F4 :major 3) [:i :ii :iii :iv :v :vi :vii])] 341 | (let [chord-pat 342 | [_ _ _ _ _ _ _ _ _ _ _ _ 343 | f33 f35 f31 _ _ _ _ _ _ _ _ _]] 344 | (let [chord-bufs (shuffle [n1 n2 n3])] ;; Play around with some random inversions 345 | (dotimes [chord-idx (count chord-bufs)] 346 | (pattern! (nth chord-bufs chord-idx) (map #(if (> (count %1) chord-idx) (nth %1 chord-idx) 0) chord-pat)))))) 347 | -------------------------------------------------------------------------------- /src/cassiopeia/engine/mixers.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.engine.mixers 2 | (:require [mud.timing :as timing]) 3 | (:use [overtone.live] 4 | [overtone.helpers.lib :only [uuid]])) 5 | 6 | (defsynth basic-mixer [boost 0 amp 1 mute 1 in-bus 0 out-bus 0 clamp-down-t 0.05] 7 | (out out-bus (* (+ boost 1) amp (lag mute clamp-down-t) (in:ar in-bus 2)))) 8 | 9 | ;;State to store the currently active nk mixers 10 | (defonce korg-nano-kontrol-mixers (atom {})) 11 | 12 | (defcgen wobble 13 | "wobble an input src" 14 | [src {:doc "input source"} 15 | wobble-factor {:doc "num wobbles per second"}] 16 | (:ar 17 | (let [sweep (lin-exp (lf-tri wobble-factor) -1 1 40 3000) 18 | wob (lpf src sweep) 19 | wob (* 0.8 wob)] 20 | wob))) 21 | 22 | (defsynth meta-mix [rev-mix 0 23 | delay-decay 0 24 | dec-mix 0 25 | wobble-mix 0 26 | delay-mix 0 27 | hpf-mix 0 28 | wobble-factor 0 29 | amp 1.5 30 | rev-damp 0 31 | rev-room 0 32 | samp-rate 0 33 | bit-rate 0 34 | delay-rate 0 35 | hpf-freq 2060 36 | hpf-rq 1 37 | pan 0 38 | in-bus 10 39 | delay-reset-trig [0 :kr] 40 | out-bus 0] 41 | (let [ 42 | ;;scale inputs accordingly 43 | wobble-factor (* wobble-factor 15) 44 | amp (* amp 3) 45 | samp-rate (* samp-rate 22000) 46 | bit-rate (* bit-rate 32) 47 | hpf-freq (mul-add hpf-freq 2000 60) 48 | pan (- (* 2 pan) 1) 49 | num-samps (* 2 44100) 50 | delay-buf (local-buf num-samps) 51 | src (in:ar in-bus 1) 52 | pos (phasor:ar delay-reset-trig 1 0 (* delay-rate num-samps)) 53 | old (buf-rd:ar 1 delay-buf pos :loop true) 54 | delay-sig (+ src (* delay-decay old)) 55 | 56 | src (+ (* (- 1 delay-mix) src) 57 | (* delay-mix delay-sig)) 58 | 59 | src (+ (* (- 1 rev-mix) src) 60 | (* rev-mix (free-verb src :mix 1 :room rev-room :damp rev-damp))) 61 | 62 | src (+ (* (- 1 dec-mix) src) 63 | (* dec-mix (decimator src samp-rate bit-rate))) 64 | 65 | src (+ (* (- 1 hpf-mix) src) 66 | (* hpf-mix (normalizer (rhpf src hpf-freq hpf-rq)))) 67 | 68 | src (+ (* (- 1 wobble-mix) src) 69 | (* wobble-mix (wobble src wobble-factor))) 70 | ] 71 | 72 | (buf-wr:ar [src] delay-buf pos :loop true) 73 | (out out-bus (pan2 (* amp src) pan)))) 74 | 75 | (defsynth mixer-sin-control 76 | [out-bus 0 77 | 78 | freq-mul-0 0 79 | phase-shift-0 0 80 | mul-0 0 81 | add-0 1 82 | amp-0 0 83 | 84 | freq-mul-1 0 85 | phase-shift-1 0 86 | mul-1 0 87 | add-1 1 88 | amp-1 0 89 | 90 | freq-mul-2 0 91 | phase-shift-2 0 92 | mul-2 0 93 | add-2 1 94 | amp-2 0 95 | 96 | freq-mul-3 0 97 | phase-shift-3 0 98 | mul-3 0 99 | add-3 1 100 | amp-3 0 101 | 102 | freq-mul-4 0 103 | phase-shift-4 0 104 | mul-4 0 105 | add-4 1 106 | amp-4 0 107 | 108 | freq-mul-5 0 109 | phase-shift-5 0 110 | mul-5 0 111 | add-5 1 112 | amp-5 0 113 | 114 | freq-mul-6 0 115 | phase-shift-6 0 116 | mul-6 0 117 | add-6 1 118 | amp-6 0 119 | 120 | freq-mul-7 0 121 | phase-shift-7 0 122 | mul-7 0 123 | add-7 1 124 | amp-7 0.5 125 | 126 | freq-mul-8 0 127 | phase-shift-8 0 128 | mul-8 0 129 | add-8 1 130 | amp-8 0 131 | 132 | freq-mul-9 0 133 | phase-shift-9 0 134 | mul-9 0 135 | add-9 1 136 | amp-9 0 137 | 138 | freq-mul-10 0 139 | phase-shift-10 0 140 | mul-10 0 141 | add-10 1 142 | amp-10 0 143 | 144 | freq-mul-11 0 145 | phase-shift-11 0 146 | mul-11 0 147 | add-11 1 148 | amp-11 0 149 | 150 | freq-mul-12 0 151 | phase-shift-12 0 152 | mul-12 0 153 | add-12 1 154 | amp-12 0 155 | 156 | freq-mul-13 0 157 | phase-shift-13 0 158 | mul-13 0 159 | add-13 1 160 | amp-13 0 161 | 162 | freq-mul-14 0 163 | phase-shift-14 0 164 | mul-14 0 165 | add-14 1 166 | amp-14 0 167 | 168 | freq-mul-15 0 169 | phase-shift-15 0 170 | mul-15 0 171 | add-15 1 172 | amp-15 0.5 173 | 174 | ] 175 | 176 | (let [clk (in:kr timing/pi-x-b)] 177 | (out:kr out-bus [(* amp-0 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-0 phase-shift-0))) 2) mul-0 add-0)) 178 | (* amp-1 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-1 phase-shift-1))) 2) mul-1 add-1)) 179 | (* amp-2 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-2 phase-shift-2))) 2) mul-2 add-2)) 180 | (* amp-3 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-3 phase-shift-3))) 2) mul-3 add-3)) 181 | (* amp-4 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-4 phase-shift-4))) 2) mul-4 add-4)) 182 | (* amp-5 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-5 phase-shift-5))) 2) mul-5 add-5)) 183 | (* amp-6 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-6 phase-shift-6))) 2) mul-6 add-6)) 184 | (* amp-7 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-7 phase-shift-7))) 2) mul-7 add-7)) 185 | (* amp-8 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-8 phase-shift-8))) 2) mul-8 add-8)) 186 | (* amp-9 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-9 phase-shift-9))) 2) mul-9 add-9)) 187 | (* amp-10 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-10 phase-shift-10))) 2) mul-10 add-10)) 188 | (* amp-11 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-11 phase-shift-11))) 2) mul-11 add-11)) 189 | (* amp-12 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-12 phase-shift-12))) 2) mul-12 add-12)) 190 | (* amp-13 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-13 phase-shift-13))) 2) mul-13 add-13)) 191 | (* amp-14 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-14 phase-shift-14))) 2) mul-14 add-14)) 192 | (* amp-15 (mul-add:kr (/ (+ 1 (sin (mul-add clk freq-mul-15 phase-shift-15))) 2) mul-15 add-15)) 193 | 194 | ]))) 195 | 196 | (def nano2-fns {:slider0 (fn [v mixer-g] (ctl mixer-g :rev-mix v)) 197 | :slider1 (fn [v mixer-g] (ctl mixer-g :delay-decay v)) 198 | :slider2 (fn [v mixer-g] (ctl mixer-g :dec-mix v)) 199 | :slider3 (fn [v mixer-g] (ctl mixer-g :wobble-mix v)) 200 | :slider4 (fn [v mixer-g] (ctl mixer-g :delay-mix v)) 201 | :slider5 (fn [v mixer-g] (ctl mixer-g :hpf-mix v)) 202 | :slider6 (fn [v mixer-g] (ctl mixer-g :wobble-factor (scale-range v 0 1 0 15))) 203 | :slider7 (fn [v mixer-g] (ctl mixer-g :amp (scale-range v 0 1 0 3))) 204 | :pot0 (fn [v mixer-g] (ctl mixer-g :rev-damp v)) 205 | :pot1 (fn [v mixer-g] (ctl mixer-g :rev-room v)) 206 | :pot2 (fn [v mixer-g] (ctl mixer-g :samp-rate (* 22000 v))) 207 | :pot3 (fn [v mixer-g] (ctl mixer-g :bit-rate (* 32 v))) 208 | :pot4 (fn [v mixer-g] (ctl mixer-g :delay-rate v)) 209 | :pot5 (fn [v mixer-g] (ctl mixer-g :hpf-freq (+ 60 (* 2000 v)))) 210 | :pot6 (fn [v mixer-g] (ctl mixer-g :hpf-rq v)) 211 | :pot7 (fn [v mixer-g] (ctl mixer-g :pan (scale-range v 0 1 -1 1))) 212 | 213 | }) 214 | 215 | (def nano2-fns {:slider0 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-0 v)) 216 | :slider1 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-1 v)) 217 | :slider2 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-2 v)) 218 | :slider3 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-3 v)) 219 | :slider4 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-4 v)) 220 | :slider5 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-5 v)) 221 | :slider6 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-6 v)) 222 | :slider7 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-7 v)) 223 | :pot0 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-8 v)) 224 | :pot1 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-9 v)) 225 | :pot2 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-10 v)) 226 | :pot3 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-11 v)) 227 | :pot4 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-12 v)) 228 | :pot5 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-13 v)) 229 | :pot6 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-14 v)) 230 | :pot7 (fn [v sin-ctl-s] (ctl sin-ctl-s :amp-15 v))}) 231 | 232 | (def nano2-controls (keys nano2-fns)) 233 | 234 | (defn- mk-mixer 235 | [event-k mixer-g out-bus] 236 | (let [in-bus (audio-bus 2) 237 | ctl-bus (control-bus 16) 238 | live? (atom true) 239 | sin-ctl (mixer-sin-control [:tail mixer-g] :out-bus ctl-bus) 240 | mixer (meta-mix [:after sin-ctl] :in-bus in-bus :out-bus out-bus) 241 | handler-k (uuid)] 242 | (node-map-n-controls mixer :rev-mix ctl-bus 16) 243 | (doseq [control-id nano2-controls] 244 | (println "adding handler for: " (vec (concat event-k [control-id]))) 245 | (on-latest-event (vec (concat event-k [control-id])) 246 | (fn [msg] 247 | (let [id (:id msg) 248 | val (:val msg)] 249 | (println :msg msg) 250 | (if-let [f (get nano2-fns id)] 251 | (do 252 | ;;(println "-->" id ctl-bus) 253 | (f val sin-ctl) 254 | ) 255 | ;; (println "unbound: " note) 256 | ))) 257 | (str handler-k control-id))) 258 | (on-node-destroyed mixer 259 | (fn [_] 260 | (doseq [control-id nano2-controls] 261 | (remove-event-handler (str handler-k control-id))) 262 | (swap! korg-nano-kontrol-mixers dissoc event-k) 263 | (reset! live? false))) 264 | 265 | (with-meta {:mixer-g mixer-g 266 | :mixer mixer 267 | :handler-k handler-k 268 | :in-bus in-bus 269 | :event-key event-k 270 | :live? live? 271 | :sin-ctl sin-ctl} 272 | {:type ::mixer}))) 273 | 274 | 275 | (defn add-mixer 276 | ([event-k] 277 | (add-mixer event-k (foundation-safe-post-default-group))) 278 | ([event-k tgt-g] 279 | (add-mixer event-k tgt-g 0)) 280 | ([event-k tgt-g out-bus] 281 | (let [mixers (swap! korg-nano-kontrol-mixers 282 | (fn [mixers] 283 | (when (contains? mixers event-k) 284 | (throw (Exception. 285 | (str "Korg Nano Kontrol Mixer with event key " 286 | event-k " already exists.")))) 287 | 288 | (assoc mixers event-k (mk-mixer event-k tgt-g out-bus))))] 289 | (get mixers event-k)))) 290 | 291 | (defn kill-mixer [mixer] 292 | (remove-event-handler (:handler-key mixer)) 293 | (swap! korg-nano-kontrol-mixers dissoc (:event-key mixer)) 294 | (with-inactive-modification-error :silent 295 | (kill (:mixer mixer)))) 296 | 297 | (defn add-nk-mixer 298 | ([g k] 299 | (add-mixer [:v-nanoKON2 g k :control-change])) 300 | ([g k tgt-g] 301 | (add-mixer [:v-nanoKON2 g k :control-change] tgt-g)) 302 | ([g k tgt-g out-bus] 303 | (add-mixer [:v-nanoKON2 g k :control-change] tgt-g out-bus))) 304 | 305 | (defn mx 306 | [k] 307 | (:mixer-g (get @korg-nano-kontrol-mixers k))) 308 | 309 | (defn nkmx 310 | ([k] (nkmx 16 k)) ;; TODO replace 16 with a more sensible call i.e. nk-bank 311 | ([bank k] 312 | (:in-bus (get @korg-nano-kontrol-mixers [:v-nanoKON2 bank k :control-change])))) 313 | 314 | (defn nkmx-out 315 | [k] 316 | (:out-bus (get @korg-nano-kontrol-mixers [:v-nanoKON2 16 k :control-change]))) 317 | 318 | (defn nkmx-synth 319 | [k] 320 | (:mixer (get @korg-nano-kontrol-mixers [:v-nanoKON2 16 k :control-change]))) 321 | 322 | (defn nkmx-sctl 323 | ([k] (nkmx-sctl k 16)) 324 | ([k bank-id] 325 | (:sin-ctl (get @korg-nano-kontrol-mixers [:v-nanoKON2 bank-id k :control-change])))) 326 | -------------------------------------------------------------------------------- /src/cassiopeia/destination/voices.clj: -------------------------------------------------------------------------------- 1 | (ns cassiopeia.destination.voices 2 | " 3 | _| _| _| 4 | _| _| _|_| _|_|_| _|_| _|_|_| 5 | _| _| _| _| _| _| _|_|_|_| _|_| 6 | _| _| _| _| _| _| _| _|_| 7 | _| _|_| _| _|_|_| _|_|_| _|_|_| 8 | 9 | Hearing Voices From Space. 10 | A space suit floats through the empty void and orbits our planet, its radio broadcasts signals to the Earth below. 11 | On the surface, amateur radio operators receive the transmission and hear a voice. Coming from the suit, 12 | as it floats alone, away from the international space station. 13 | " 14 | (:use overtone.live) 15 | (:use cassiopeia.engine.samples) 16 | (:use cassiopeia.samples) 17 | (:use cassiopeia.warm-up) 18 | (:require [mud.timing :as tim] 19 | [cassiopeia.engine.monome-sequencer :as mon])) 20 | 21 | (defonce voice-g (group "the voices")) 22 | 23 | (def score [:C1 :E1 :F1 :C3 :C2 :E2 :F2 :E3 :F3 :C4 :E4 :F4]) 24 | 25 | (defsynth voice [out-bus 0 note 0 pan 0 attack 10 release 10 mix 0.33 amp 1] 26 | (let [freq (midicps note) 27 | sig (sum [(* (/ 0.05 (inc 0)) (var-saw:ar (* freq (+ 0 1.0001))))] 28 | [(* (/ 0.05 (inc 1)) (var-saw:ar (* freq (+ 1 1.0001))))] 29 | [(* (/ 0.05 (inc 2)) (var-saw:ar (* freq (+ 2 1.0001))))]) 30 | sig2 (ringz:ar (* 0.0003 (white-noise:ar)) (t-rand:ar freq (midicps (+ 1 note)) (impulse:ar 10))) 31 | env (env-gen:kr (env-lin attack 1 release) 1 :action FREE) 32 | s (+ 0.8 (* 0.2 (sin-osc:kr 0.1 0))) 33 | src (* (+ sig sig2) s env) 34 | src (limiter:ar (free-verb:ar (lpf:ar src 10000) :mix mix) 0.7)] 35 | (out out-bus (* amp (pan2:ar src pan))))) 36 | 37 | (doseq [n (range 0 10)] 38 | (voice [:head voice-g] 39 | :note (note (rand-nth score)) 40 | :pan (ranged-rand -0.5 0.5) 41 | :attack 5 42 | :release 8)) 43 | 44 | (kill voice-g) 45 | (stop) 46 | 47 | (def num-voices 20) 48 | (def ring-score (map midi->hz (take num-voices (cycle [26 40 54 67 81 95 109 110 124 138])))) 49 | (defonce ring-score-buf (buffer num-voices)) 50 | (defonce ring-g (group "rings")) 51 | 52 | (buffer-write! ring-score-buf ring-score) 53 | 54 | (def ring-buf (buffer 16)) 55 | (defsynth ringing [amp 1 out-bus 0 num-steps 8 beat-num 0 56 | beat-bus 0 beat-trg-bus 0] 57 | (let [cnt (in:kr beat-bus) 58 | beat-trg (in:kr beat-trg-bus) 59 | bar-trg (and (buf-rd:kr 1 ring-buf cnt) 60 | (= beat-num (mod cnt num-steps)) 61 | beat-trg) 62 | time 5 63 | freqs ring-score 64 | 65 | rings (take num-voices (repeatedly #(rand 1.0))) 66 | envs (take num-voices (repeatedly #(env-gen (env-lin (/ time 3.0) (/ time 3.0) (/ time 3.0) (rand 1.0))))) 67 | 68 | src (* [(reciprocal num-voices) (reciprocal num-voices)] (pink-noise:ar)) 69 | src (klank:ar [freqs envs rings] src) 70 | src (* src (env-gen:kr (env-lin (rand time) (/ time 3) (rand time)) :gate bar-trg)) 71 | src (hpf:ar src 120) 72 | 73 | src (delay-c:ar src 0.4 [(rand 0.4) (rand 0.4) 1/8 src]) 74 | src (delay-c:ar src 0.4 [(rand 0.4) (rand 0.4) 1/8 src]) 75 | src (delay-c:ar src 0.4 [(rand 0.4) (rand 0.4) 1/8 src]) 76 | src (delay-c:ar src 0.4 [(rand 0.4) (rand 0.4) 1/8 src])] 77 | (out out-bus (* amp src)))) 78 | 79 | (dotimes [i 16] 80 | (ringing [:head ring-g] :amp 3 81 | :beat-num i 82 | :beat-bus (:count tim/beat-1th) 83 | :beat-trg-bus (:beat tim/beat-1th))) 84 | 85 | (buffer-write! ring-buf (take 16 (cycle [1 0 0 0 0 0 0 0 86 | 0 0 0 0 0 0 0 0]))) 87 | 88 | (kill ring-g) 89 | (kill ringing) 90 | 91 | 92 | (defsynth noise-ocean [amp 1 out-bus 0] 93 | (let [src (one-pole:ar (+ (* 0.5 (dust:ar 100)) (* 0.1 (white-noise:ar))) 0.7) 94 | src (+ src (splay:ar (freq-shift:ar src [1/4 1/5 1/6 1/7])))] 95 | (out out-bus (* amp src)))) 96 | 97 | (comment 98 | (noise-ocean :amp 0.05) 99 | (kill noise-ocean)) 100 | 101 | (defsynth dark-ambience [out-bus 0 amp 1 mul 0.2 room-size 70 rev-time 99 ring-freq 60 ring-mul 55] 102 | (let [pink (hpf:ar (* (* 0.005 (pink-noise)) (line:kr 0 1 9)) 5) 103 | src1 (ringz (* pink (lf-noise1:kr 0.15)) (+ ring-freq (* ring-mul 0)) mul) 104 | src2 (ringz (* pink (lf-noise1:kr 0.15)) (+ ring-freq (* ring-mul 1)) mul) 105 | src3 (ringz (* pink (lf-noise1:kr 0.15)) (+ ring-freq (* ring-mul 2)) mul) 106 | src4 (ringz (* pink (lf-noise1:kr 0.15)) (+ ring-freq (* ring-mul 3)) mul) 107 | src5 (ringz (* pink (lf-noise1:kr 0.15)) (+ ring-freq (* ring-mul 4)) mul) 108 | src (tanh (g-verb (sum [src1 src2 src3 src4 src5]) room-size rev-time))] 109 | (out out-bus (* amp src)))) 110 | 111 | (def dark (dark-ambience :mul 0.2 :amp 0.2)) 112 | 113 | (ctl dark :ring-mul 55) 114 | (ctl dark :ring-freq (midi->hz 40)) 115 | (ctl dark :mul 0.2 :room-size 70) 116 | (ctl dark :mul 0.5 :rev-time 99) 117 | (ctl dark :amp 0.1) 118 | (ctl dark :room-size 70) 119 | 120 | (kill dark) 121 | 122 | (stop) 123 | 124 | (def sis-score [[72 69 64] [70 64 62] [67 60 70] [65 60 69] [64 60 67] [65 60 69]]) 125 | 126 | (defsynth sistres [out-bus 0 amp 1] 127 | (let [h (midicps (rand-nth [40 45 52])) 128 | sins (take 16 (repeatedly #(* 0.2 (sin-osc:ar (exp-rand h (+ h (/ h 64))) 0)))) 129 | src (* sins (lf-gauss:ar 9 1/4 0 0 2))] 130 | (out out-bus (* amp (splay:ar src))))) 131 | 132 | (sistres :amp 10) 133 | 134 | (def pattern-sizes [1 2 4 8 16 32 64 128 256]) 135 | (def durations [1/8 1/4 1/2 1]) 136 | (def voices 4) 137 | (def pattern-size (rand-nth pattern-sizes)) 138 | 139 | (def perc-dur-buf (buffer voices)) 140 | (defonce perc-amp-buf (buffer pattern-size)) 141 | (defonce perc-post-frac-buf (buffer pattern-size)) 142 | 143 | (defonce perc-g (group "perc grouping")) 144 | 145 | (defsynth buf->perc-inst [out-bus 0 buf [0 :ir] rate 1 inter 2 beat-num 0 146 | pattern-buf 0 pattern-size 3 147 | amp-buf 0 148 | duration-buf 0 149 | voices 3 150 | beat-count-bus 0] 151 | (let [cnt (in:kr beat-count-bus) 152 | dur (buf-rd:kr 1 duration-buf (mod cnt voices)) 153 | cutom-amp (buf-rd:kr 1 amp-buf (mod cnt pattern-size)) 154 | pos-frac (buf-rd:kr 1 pattern-buf (mod cnt pattern-size)) 155 | 156 | bar-trg (= beat-num (mod cnt voices)) 157 | amp (set-reset-ff bar-trg) 158 | 159 | width-frac (* (/ dur (buf-dur:ir buf)) rate) 160 | sig [(buf-rd:ar 1 buf (phasor:ar 0 161 | (* rate (buf-rate-scale:kr buf)) 162 | (* pos-frac (buf-samples:kr buf)) 163 | (+ (* pos-frac (buf-samples:kr buf) ) 164 | (* width-frac (buf-samples:kr buf)))) 165 | true 166 | inter)] 167 | env (env-gen:kr (env-perc) bar-trg 1 0 dur)] 168 | (out:ar out-bus (pan2 (* env amp cutom-amp sig))))) 169 | 170 | 171 | (defonce smooth-g (group "smooth grouping")) 172 | 173 | (def smooth-dur-buf (buffer voices)) 174 | (defonce smooth-amp-buf (buffer pattern-size)) 175 | (defonce smooth-post-frac-buf (buffer pattern-size)) 176 | 177 | (defsynth buf->smooth-inst [out-bus 0 buf [0 :ir] rate 1 inter 2 beat-num 0 178 | pattern-buf 0 pattern-size 3 179 | amp-buf 0 180 | duration-buf 0 181 | voices 3 182 | beat-count-bus 0] 183 | (let [cnt (in:kr beat-count-bus) 184 | dur (buf-rd:kr 1 duration-buf (mod cnt voices)) 185 | custom-amp (buf-rd:kr 1 amp-buf (mod cnt pattern-size)) 186 | pos-frac (buf-rd:kr 1 pattern-buf (mod cnt pattern-size)) 187 | bar-trg (= beat-num (mod cnt voices)) 188 | amp (set-reset-ff bar-trg) 189 | 190 | width-frac (* (/ dur 2 (buf-dur:ir buf)) rate) 191 | forward (buf-rd:ar 1 buf (phasor:ar 0 192 | (* (abs rate) (buf-rate-scale:kr buf)) 193 | (- (* width-frac (buf-samples:kr buf)) 194 | (* pos-frac (buf-samples:kr buf))) 195 | (+ (* width-frac (buf-samples:kr buf)) 196 | (* pos-frac (buf-samples:kr buf)))) 197 | 1 198 | inter) 199 | 200 | backward (buf-rd:ar 1 buf (phasor:ar 0 201 | (* -1 (abs rate) (buf-rate-scale:kr buf)) 202 | (+ (* width-frac (buf-samples:kr buf)) 203 | (* pos-frac (buf-samples:kr buf))) 204 | (- (* width-frac (buf-samples:kr buf)) 205 | (* pos-frac (buf-samples:kr buf)))) 206 | 1 207 | inter) 208 | 209 | sound (bi-pan-b2:ar forward backward (f-sin-osc:kr dur)) 210 | env (env-gen:kr (env-sine) bar-trg 1 0 dur)] 211 | (out out-bus (* env amp custom-amp sound)))) 212 | 213 | (defn make-perc 214 | ([lib] (make-perc lib 3)) 215 | ([lib voices] 216 | (doall 217 | (map 218 | (fn [n] 219 | (buf->perc-inst 220 | [:head perc-g] 221 | :buf (rand-nth lib) 222 | :rate 1 223 | :beat-num n 224 | :pattern-size (buffer-size perc-post-frac-buf) 225 | :pattern-buf perc-post-frac-buf 226 | :amp-buf perc-amp-buf 227 | :duration-buf perc-dur-buf 228 | :voices voices 229 | :beat-count-bus (:count tim/main-beat)) 230 | perc-g) 231 | (range 0 voices))))) 232 | 233 | (defn make-smooth 234 | ([lib] (make-smooth lib 3)) 235 | ([lib voices] 236 | (doall 237 | (map 238 | (fn [n] 239 | (buf->smooth-inst 240 | [:head smooth-g] 241 | :buf (rand-nth lib) 242 | :rate 1 243 | :beat-num n 244 | :pattern-size (buffer-size smooth-post-frac-buf) 245 | :pattern-buf smooth-post-frac-buf 246 | :amp-buf smooth-amp-buf 247 | :duration-buf smooth-dur-buf 248 | :voices voices 249 | :beat-count-bus (:count tim/main-beat))) 250 | (range 0 voices))))) 251 | 252 | (defn resize-pattern [old-buf group new-size synth-ctl] 253 | (let [size (buffer-size old-buf) 254 | new-buf (buffer new-size) 255 | old-vals (buffer-read old-buf)] 256 | (buffer-write! new-buf (take new-size (cycle old-vals))) 257 | (ctl group synth-ctl new-buf :pattern-size new-size) 258 | (buffer-free old-buf) 259 | new-buf)) 260 | 261 | (defn spin-durations-for-voice [voice buf] 262 | (buffer-write! buf voice [(rand-nth durations)])) 263 | 264 | (def pattern-size (rand-nth pattern-sizes)) 265 | 266 | (def smooth-post-frac-buf (resize-pattern smooth-post-frac-buf smooth-g pattern-size :pattern-buf)) 267 | (def smooth-amp-buf (resize-pattern smooth-amp-buf smooth-g pattern-size :amp-buf)) 268 | 269 | (buffer-write! smooth-dur-buf (take voices (repeatedly #(do 1)))) 270 | (buffer-write! smooth-amp-buf (take pattern-size (repeatedly #(ranged-rand 1 3)))) 271 | (buffer-write! smooth-post-frac-buf (take pattern-size (repeatedly #(/ (rand 512) 512)))) 272 | 273 | (def ss (make-smooth [rf-beat-it-s] voices)) 274 | 275 | 276 | (def perc-post-frac-buf (resize-pattern perc-post-frac-buf perc-g pattern-size :pattern-buf)) 277 | (def perc-amp-buf (resize-pattern perc-amp-buf perc-g pattern-size :amp-buf)) 278 | 279 | (buffer-write! perc-dur-buf (take voices (repeatedly #(rand-nth durations)))) 280 | (buffer-write! perc-amp-buf (take pattern-size (repeatedly #(ranged-rand 1 3)))) 281 | (buffer-write! perc-post-frac-buf (take pattern-size (repeatedly #(/ (rand 512) 512)))) 282 | 283 | (def gs (make-perc [constant-blues-s death-s dreamers-of-the-dreams-s afraid-s one-moment-please-s] voices)) 284 | 285 | (spin-durations-for-voice (rand-int voices) perc-dur-buf) 286 | (spin-durations-for-voice (rand-int voices) smooth-dur-buf) 287 | 288 | (kill smooth-g) 289 | (kill perc-g) 290 | 291 | (stop) 292 | 293 | (comment 294 | ;;Part of chaos 295 | (def perc-amp (buffer-read perc-amp-buf)) 296 | (def smooth-amp (buffer-read smooth-amp-buf)) 297 | 298 | (buffer-write! perc-amp-buf (take pattern-size (cycle [0]))) 299 | (buffer-write! smooth-amp-buf (take pattern-size (cycle [0]))) 300 | 301 | (buffer-write! perc-amp-buf [0.2 0.5 0.2 0.5]) 302 | 303 | (buffer-write! perc-amp-buf perc-amp) 304 | (buffer-write! smooth-amp-buf perc-amp)) 305 | --------------------------------------------------------------------------------