added sliders
This commit is contained in:
parent
e35dc88845
commit
b3236c87fd
2 changed files with 53 additions and 11 deletions
|
@ -123,7 +123,11 @@ When the mouse is at the left of the screen, the frequency is 200, when the mous
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Sliders
|
||||||
|
|
||||||
|
|
||||||
|
(add-effect track3 (low-pass-filter resonance
|
||||||
|
(slider : 200 500)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,56 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
|
|
||||||
(require rsc3 rhs/rhs)
|
(require rsc3 rhs/rhs)
|
||||||
|
|
||||||
|
|
||||||
|
;; --- gui stuff
|
||||||
|
|
||||||
|
(require (prefix-in gui: racket/gui))
|
||||||
|
|
||||||
|
(define frame (new gui:frame% [label "Example"]))
|
||||||
|
|
||||||
|
;; parent should be a frame
|
||||||
|
(new gui:slider% [parent frame]
|
||||||
|
[label "freq"]
|
||||||
|
[min-value 300]
|
||||||
|
[max-value 1000]
|
||||||
|
[init-value 400]
|
||||||
|
;; callback receives the slider object and an event object
|
||||||
|
[callback (lambda (s event)
|
||||||
|
(send-msg (n-set1 1001 "freq" (gui:send s get-value))))])
|
||||||
|
|
||||||
|
(gui:send frame show #t)
|
||||||
|
|
||||||
|
|
||||||
;; simplifies sending messages to server
|
;; hypothetical usage
|
||||||
|
#;(add-filter track2 (lpf #:resonance .3
|
||||||
|
#:cutoff (slider 300 800 500)))
|
||||||
|
|
||||||
|
(define (slider min-n max-n init)
|
||||||
|
(define bus-id 16)
|
||||||
|
|
||||||
|
(new gui:slider% [parent frame]
|
||||||
|
[label "amp"]
|
||||||
|
[min-value min-n]
|
||||||
|
[max-value max-n]
|
||||||
|
[init-value init]
|
||||||
|
;; callback receives the slider object and an event object
|
||||||
|
[callback (lambda (s event)
|
||||||
|
(send-msg
|
||||||
|
(c-set1 bus-id (/ (gui:send s get-value) 1000))))])
|
||||||
|
|
||||||
|
|
||||||
|
(in 1 kr bus-id))
|
||||||
|
|
||||||
|
; -------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; simplifies sending osc messages to server
|
||||||
(define (send-msg msg)
|
(define (send-msg msg)
|
||||||
(with-sc3 (lambda (fd)
|
(with-sc3 (lambda (fd)
|
||||||
(send fd msg))))
|
(send fd msg))))
|
||||||
|
|
||||||
(define current-node-id 1000)
|
(define current-node-id 1000)
|
||||||
(define (gen-node-id)
|
(define (gen-node-id)
|
||||||
|
@ -25,7 +66,7 @@
|
||||||
(define sin-instrument
|
(define sin-instrument
|
||||||
(letc ([bus 0]
|
(letc ([bus 0]
|
||||||
[freq 440])
|
[freq 440])
|
||||||
(out bus (mul 0.2 (sin-osc ar freq 0)))))
|
(out bus (mul (slider 100 800 200) (sin-osc ar freq 0)))))
|
||||||
|
|
||||||
(define saw-instrument
|
(define saw-instrument
|
||||||
(letc ([bus 0]
|
(letc ([bus 0]
|
||||||
|
@ -41,7 +82,7 @@
|
||||||
|
|
||||||
;; send synthdefs
|
;; send synthdefs
|
||||||
(with-sc3 (lambda (fd)
|
(with-sc3 (lambda (fd)
|
||||||
(send-synth fd "sin-inst" (wave-instrument sin-osc))
|
(send-synth fd "sin-inst" sin-instrument) ; (wave-instrument sin-osc))
|
||||||
(send-synth fd "saw-inst" saw-instrument)))
|
(send-synth fd "saw-inst" saw-instrument)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,10 +108,6 @@
|
||||||
- to stop/run:
|
- to stop/run:
|
||||||
(send-msg (n-run1 1001 1))
|
(send-msg (n-run1 1001 1))
|
||||||
|
|
||||||
-
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|#
|
|#
|
||||||
|
|
||||||
;; ======== test run ===========
|
;; ======== test run ===========
|
||||||
|
@ -85,3 +122,4 @@
|
||||||
; (note-off my-sin)
|
; (note-off my-sin)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue