summaryrefslogtreecommitdiff
path: root/examples/polyaft.csd
blob: a7db4c44230227eca34ccfd6245da4ba831e8b00 (plain)
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
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in   No messages  MIDI in
-odac           -iadc     -d         -M0  ;;;RT audio I/O with MIDI in
; For Non-realtime ouput leave only the line below:
; -o polyaft.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr	=  44100
ksmps	=  10
nchnls	=  1

	massign 1, 1
itmp	ftgen 1, 0, 1024, 10, 1		; sine wave

	instr 1

kcps	cpsmidib 2		; note frequency
inote	notnum			; note number
kaft	polyaft inote, 0, 127	; aftertouch
; interpolate aftertouch to eliminate clicks
ktmp	phasor 40
ktmp	trigger 1 - ktmp, 0.5, 0
kaft	tlineto kaft, 0.025, ktmp
; map to sine curve for crossfade
kaft	=  sin(kaft * 3.14159 / 254) * 22000

asnd	oscili kaft, kcps, 1

	out asnd

	endin


</CsInstruments>
<CsScore>

t 0 120
f 0 9 2 -2 0
e


</CsScore>
</CsoundSynthesizer>