~ubuntu-branches/ubuntu/trusty/csound-manual/trusty-proposed

« back to all changes in this revision

Viewing changes to examples/adsr.csd

  • Committer: Bazaar Package Importer
  • Author(s): Felipe Sateler
  • Date: 2011-08-01 22:21:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110801222158-90kslkp5ujci2f5d
Tags: 1:5.13~dfsg-1
* New upstream release
 - Add Menno Knevel to the copyright file
 - Refresh patch 2000-stripped-opcodes.diff
 - Update copyright hints file
* Update Vcs-* headers
* Bump Standards-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<CsoundSynthesizer>
2
2
<CsOptions>
3
3
; Select audio/midi flags here according to platform
4
 
; Audio out   Audio in    No messages
5
 
-odac           -iadc     -d     ;;;RT audio I/O
 
4
-odac     ;;;RT audio out
 
5
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
6
6
; For Non-realtime ouput leave only the line below:
7
7
; -o adsr.wav -W ;;; for file output any platform
8
8
</CsOptions>
9
9
<CsInstruments>
10
10
 
11
 
; Initialize the global variables.
12
11
sr = 44100
13
 
kr = 4410
14
 
ksmps = 10
15
 
nchnls = 1
 
12
ksmps = 32
 
13
nchnls = 2
 
14
0dbfs = 1
16
15
 
17
 
; Instrument #1 - a simple instrument.
18
16
instr 1
19
 
  ; Set the amplitude.
20
 
  kamp init 20000
21
 
  ; Get the frequency from the fourth p-field.
22
 
  kcps = cpspch(p4)
23
 
 
24
 
  a1 vco kamp, kcps, 1
25
 
  out a1
26
 
endin
27
 
 
28
 
; Instrument #2 - instrument with an ADSR envelope.
29
 
instr 2
30
 
  iatt = 0.05
31
 
  idec =  0.5
32
 
  islev = 0.08
33
 
  irel = 0.008
34
 
 
35
 
  ; Create an amplitude envelope.
36
 
  kenv adsr iatt, idec, islev, irel
37
 
  kamp = kenv * 20000
38
 
 
39
 
  ; Get the frequency from the fourth p-field.
40
 
  kcps = cpspch(p4)
41
 
 
42
 
  a1 vco kamp, kcps, 1
43
 
  out a1
44
 
endin
45
 
 
 
17
 
 
18
iatt  = p5
 
19
idec  = p6  
 
20
islev = p7
 
21
irel  = p8
 
22
 
 
23
kenv    adsr iatt, idec, islev, irel
 
24
kcps =  cpspch(p4)        ;frequency
 
25
 
 
26
asig    vco2  kenv * 0.8, kcps
 
27
        outs  asig, asig
 
28
 
 
29
endin
46
30
 
47
31
</CsInstruments>
48
32
<CsScore>
49
33
 
50
 
; Table #1, a sine wave.
51
 
f 1 0 16384 10 1
52
 
 
53
 
; Set the tempo to 120 beats per minute.
54
 
t 0 120
55
 
 
56
 
; Play a melody with Instrument #1.
57
 
; p4 = frequency in pitch-class notation.
58
 
i  1  0   1  8.04
59
 
i  1  1   1  8.04
60
 
i  1  2   1  8.05
61
 
i  1  3   1  8.07
62
 
i  1  4   1  8.07
63
 
i  1  5   1  8.05
64
 
i  1  6   1  8.04
65
 
i  1  7   1  8.02
66
 
i  1  8   1  8.00
67
 
i  1  9   1  8.00
68
 
i  1  10  1  8.02
69
 
i  1  11  1  8.04
70
 
i  1  12  2  8.04
71
 
i  1  14  2  8.02
72
 
 
73
 
; Repeat the melody with Instrument #2.
74
 
; p4 = frequency in pitch-class notation.
75
 
i  2  16  1  8.04
76
 
i  2  17  1  8.04
77
 
i  2  18  1  8.05
78
 
i  2  19  1  8.07
79
 
i  2  20  1  8.07
80
 
i  2  21  1  8.05
81
 
i  2  22  1  8.04
82
 
i  2  23  1  8.02
83
 
i  2  24  1  8.00
84
 
i  2  25  1  8.00
85
 
i  2  26  1  8.02
86
 
i  2  27  1  8.04
87
 
i  2  28  2  8.04
88
 
i  2  30  2  8.02
 
34
i 1  0  1  7.00  .0001  1  .01  .001 ; short attack
 
35
i 1  2  1  7.02  1  .5  .01  .001    ; long attack
 
36
i 1  4  2  6.09  .0001  1 .1  .7     ; long release
 
37
 
89
38
e
90
39
 
91
 
 
92
40
</CsScore>
93
41
</CsoundSynthesizer>