added lpf, mouse/x,y
This commit is contained in:
parent
80822812c4
commit
0871d776c7
5 changed files with 80 additions and 40 deletions
|
@ -58,7 +58,7 @@ You can either use a preset instrument or define your own instrument. There are
|
||||||
;; stop playing note
|
;; stop playing note
|
||||||
(note-off my-note)
|
(note-off my-note)
|
||||||
```
|
```
|
||||||
|
<!--
|
||||||
Or you can create a note object then play it.
|
Or you can create a note object then play it.
|
||||||
|
|
||||||
```scheme
|
```scheme
|
||||||
|
@ -69,6 +69,7 @@ Or you can create a note object then play it.
|
||||||
(sleep 1)
|
(sleep 1)
|
||||||
(note-off my-note2)
|
(note-off my-note2)
|
||||||
```
|
```
|
||||||
|
-->
|
||||||
|
|
||||||
### 2. Creating an instrument
|
### 2. Creating an instrument
|
||||||
A custom instrument is composed of three parts:
|
A custom instrument is composed of three parts:
|
||||||
|
@ -120,7 +121,47 @@ For example, previous note, `weird-note`:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 4. Add filters to a track
|
||||||
|
|
||||||
|
You can add filters to a specific track.
|
||||||
|
|
||||||
|
Add a reverb to track 0. (currently only track 0 works.)
|
||||||
|
|
||||||
|
```scheme
|
||||||
|
(make-instrument "phone-inst" ([freq 500])
|
||||||
|
(mul (sin-osc ar (mul-add (lf-pulse ar 15 0 0.5) 200 freq) 0)
|
||||||
|
(mouse-button kr 0 0.1 0.1)))
|
||||||
|
|
||||||
|
;; click any mouse button to hear the note
|
||||||
|
(define phone-note (play-note "phone-inst" 600))
|
||||||
|
|
||||||
|
;; apply a reverb effect on track 0
|
||||||
|
(reverb 0 0.5)
|
||||||
|
|
||||||
|
(sleep 3)
|
||||||
|
|
||||||
|
(moog-filter 0 800)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### mouse/x and mouse/y
|
||||||
|
|
||||||
|
You can parameters to filters and instruments using the mouse.
|
||||||
|
|
||||||
|
(mouse/x start-value end-value)
|
||||||
|
|
||||||
|
For example, if you want to control the cutoff frequency for a filter using the left-right position of the mouse.
|
||||||
|
|
||||||
|
(low-pass-filter 0 (mouse/x kr 200 500)))
|
||||||
|
|
||||||
|
When the mouse is at the left of the screen, the frequency is 200, when the mouse is at the right, the frequency is 500.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
### Envelopes
|
### Envelopes
|
||||||
|
|
||||||
```scheme
|
```scheme
|
||||||
Didn't implement envelopes yet.
|
Didn't implement envelopes yet.
|
||||||
;; add envelope to instrument
|
;; add envelope to instrument
|
||||||
|
@ -129,27 +170,6 @@ Didn't implement envelopes yet.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3. Playing a note using a custom instrument
|
|
||||||
|
|
||||||
Now that we have an instrument, we can use it to play notes on a specific track.
|
|
||||||
|
|
||||||
```scheme
|
|
||||||
;; this plays the key C#, octave 3 on track 2.
|
|
||||||
(note-on my-piano C#3 track2)
|
|
||||||
|
|
||||||
;; to stop playing
|
|
||||||
(note-off my-piano C#3 track2)
|
|
||||||
|
|
||||||
;; TODO - find a way to turn off a note, or make a note play for a specific time
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### 4. Add filters to a track
|
|
||||||
|
|
||||||
You can add filters to a specific track.
|
|
||||||
|
|
||||||
(add-effect track3 (reverb 0.5 0.9))
|
|
||||||
|
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
@ -161,18 +181,6 @@ These can be used in defining instruments.
|
||||||
|
|
||||||
-
|
-
|
||||||
|
|
||||||
### mouse-x and mouse-y
|
|
||||||
|
|
||||||
You can parameters to filters and instruments using the mouse.
|
|
||||||
|
|
||||||
(mouse-x start-value end-value)
|
|
||||||
|
|
||||||
For example, if you want to control the cutoff frequency for a filter using the left-right position of the mouse.
|
|
||||||
|
|
||||||
(add-effect track3 (low-pass-filter resonance
|
|
||||||
(mouse-x kr 200 500)))
|
|
||||||
|
|
||||||
When the mouse is at the left of the screen, the frequency is 200, when the mouse is at the right, the frequency is 500.
|
|
||||||
|
|
||||||
### List of Filters
|
### List of Filters
|
||||||
|
|
||||||
|
|
21
oregano/examples/filters.rkt
Normal file
21
oregano/examples/filters.rkt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
(require oregano)
|
||||||
|
|
||||||
|
;; press 'a'
|
||||||
|
(make-instrument "my-inst" ([freq 500])
|
||||||
|
(mul (sin-osc ar (mul-add (lf-pulse ar 15 0 0.5) 200 freq) 0)
|
||||||
|
(mouse-button kr 0 0.1 0.1)))
|
||||||
|
|
||||||
|
(define phone-note (play-note "my-inst" 600))
|
||||||
|
|
||||||
|
(define track0 0)
|
||||||
|
|
||||||
|
(sleep 1)
|
||||||
|
|
||||||
|
(reverb track0 0.5)
|
||||||
|
|
||||||
|
(sleep 3)
|
||||||
|
|
||||||
|
|
||||||
|
(moog-filter track0 800)
|
|
@ -132,8 +132,14 @@
|
||||||
(send-msg (n-set1 (note-id the-note) name val))
|
(send-msg (n-set1 (note-id the-note) name val))
|
||||||
(void))
|
(void))
|
||||||
|
|
||||||
|
|
||||||
|
(define (mouse/x start end)
|
||||||
|
(mouse-x kr start end 0 0.1))
|
||||||
|
|
||||||
|
(define (mouse/y start end)
|
||||||
|
(mouse-y kr start end 0 0.1))
|
||||||
|
|
||||||
|
|
||||||
#|
|
#|
|
||||||
|
|
||||||
- to stop/run:
|
- to stop/run:
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
(require rsc3)
|
(require rsc3)
|
||||||
|
|
||||||
;; FIXME - not running
|
;; FIXME - not running
|
||||||
(display "Hello! from main.rkt\n")
|
;(display "Hello! from main.rkt\n")
|
||||||
;(run-super-collider)
|
;(run-super-collider)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(require rsc3)
|
(require rsc3)
|
||||||
|
|
||||||
|
(provide (all-defined-out))
|
||||||
#|
|
#|
|
||||||
tracks:
|
tracks:
|
||||||
|
|
||||||
|
@ -66,13 +68,17 @@ tracks:
|
||||||
(define (name bus)
|
(define (name bus)
|
||||||
(apply-effect bus ugen)))
|
(apply-effect bus ugen)))
|
||||||
|
|
||||||
(define (reverb bus)
|
(define (reverb bus ammount)
|
||||||
(apply-effect bus
|
(apply-effect bus
|
||||||
(free-verb (in 1 ar bus)
|
(free-verb (in 1 ar bus)
|
||||||
0.5
|
0.5
|
||||||
(mouse-y kr 0 1 0 0.1)
|
ammount ;(mouse-y kr 0 1 0 0.1)
|
||||||
0.5)))
|
0.5)))
|
||||||
|
|
||||||
|
(define (low-pass-filter bus ammount)
|
||||||
|
(apply-effect bus
|
||||||
|
(lpf (in 1 ar bus) ammount)))
|
||||||
|
|
||||||
; example: apply reverb on bus 0
|
; example: apply reverb on bus 0
|
||||||
; (reverb 0)
|
; (reverb 0)
|
||||||
|
|
||||||
|
@ -84,5 +90,4 @@ tracks:
|
||||||
(apply-effect bus
|
(apply-effect bus
|
||||||
(comb-n (in 1 ar bus) delay-time delay-time decay-time)))
|
(comb-n (in 1 ar bus) delay-time delay-time decay-time)))
|
||||||
|
|
||||||
; (add-effect track0 (reverb 0.3 6)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue