added note-on and note-off

This commit is contained in:
Mustafa 2014-05-15 15:34:43 -07:00
parent 02c38b19d3
commit b54f9c8746

View file

@ -17,7 +17,7 @@
current-node-id) current-node-id)
(define (instrument wave-func) (define (wave-instrument wave-func)
(letc ([bus 0] (letc ([bus 0]
[freq 440]) [freq 440])
(out bus (mul 0.2 (wave-func ar freq 0))))) (out bus (mul 0.2 (wave-func ar freq 0)))))
@ -41,7 +41,8 @@
;; send synthdefs ;; send synthdefs
(with-sc3 (lambda (fd) (with-sc3 (lambda (fd)
(send-synth fd "sin-inst" sin-instrument))) (send-synth fd "sin-inst" (wave-instrument sin-osc))
(send-synth fd "saw-inst" saw-instrument)))
(define (make-instrument ins) (define (make-instrument ins)
@ -53,6 +54,14 @@
node-id)] node-id)]
[else (error "unknown instrument used")])) [else (error "unknown instrument used")]))
(define (note-on inst freq track)
(send-msg (n-set1 inst "freq" freq))
(send-msg (n-set1 inst "bus" track))
(send-msg (n-run1 inst 1)))
(define (note-off inst)
(send-msg (n-run1 inst 0)))
#| #|
- to stop/run: - to stop/run:
@ -69,5 +78,10 @@
(define my-sin (make-instrument 'sin)) (define my-sin (make-instrument 'sin))
;; example:
; (note-on my-sin 500 1)
; (note-off my-sin)