rsc3/oregano/routing.rkt

89 lines
1.9 KiB
Racket
Raw Normal View History

2014-05-01 19:21:18 +00:00
#lang racket
2014-05-29 16:07:17 +00:00
(require rsc3)
2014-05-01 19:21:18 +00:00
#|
tracks:
0 - output left speaker
1 - output right speaker
3 - first track
## example usage
; add reverb to track 3
(append-effect track3 (reverb-effect 0.5 0.9))
(append-effect track3 (reverb-effect 0.5 0.9))
; done internally:
; (process-track 3)
(define my-piano (make-instrument "piano"))
(note-on my-piano C#3 track3)
|#
2014-05-08 00:08:32 +00:00
(define num-tracks 8)
(define tracks (make-vector num-tracks '()))
;; returns the effect list for a given track
;; track-num is 1-based
(define (get-track-effects track-num)
(vector-ref tracks track-num))
2014-05-01 19:21:18 +00:00
;; adds an effect to the end of the effect chain of the given track
(define (append-effect track-num effect-ugen)
2014-05-08 00:08:32 +00:00
(define current-effects (get-track-effects track-num))
(vector-set! tracks track-num
(append current-effects (list effect-ugen))))
(append-effect 3 'reverb)
(append-effect 3 'echo)
2014-05-01 19:21:18 +00:00
2014-05-14 03:54:20 +00:00
2014-05-01 19:21:18 +00:00
;; creates a ugen that is routed
;; in-bus: input bus channel
;; out-bus: output bus channel
(define (make-effect-ugen effect-ugen in-bus out-bus)
; TODO
empty)
;; example effect ugen
#;(audition (out 0 (free-verb (in 1 ar 16) 0.5
(mouse-y kr 0 1 0 0.1)
0.5)))
2014-05-29 16:07:17 +00:00
;; ======= Effects ==========
2014-05-01 19:21:18 +00:00
2014-05-29 16:07:17 +00:00
(define (apply-effect bus effect)
(audition (replace-out bus effect)))
2014-05-08 00:08:32 +00:00
2014-05-29 17:51:40 +00:00
#;(define-syntax-rule (define-effect name ugen)
(define (name bus)
(apply-effect bus ugen)))
2014-05-29 16:07:17 +00:00
(define (reverb bus)
(apply-effect bus
(free-verb (in 1 ar bus)
0.5
(mouse-y kr 0 1 0 0.1)
0.5)))
2014-05-08 00:08:32 +00:00
2014-05-29 16:07:17 +00:00
; example: apply reverb on bus 0
; (reverb 0)
2014-05-08 00:08:32 +00:00
2014-05-29 16:07:17 +00:00
(define (moog-filter bus freq [resonance 3] [opt 0])
(apply-effect bus
(moog-ff (in 1 ar bus) freq resonance opt)))
2014-05-08 00:08:32 +00:00
2014-05-29 17:51:40 +00:00
(define (delay bus delay-time decay-time)
(apply-effect bus
(comb-n (in 1 ar bus) delay-time delay-time decay-time)))
2014-05-01 19:21:18 +00:00
2014-05-29 16:07:17 +00:00
; (add-effect track0 (reverb 0.3 6)
2014-05-01 19:21:18 +00:00