Debian Codegraph @

src/Examples/McCurdy Collection/MIDI/MIDILinsegrEnvelope.csd

raw
1 ;Writen by Iain McCurdy, 2006
2
3 ; Modified for QuteCsound by René, February 2011
4 ; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6 ;Notes on modifications from original csd:
7 ; Add scope for fun
8
9 ;my flags on Ubuntu: -dm0 -odac -+rtaudio=alsa -b1024 -B2048 -+rtmidi=alsa -Ma
10 <CsoundSynthesizer>
11 <CsOptions>
12
13 </CsOptions>
14 <CsInstruments>
15 sr = 44100 ;SAMPLE RATE
16 ksmps = 128 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
17 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
18 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
19
20
21 instr 1 ; SIMPLE BEEP INSTRUMENT - CAN BE ACTIVATED VIA A CONNECTED MIDI KEYBOARD
22
23 icps cpsmidi
24 iamp ampmidi 0.2
25
26 ; linsegr IS USED TO CREATE AN ADSR STYLE ENVELOPE
27 ; ATTACK LEVEL IS HIGHER THAN SUSTAIN LEVEL GIVING THE NOTE A HARD ATTACK
28 ; INITIAL_LEVEL | ATTACK_TIME | ATTACK_LEVEL | DECAY_TIME | SUSTAIN_LEVEL | RELEASE_TIME | RELEASE_LEVEL
29 aenv linsegr 0, (.01), 1, (.1), .5, (.5), 0
30
31 ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE
32 asig oscili iamp*aenv, icps, 1
33 outs asig, asig ;SEND AUDIO OUTPUT OF OSCILLATOR TO THE SPEAKERS
34 endin
35 </CsInstruments>
36 <CsScore>
37 f 1 0 1024 10 1 ; SINE WAVE
38 f 0 600 ; THIS LINE FUNCTIONS AS A DUMMY SCORE EVENT AND ALLOWS REALTIME MIDI PLAYING FOR 10 MINUTES
39 </CsScore>
40 </CsoundSynthesizer>
41 <bsbPanel>
42 <label>Widgets</label>
43 <objectName/>
44 <x>757</x>
45 <y>523</y>
46 <width>642</width>
47 <height>385</height>
48 <visible>true</visible>
49 <uuid/>
50 <bgcolor mode="nobackground">
51 <r>170</r>
52 <g>170</g>
53 <b>170</b>
54 </bgcolor>
55 <bsbObject version="2" type="BSBLabel">
56 <objectName/>
57 <x>2</x>
58 <y>2</y>
59 <width>639</width>
60 <height>377</height>
61 <uuid>{c37e13f6-7642-465f-9b2a-f059eef7bce8}</uuid>
62 <visible>true</visible>
63 <midichan>0</midichan>
64 <midicc>0</midicc>
65 <label>linsegr (expsegr) - envelopes with MIDI release stages </label>
66 <alignment>center</alignment>
67 <font>Liberation Sans</font>
68 <fontsize>18</fontsize>
69 <precision>3</precision>
70 <color>
71 <r>0</r>
72 <g>0</g>
73 <b>0</b>
74 </color>
75 <bgcolor mode="background">
76 <r>244</r>
77 <g>248</g>
78 <b>200</b>
79 </bgcolor>
80 <bordermode>border</bordermode>
81 <borderradius>5</borderradius>
82 <borderwidth>2</borderwidth>
83 </bsbObject>
84 <bsbObject version="2" type="BSBLabel">
85 <objectName/>
86 <x>5</x>
87 <y>27</y>
88 <width>632</width>
89 <height>268</height>
90 <uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid>
91 <visible>true</visible>
92 <midichan>0</midichan>
93 <midicc>0</midicc>
94 <label>-----------------------------------------------------------------------------------------------------------------------------------------------------------
95 We can still use the traditional envelope generating opcodes line/expon/linseg/expseg in MIDI activated instruments but the popular practise of employing 'p3' (note duration derived from the score) within the formation of an envelope, in order to make that envelope's segment durations at least partially dependent upon note duration, will not be possible as Csound will not know note duration until a MIDI note-off is received. The opcodes 'linsegr' (for straight line segments) and 'expsegr' (for exponential segments) will hold their penultimate break-point value until a MIDI note off is received at which point the final segment will proceed. The final three arguments in a linsegr/expsegr can, from the perspective of a playable instrument, be regarded as 'sustain time', 'release time' and 'release level'. On with expon and expseg, values of zero are illegal with expsegr - values close to zero can be used instead. Where the user desires to modify envelope parameters in this example the code should for the linsegr line can be modified. Some of the more developed MIDI examples in this catalogue include MIDI envelopes where the user can modify the times and values of the envelopes using widgets. The maximum allowed value for the release time is 32768/kr. Exceeding this limit will cause the envelope to not function properly. More information on this opcode is given in the actual code of this example.</label>
96 <alignment>left</alignment>
97 <font>Liberation Sans</font>
98 <fontsize>14</fontsize>
99 <precision>3</precision>
100 <color>
101 <r>0</r>
102 <g>0</g>
103 <b>0</b>
104 </color>
105 <bgcolor mode="nobackground">
106 <r>255</r>
107 <g>255</g>
108 <b>255</b>
109 </bgcolor>
110 <bordermode>noborder</bordermode>
111 <borderradius>1</borderradius>
112 <borderwidth>1</borderwidth>
113 </bsbObject>
114 <bsbObject version="2" type="BSBScope">
115 <objectName/>
116 <x>7</x>
117 <y>298</y>
118 <width>629</width>
119 <height>73</height>
120 <uuid>{78831f8c-abab-4c29-be2b-6207912c4285}</uuid>
121 <visible>true</visible>
122 <midichan>0</midichan>
123 <midicc>0</midicc>
124 <value>-255.00000000</value>
125 <type>scope</type>
126 <zoomx>2.00000000</zoomx>
127 <zoomy>4.00000000</zoomy>
128 <dispx>1.00000000</dispx>
129 <dispy>1.00000000</dispy>
130 <mode>0.00000000</mode>
131 </bsbObject>
132 </bsbPanel>
133 <bsbPresets>
134 </bsbPresets>