From d4eb5691c136e28eb93f22a6ee50c156d22aedd6 Mon Sep 17 00:00:00 2001 From: Mustafa Date: Wed, 28 May 2014 22:41:53 -0700 Subject: [PATCH] small changes --- oregano/examples/instrument-example.rkt | 25 +++++++-- oregano/gui.rkt | 14 ++--- oregano/instrument.rkt | 68 +++++++++++++------------ oregano/main.rkt | 4 +- oregano/start_server_linux.sh | 3 -- oregano/system.rkt | 3 +- 6 files changed, 65 insertions(+), 52 deletions(-) diff --git a/oregano/examples/instrument-example.rkt b/oregano/examples/instrument-example.rkt index 39f8f84..1e1cb7b 100644 --- a/oregano/examples/instrument-example.rkt +++ b/oregano/examples/instrument-example.rkt @@ -2,21 +2,34 @@ (require oregano) - -#| +(display "start\n") (define my-note (play-note "sin-inst" 440)) (sleep 1) ;; stop playing note (note-off my-note) +(display "end note1\n") + +(define my-note2 (play-note "saw-inst" 880)) +(sleep 2) +(note-off my-note2) +(display "end note2\n") + +(sleep 1) + +(define my-note3 (play-note "sin-inst" 500)) +(sleep 1) +;; stop playing note +(note-off my-note3) - +#;( (define my-note2 (make-note "sin-inst" 880)) (note-on my-note2) (sleep 1) (note-off my-note2) -|# +) +#| (make-instrument "my-inst" ([freq 500] [mod 20]) (mul (sin-osc ar mod 0) (sin-osc ar freq 0))) @@ -26,4 +39,6 @@ (lambda (val) (set-note-param weird-note "mod" val))) -(show-gui) \ No newline at end of file +(show-gui) + +|# \ No newline at end of file diff --git a/oregano/gui.rkt b/oregano/gui.rkt index 3e0b940..06ab07c 100644 --- a/oregano/gui.rkt +++ b/oregano/gui.rkt @@ -67,13 +67,9 @@ [callback (lambda (element event) (func (gui:send element get-value)))])) -#;(new gui:check-box% - [label "note-on"] - [parent frame] - [value #f] - [callback (lambda (element event) - (if (gui:send element get-value) - (send-msg (n-run1 1001 1)) - (send-msg (n-run1 1001 0))))]) - +(define (note-button the-note name) + (new gui:button% [parent frame] + [label name] + [callback (lambda (s event) + (display event))])) diff --git a/oregano/instrument.rkt b/oregano/instrument.rkt index 338d82d..c22175e 100644 --- a/oregano/instrument.rkt +++ b/oregano/instrument.rkt @@ -1,7 +1,7 @@ #lang racket -(require rsc3) +(require rsc3 "system.rkt") (provide (all-from-out rsc3)) @@ -11,6 +11,7 @@ ;; TODO - remove. using "signal-slider" for testing (require "gui.rkt") +(run-super-collider) (define current-node-id 1000) @@ -27,7 +28,7 @@ (letc ([bus 0] [freq 440]) (out bus (mul 0.2 (wave-func ar freq 0))))) - + (define sin-instrument (letc ([bus 0] [freq 440]) @@ -47,15 +48,15 @@ (mul (saw ar freq) 0.1) (mouse-y kr 200 30000 1 0.1) 3 0)))) -;; TODO +;; other way #;(define (make-instrument name graph) - (let ([sd (letc ([bus 0]) - (out bus ugen))] - ;[name (format "synth~a" current-node-id)] - ) - (with-sc3 (lambda (fd) - (send-synth fd name sd))) - )) + (let ([sd (letc ([bus 0]) + (out bus ugen))] + ;[name (format "synth~a" current-node-id)] + ) + (with-sc3 (lambda (fd) + (send-synth fd name sd))) + )) (define-syntax-rule (make-instrument inst-name ([argname argdefault] ...) ugen) (let ([sd (letc ([bus 0] @@ -68,8 +69,8 @@ ;; example of definst macro like overtone's definst #;(define-syntax-rule (define-instrument inst-name [[argname argdefault] ...] ugen) - (define (inst-name [argname argdefault] ...) - (+ argname ...))) + (define (inst-name [argname argdefault] ...) + (+ argname ...))) (define perset-instrument-map `(("sin-inst" ,sin-instrument) @@ -77,34 +78,33 @@ ("moog-inst" ,moog-instrument))) ;; send synthdefs -(map (lambda (pair) - (with-sc3 (lambda (fd) - (send-synth fd (first pair) (second pair))))) - perset-instrument-map) +(for ([pair perset-instrument-map]) + (with-sc3 (lambda (fd) + (send-synth fd (first pair) (second pair))))) + ; === user note funcs === -(struct note (id [freq #:mutable])) +(struct note (id [freq #:mutable]) #:transparent) (define (create-synth name play-on-start) (define node-id (gen-node-id)) (send-msg (s-new0 name node-id 1 1)) + ;; TODO - send in bundle. it run 0 may be sent after ; don't make sound upon creation (if play-on-start empty (send-msg (n-run1 node-id 0))) node-id) -#;(define (preset-instrument name) - (let ([node-id (gen-node-id)]) - (create-synth name node-id))) (define (make-note/option inst-name freq play-on-start) - (define node-id (create-synth inst-name play-on-start)) - (note node-id freq)) + (define id (create-synth inst-name play-on-start)) + (send-msg (n-set1 id "freq" freq)) + (note id freq)) (define (play-note inst-name freq) (make-note/option inst-name freq #t)) @@ -117,30 +117,33 @@ (define (note-on the-note) ;(send-msg (n-set1 inst "bus" track)) ; TODO (send-msg (n-run1 (note-id the-note) 1)) - (send-msg (n-set1 (note-id the-note) "freq" (note-freq the-note)))) + (send-msg (n-set1 (note-id the-note) "freq" (note-freq the-note))) + (void)) (define (note-off the-note) - (send-msg (n-run1 (note-id the-note) 0))) + (send-msg (n-run1 (note-id the-note) 0)) + (void)) (define (set-note-param the-note name val) (if (eq? name "freq") (set-note-freq! the-note val) empty) - (send-msg (n-set1 (note-id the-note) name val))) + (send-msg (n-set1 (note-id the-note) name val)) + (void)) - - -#| + + + #| - to stop/run: (send-msg (n-run1 1001 1)) |# - - -;; ======== example useage =========== -#| + + + ;; ======== example useage =========== + #| (define my-sin (preset-instrument "sin-inst")) (param-slider "change frequency" 300 1000 400 @@ -162,3 +165,4 @@ ; (note-off my-sin) |# + \ No newline at end of file diff --git a/oregano/main.rkt b/oregano/main.rkt index 1336639..74584e1 100644 --- a/oregano/main.rkt +++ b/oregano/main.rkt @@ -1,6 +1,5 @@ #lang racket - (require "instrument.rkt" "gui.rkt" "sample.rkt" @@ -9,7 +8,8 @@ ;; setup (require rsc3) - +;; FIXME - not running +(display "Hello! from main.rkt\n") (run-super-collider) diff --git a/oregano/start_server_linux.sh b/oregano/start_server_linux.sh index 687a58e..cb860c2 100755 --- a/oregano/start_server_linux.sh +++ b/oregano/start_server_linux.sh @@ -8,7 +8,4 @@ sleep 1 jack_connect -s default SuperCollider:out_1 system:playback_1 jack_connect -s default SuperCollider:out_2 system:playback_2 -# go to scsynth -fg - diff --git a/oregano/system.rkt b/oregano/system.rkt index 21bbf42..8d7f96b 100644 --- a/oregano/system.rkt +++ b/oregano/system.rkt @@ -6,13 +6,14 @@ ;; run scsynth (define (run-super-collider) + (display "in run-super-collider\n") (match (system-type 'os) ('unix (if (system "ps -e | grep scsynth > /dev/null") (display "SuperCollider Running\n") (begin (display "Starting SuperCollider...") (process "./start_server_linux.sh") - (sleep 0.3) + (sleep 0.5) (if (system "ps -e | grep scsynth > /dev/null") (display "OK") (display "Error")))))