Skip to content

Commit

Permalink
Clean up examples
Browse files Browse the repository at this point in the history
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
  • Loading branch information
jfhamlin committed Apr 20, 2024
1 parent 416c432 commit 8efbaf6
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 144 deletions.
7 changes: 0 additions & 7 deletions examples/basic_beat.glj

This file was deleted.

2 changes: 1 addition & 1 deletion examples/bitcrush.glj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns user
(:require [mrat.core :refer :all]))
(:require [mrat.core :refer :all]))

(play (-> (saw [100 150 202 304 606] :mul 0.5 :iphase [0.2 0 0.5])
(bitcrush :bits (step (impulse 8) [3 2 16 5]))
Expand Down
3 changes: 0 additions & 3 deletions examples/drone.glj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
(drone 1/11 [A4 C#4] [5 5])
(drone 1/7 [E4 B4] [5 4])
)
(+ (-> (pink-noise)
(* 0.1)
(rhpf (mtof B8) (sin 1/10 :mul 0.5 :add 0.6))))
(freeverb :room-size 0.6)
(* 0.2)
limiter))
8 changes: 4 additions & 4 deletions examples/drumcircle.glj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

(def notes (map mtof [Eb5 B3 C2 D5 B2 C3 G4 A3]))
(def prog (step trig notes))
(play (-> (saw prog :mul 0.2)
(play (-> (sin prog :mul 0.2)
(combc 2 0.014 1)
(* 0.7)
(* 0.5)
(rlpf 300 0.3)
(+ (-> (play-buf :loop_amen_full :rate (step trig [0.4 1 0.1 2 1.5 0.6 0.25]) :trigger trig :mul 0.1)
(rhpf 1500 0.05 :mul 0.3)))
(freeverb :room-size 0.75)))
(rhpf 1400 0.15 :mul 0.2)))
(freeverb :room-size 0.1)))
2 changes: 1 addition & 1 deletion examples/fm.glj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(let [offset (choose gate [0 0 0 0 0 0 12 12 12 24])]
(step gate
(->> mixolydian
(map #(+ D0 % offset))
(map #(+ D2 % offset))
(map mtof)))))

(def op-conf
Expand Down
19 changes: 9 additions & 10 deletions examples/ihylp.glj
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

(def notes
(map #(+ % offset) [E8 D8 B7 A7 G7 F#7
E7 D7 B6 A6 G6 F#6
E6 D6 B5 A5 G5 F#5
E5 D5 B4 A4 G4 F#4
E4 D4 B3 G3
E3 D3 B2 G2
E2 B1
E1]))
E7 D7 B6 A6 G6 F#6
E6 D6 B5 A5 G5 F#5
E5 D5 B4 A4 G4 F#4
E4 D4 B3 G3
E3 D3 B2 G2
E2 B1
E1]))

(def rand-source (math$rand.NewSource 214))
(def mrand (math$rand.New rand-source))

(defn synth
[rate note]
(let [osc (sqr (mtof note) :duty 0.2)
(let [osc (sin (mtof note) :duty 0.2)
trig (impulse rate :iphase (.Float64 mrand))
amp (env trig [0 1 1 0] [0.01 0.02 0.1])]
(* osc amp)))
Expand All @@ -33,8 +33,7 @@
(-> (map #(-> (synth (/ bps (+ 1 (* speed-factor %1))) %2)
(pan2 (/ %1 (count notes)))) (range (count notes)) notes)
(sum)
(* (/ 1 (inc (count notes))))
(* 4)
(* (/ 4 (inc (count notes))))
(freeverb :room-size 0.5)))

(play ihylpr)
60 changes: 1 addition & 59 deletions examples/karplus_strong.glj
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
(ns karplus_strong
(:require [mrat.core :refer :all]))

(defn supersaw
"SuperSaw (Roland JP-8000 and JP-8080)

Ported from https://gist.github.com/audionerd/fe50790b7601cba65ddd855caffb05ad"
([freq] (supersaw freq 0.75))
([freq mix] (supersaw freq mix 0.75))
([freq mix detune]
(letfn [(detune-curve [x]
(+ (* 10028.7312891634 (pow x 11))
(* -50818.8652045924 (pow x 10))
(* 111363.4808729368 (pow x 9))
(* -138150.6761080548 (pow x 8))
(* 106649.6679158292 (pow x 7))
(* -53046.9642751875 (pow x 6))
(* 17019.9518580080 (pow x 5))
(* -3425.0836591318 (pow x 4))
(* 404.2703938388 (pow x 3))
(* -24.1878824391 (pow x 2))
(* 0.6717417634 x)
0.0030115596))
(center-gain [x] (+ (* -0.55366 x) 0.99785))
(side-gain [x] (+ (* -0.73764 (pow x 2)) (* 1.2841 x) 0.044372))]
(let [center (saw freq :iphase (math$rand.Float64))
detune-factor (* freq (detune-curve detune))
freqs [(+ freq (* detune-factor 0.11002313))
(+ freq (* detune-factor 0.06288439))
(+ freq (* detune-factor 0.01952356))
(+ freq (* detune-factor 0.01991221))
(+ freq (* detune-factor 0.06216538))
(+ freq (* detune-factor 0.10745242))]
side (sum (map #(saw % :iphase (math$rand.Float64)) freqs))
sig (+ (* center (center-gain mix)) (* side (side-gain mix)))]
sig))))

(:require [mrat.core :refer :all]))

(def fade-in-time 60)

(def metro (impulse 10))
(def metro-bass (impulse 5))
(def metro-kick (impulse 2.5))

(def burst (-> (pink-noise)
(* (env-adsr metro [0.001 0.001 1 0.001]))
Expand All @@ -57,29 +20,8 @@
(pipeset! feedback (+ burst delay-filter))

(play (-> feedback
;;(* (sin 0.1 :mul 20 :add 25))
wfold
(* 0)
(loshelf 20 :db -20)
(rhpf 1200)
(hishelf 12000 :db -90)
limiter))

(def bass-line [0 2 7 3 12 10 0 2 3 11])
(defn bass-synth
[gate freq]
(let [osc (supersaw freq 0.75 0.7)
amp (env gate [0.0001 1 1 0.0001] [0.01 0.1 0.01] :interp :exp)
hicut (* freq 8)
locut (* freq 1)
cutoff (env gate [locut hicut hicut locut] [0.02 0.08 0.01] :interp :exp)]
(-> osc
(* 0.1)
(rlpf cutoff 0.2)
(* amp))))

(play (-> (bass-synth metro-bass (step metro-bass (map #(mtof (+ F1 %)) bass-line)))
(* 0.8)))

(play (-> (play-buf :bass_thick_c :trigger metro-kick :rate 0.5)
(rlpf 800 0.4 :mul 0.75)))
1 change: 0 additions & 1 deletion examples/micin.glj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
(:require [mrat.core :refer :all]))

(play (-> (sound-in)
(bpf 400 1)
(delayc 1 0.5)))
4 changes: 0 additions & 4 deletions examples/ping.glj

This file was deleted.

14 changes: 0 additions & 14 deletions examples/simple.glj

This file was deleted.

29 changes: 0 additions & 29 deletions examples/simplesin.glj

This file was deleted.

6 changes: 3 additions & 3 deletions examples/st.glj
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
(let [amp (dbamp drone-env)
freq (* root (octaves -1))]
(-> (sum (repeatedly
16
#(saw (* freq (semitones (* 0.2 (noise-quad 8))))
:iphase (math$rand.Float64))))
16
#(saw (* freq (semitones (* 0.2 (noise-quad 8))))
:iphase (math$rand.Float64))))
(lores (* 2 freq) 0.8)
(* amp))))

Expand Down
6 changes: 3 additions & 3 deletions examples/sunset.glj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
0 0 0 0 0 0
])

(def root-midi 40)
(def root-midi 50)

(def metro (impulse 4))
(def metro (impulse 6))

(def metro-slo (impulse 0.1))

Expand All @@ -34,7 +34,7 @@
]) %)) intervals)))

(def hi-pad
(-> (sum (map #(saw % :iphase (math$rand.Float64)) (map #(mtof (+ root-midi 24 %)) [-2 0 7.1 3 12.1 24.1 35.9])))
(-> (sum (map #(sqr % :iphase (math$rand.Float64)) (map #(mtof (+ root-midi 24 %)) [-2 0 7.1 3 12.1 24.1 35.9])))
(* 0.2)
(lores (mtof (+ root-midi 12 24 (lfpulse 1/8 :mul 24))) res)
(* (env-adsr metro-slo [1 2 0.5 6]))
Expand Down
5 changes: 0 additions & 5 deletions examples/test.glj

This file was deleted.

0 comments on commit 8efbaf6

Please sign in to comment.