Skip to content

Commit

Permalink
Update jam because the sampled piano is broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctford committed Jan 19, 2017
1 parent 6985048 commit 07e9f6c
Showing 1 changed file with 25 additions and 36 deletions.
61 changes: 25 additions & 36 deletions src/jazz/standards/in_the_mood.clj
@@ -1,42 +1,31 @@
(ns jazz.standards.in-the-mood
(:use leipzig.scale, leipzig.melody, leipzig.live, leipzig.chord
overtone.inst.sampled-piano
[overtone.live :only [at ctl sample freesound-path]]))

(defn in-time
"Transform both :time and :duration according to timing."
[timing notes]
(->> notes
(map (fn [{start :time, duration :duration, :as note}]
(-> note
(assoc :duration (- (timing (+ start duration))
(timing start))))))
(where :time timing)))

(defn mapthen [f & args]
(->> args
(apply map f)
(reduce #(then %2 %1))))

(defmethod play-note :beat
[note]
((sample (freesound-path 802))))

(defmethod play-note :default
[{midi :pitch, start :time, duration :duration}]
(let [id (sampled-piano midi)]
(at (+ start duration) (ctl id :gate 0))))
(ns jazz.standards.in-the-mood
(:use leipzig.scale, leipzig.melody, leipzig.live, leipzig.chord, leipzig.temperament
[overtone.live :only [FREE adsr line:kr sin-osc definst hpf lpf clip2 env-gen]]))

(def in-the-mood
(let [bassline []
hook []
beat (->> [] (where :part (is :beat)))]
(let [bassline []
hook []]
(->>
bassline
(with hook)
(where :pitch (comp low B flat major))
(with beat)
(in-time (bpm 90)))))
bassline
(with hook)
(where :pitch (comp equal low B flat major))
(tempo (bpm 90)))))

(comment (jam (var in-the-mood)))
(comment (def in-the-mood nil))

(defmethod play-note :default
[{midi :pitch seconds :duration}]
(-> midi (overchauffeur seconds 1500)))

(definst overchauffeur [freq 110 dur 1.0 top 1500 vol 0.25]
(-> (sin-osc freq)
(+ (* 1/3 (sin-osc (* 2.01 freq))))
(+ (* 1/2 (sin-osc (* 3.01 freq))))
(+ (* 1/8 (sin-osc (* 5.01 freq))))
(+ (* 2 (sin-osc (* 0.5 freq))))
(clip2 0.7)
(lpf top)
(hpf 20)
(* (env-gen (adsr 0.01 0.2 0.8 0.2) (line:kr 1 0 dur) :action FREE))
(* vol)))

0 comments on commit 07e9f6c

Please sign in to comment.