small changes

This commit is contained in:
Mustafa 2014-05-28 22:41:53 -07:00
parent 12a9447ef4
commit d4eb5691c1
6 changed files with 65 additions and 52 deletions

View file

@ -2,21 +2,34 @@
(require oregano) (require oregano)
(display "start\n")
#|
(define my-note (play-note "sin-inst" 440)) (define my-note (play-note "sin-inst" 440))
(sleep 1) (sleep 1)
;; stop playing note ;; stop playing note
(note-off my-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)) (define my-note2 (make-note "sin-inst" 880))
(note-on my-note2) (note-on my-note2)
(sleep 1) (sleep 1)
(note-off my-note2) (note-off my-note2)
|# )
#|
(make-instrument "my-inst" ([freq 500] [mod 20]) (make-instrument "my-inst" ([freq 500] [mod 20])
(mul (sin-osc ar mod 0) (mul (sin-osc ar mod 0)
(sin-osc ar freq 0))) (sin-osc ar freq 0)))
@ -27,3 +40,5 @@
(set-note-param weird-note "mod" val))) (set-note-param weird-note "mod" val)))
(show-gui) (show-gui)
|#

View file

@ -67,13 +67,9 @@
[callback (lambda (element event) [callback (lambda (element event)
(func (gui:send element get-value)))])) (func (gui:send element get-value)))]))
#;(new gui:check-box% (define (note-button the-note name)
[label "note-on"] (new gui:button% [parent frame]
[parent frame] [label name]
[value #f] [callback (lambda (s event)
[callback (lambda (element event) (display event))]))
(if (gui:send element get-value)
(send-msg (n-run1 1001 1))
(send-msg (n-run1 1001 0))))])

View file

@ -1,7 +1,7 @@
#lang racket #lang racket
(require rsc3) (require rsc3 "system.rkt")
(provide (provide
(all-from-out rsc3)) (all-from-out rsc3))
@ -11,6 +11,7 @@
;; TODO - remove. using "signal-slider" for testing ;; TODO - remove. using "signal-slider" for testing
(require "gui.rkt") (require "gui.rkt")
(run-super-collider)
(define current-node-id 1000) (define current-node-id 1000)
@ -47,7 +48,7 @@
(mul (saw ar freq) 0.1) (mul (saw ar freq) 0.1)
(mouse-y kr 200 30000 1 0.1) 3 0)))) (mouse-y kr 200 30000 1 0.1) 3 0))))
;; TODO ;; other way
#;(define (make-instrument name graph) #;(define (make-instrument name graph)
(let ([sd (letc ([bus 0]) (let ([sd (letc ([bus 0])
(out bus ugen))] (out bus ugen))]
@ -77,34 +78,33 @@
("moog-inst" ,moog-instrument))) ("moog-inst" ,moog-instrument)))
;; send synthdefs ;; send synthdefs
(map (lambda (pair) (for ([pair perset-instrument-map])
(with-sc3 (lambda (fd) (with-sc3 (lambda (fd)
(send-synth fd (first pair) (second pair))))) (send-synth fd (first pair) (second pair)))))
perset-instrument-map)
; === user note funcs === ; === user note funcs ===
(struct note (id [freq #:mutable])) (struct note (id [freq #:mutable]) #:transparent)
(define (create-synth name play-on-start) (define (create-synth name play-on-start)
(define node-id (gen-node-id)) (define node-id (gen-node-id))
(send-msg (s-new0 name node-id 1 1)) (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 ; don't make sound upon creation
(if play-on-start (if play-on-start
empty empty
(send-msg (n-run1 node-id 0))) (send-msg (n-run1 node-id 0)))
node-id) 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 (make-note/option inst-name freq play-on-start)
(define node-id (create-synth inst-name play-on-start)) (define id (create-synth inst-name play-on-start))
(note node-id freq)) (send-msg (n-set1 id "freq" freq))
(note id freq))
(define (play-note inst-name freq) (define (play-note inst-name freq)
(make-note/option inst-name freq #t)) (make-note/option inst-name freq #t))
@ -117,17 +117,20 @@
(define (note-on the-note) (define (note-on the-note)
;(send-msg (n-set1 inst "bus" track)) ; TODO ;(send-msg (n-set1 inst "bus" track)) ; TODO
(send-msg (n-run1 (note-id the-note) 1)) (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) (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) (define (set-note-param the-note name val)
(if (eq? name "freq") (if (eq? name "freq")
(set-note-freq! the-note val) (set-note-freq! the-note val)
empty) empty)
(send-msg (n-set1 (note-id the-note) name val))) (send-msg (n-set1 (note-id the-note) name val))
(void))
@ -162,3 +165,4 @@
; (note-off my-sin) ; (note-off my-sin)
|# |#

View file

@ -1,6 +1,5 @@
#lang racket #lang racket
(require "instrument.rkt" (require "instrument.rkt"
"gui.rkt" "gui.rkt"
"sample.rkt" "sample.rkt"
@ -9,7 +8,8 @@
;; setup ;; setup
(require rsc3) (require rsc3)
;; FIXME - not running
(display "Hello! from main.rkt\n")
(run-super-collider) (run-super-collider)

View file

@ -8,7 +8,4 @@ sleep 1
jack_connect -s default SuperCollider:out_1 system:playback_1 jack_connect -s default SuperCollider:out_1 system:playback_1
jack_connect -s default SuperCollider:out_2 system:playback_2 jack_connect -s default SuperCollider:out_2 system:playback_2
# go to scsynth
fg

View file

@ -6,13 +6,14 @@
;; run scsynth ;; run scsynth
(define (run-super-collider) (define (run-super-collider)
(display "in run-super-collider\n")
(match (system-type 'os) (match (system-type 'os)
('unix (if (system "ps -e | grep scsynth > /dev/null") ('unix (if (system "ps -e | grep scsynth > /dev/null")
(display "SuperCollider Running\n") (display "SuperCollider Running\n")
(begin (begin
(display "Starting SuperCollider...") (display "Starting SuperCollider...")
(process "./start_server_linux.sh") (process "./start_server_linux.sh")
(sleep 0.3) (sleep 0.5)
(if (system "ps -e | grep scsynth > /dev/null") (if (system "ps -e | grep scsynth > /dev/null")
(display "OK") (display "OK")
(display "Error"))))) (display "Error")))))