Created
April 12, 2015 22:29
-
-
Save ctford/b61f513483717e07411d to your computer and use it in GitHub Desktop.
An unhygienic macro for generating the standard template I use for instruments.
This file contains hidden or 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) | |
(simple :frequency 220 :position 1 :duration 5.0 :vibrato 5.0)" | |
[instrument extra-params oscillator envelope] | |
`(definst ~instrument | |
[~'frequency 440 ~'duration 1.0 ~'volume 1.0 ~'position 0.0 ~'wet 0.3 ~@extra-params] | |
(-> ~oscillator ; Signal | |
(~'* (env-gen ~envelope (line:kr 1 0 ~'duration) :action FREE)) ; Envelope | |
(free-verb :mix (~'* 1/3 ~'wet) :room 0.1) ; Early reflections. | |
(free-verb :mix ~'wet :room 0.7) ; Proper reverb | |
(~'* ~'volume) ; Volume | |
(pan2 ~'position)))) ; Panning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment