This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn synth [note] | |
(connect-> | |
(add (sawtooth (:pitch note))) | |
;(low-pass (connect-> (sine 4.5) (gain 660))) | |
(adsr 2.7 0.3 0.5 0.01) | |
(gain 0.15))) | |
(defn shorten [section] | |
(->> section (take-while #(-> % :time (< 8))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; A synthesiser we can play our piece on. | |
(defn synth [note] | |
(connect-> | |
(add (square (* 1.01 (:pitch note))) (sawtooth (:pitch note))) | |
(low-pass 600) | |
(adsr 0.001 0.4 0.5 0.1) | |
(gain 0.15))) | |
(def melody | |
; The durations and pitches of the notes. Try changing them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns leipzig-live.processing | |
(:require | |
[leipzig-live.music :as music] | |
[leipzig-live.instruments :as instrument] | |
[leipzig-live.actions :as action] | |
[leipzig-live.framework :as framework] | |
[cljs.js :as cljs])) | |
(defn add-namespace [expr-str] | |
(str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn factorial [n] | |
(letfn [(factorial' [n tally] | |
(if (zero? n) | |
tally | |
(factorial' (dec n) (* n tally))))] | |
(factorial' n 1))) | |
(defn factorial [n] | |
(letfn [(factorial' [n tally] | |
(if (zero? n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Welcome to Sonic Pi v2.8.0-dev-9d58e | |
use_bpm 120 | |
use_synth :blade | |
define :melody do |pitches, sleeps| | |
durations = sleeps.to_a # Make sure it's indexable. | |
pitches.each_with_index do |pitch, i| | |
play(pitch, sustain: durations[i] - 0.4) | |
sleep durations[i] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns traversy.lens | |
(:require [clojure.core.typed :as typed])) | |
(typed/defalias Focus | |
(typed/TFn [[a :variance :contravariant] [b :variance :covariant]] [a -> (typed/Option (typed/NonEmptySeq b))])) | |
(typed/defalias Fmap | |
(typed/TFn [[a :variance :invariant] [b :variance :invariant]] [[b -> b] a -> a])) | |
(typed/defalias Lens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dag is based on git's underlying directed acyclic graph of commits. | |
# | |
# There are "labels" (ie branches) that you can "extend" from (ie commit). | |
dag import "https://github..." # Clone a project from Github. | |
# cd project | |
# create some files | |
dag extend "Change some stuff" # Commit *all* changes (no staging of individual files). | |
dag label "bug-fix" # Create a branch, which is really just a label. | |
dag switch "bug-fix" # Checkout the new branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro deftrack | |
"Defines an instrument with frequency, duration, volume, position and wet pre-defined. | |
NB: these variables will shadow any instances in a wider scope. | |
(deftrack simple [vibrato 3] | |
(* (saw frequency) (sin-osc vibrato)) ; Signal | |
(adsr)) ; Envelope | |
(simple :frequency 440 :position -1 :wet 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns universe.core | |
(:require [om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(def app-state (atom {:text "Hello Boids" | |
:birds (map vector | |
(repeatedly 20 #(rand-int 1000)) | |
(repeatedly 20 #(rand-int 1000)))})) | |
(defn make-bird [[x y]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn integer [s] (java.lang.Integer/parseInt s)) | |
(defn parse [from-str] | |
(lens (fn [x] (-> x from-str list)) | |
(fn [f x] (-> x from-str f str)))) | |
(fact "The 'parse' lens focuses on a value in a string." | |
(-> "2015" (view (parse integer))) => [2015] | |
(-> "2015" (update (parse integer) inc)) => "2016") | |
(defn catching [thunk x] (try (thunk) (catch Exception e x))) |