-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo-play-synth.rkt
More file actions
55 lines (36 loc) · 1002 Bytes
/
Copy pathdemo-play-synth.rkt
File metadata and controls
55 lines (36 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#lang racket
(require "init.rkt")
;; show osc messages in server's terminal
(send-osc-message #"/dumpOSC" '(1))
;; clears nodes on server
(reset)
;; example usage:
(printf "press enter to make sound\n")
(define temp1 (read-line))
(send-synthdef "basic_sin.scsyndef")
;; should wait for /done message
(sleep 0.5)
;; synth should start playing after this
(define my-sin (synth-new "basic_sin"))
;; get node id
; (synth-node-id my-sin)
(printf "Press enter to change frequency\n")
(define temp2 (read-line))
;; change freq
(synth-set-params my-sin (list #"freq" 500))
(printf "Press enter to stop playing synth\n")
(read-line)
;; stop playing
(synth-stop my-sin)
;; delete synth object (stops sound)
;; (synth-delete my-sin)
(printf "Press enter to play scale\n")
(read-line)
;; stop playing
(synth-play my-sin)
;; play a scale
(for [(x (range 12))]
(begin (synth-set-params my-sin (list #"freq" (* 220 (expt 2 (/ x 6)))))
(sleep 0.2)))
(sleep 0.5)
(synth-stop my-sin)