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 whilst.song | |
(:require [overtone.live :refer :all] | |
[leipzig.melody :refer :all] | |
[leipzig.scale :as scale] | |
[leipzig.live :as live] | |
[leipzig.chord :as chord] | |
[leipzig.temperament :as temperament])) | |
; Instruments | |
(definst bass [freq 110 dur 1 volume 1.0] |
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
when : (test : Bool) -> a -> b -> if test then a else b | |
when True x _ = x | |
when False _ y = 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
locate : Eq a => (key : a) -> (entries : List (a, b)) -> {auto membership : Elem key (map Prelude.Basics.fst entries)} -> b | |
locate {membership} _ [] = absurd membership | |
locate {membership = Here} key ((key, value) :: _) = value | |
locate {membership = (There later)} key (_ :: entries) = locate key entries {membership = later} |
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
; Why Clojure? | |
; | |
; * Interactive | |
; * Succinct | |
; * Consistent | |
; * Java interoperability | |
; Try Clojure is an online "repl", where you can try out Clojure expressions. | |
; http://tryclj.com/ |
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 takes [dish minutes] | |
(-> dish (update-in [:time] #(+ % minutes)))) | |
(defn sit [minutes] | |
(fn [dish] (-> dish (takes minutes)))) | |
(defn add [ingredient attributes] | |
(fn [dish] (-> dish (assoc ingredient attributes) (takes 1)))) | |
(defn water-for [ingredient] |
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
(ns kraftwerk.die-mensch-machine.space-lab | |
(:use | |
[leipzig.melody] | |
[leipzig.live] | |
[leipzig.chord] | |
[leipzig.canon] | |
[overtone.inst.sampled-piano] | |
[leipzig.scale]) | |
(:require | |
[overtone.live :as overtone])) |