;Writen by Iain McCurdy, 2008
; Modified for QuteCsound by René, February 2011
; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
;Notes on modifications from original csd:
; Add table(s) for exp slider
;my flags on Ubuntu: -dm0 -odac -+rtaudio=alsa -b1024 -B2048 -+rtmidi=alsa -Ma
sr = 44100 ;SAMPLE RATE
ksmps = 2 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
giwaveform ftgen 0,0,4096,10,1,.5,.25,.125,.0625 ;A RICH HARMONIC WAVEFORM
gkvoice init 1 ;GLOBAL VARIABLE USED TO DEFINE WHETHER VOICE 1 OR VOICE 2 IS CURRENT
giExp1 ftgen 0, 0, 129, -25, 0, 0.01, 128, 2.0 ;TABLE FOR EXP SLIDER
giExp2 ftgen 0, 0, 129, -25, 0, 0.01, 128, 8.0 ;TABLE FOR EXP SLIDER
instr 10 ;GUI
ktrig metro 10
if (ktrig == 1) then
katt invalue "Attack"
gkatt tablei katt, giExp1, 1
outvalue "Attack_Value", gkatt
kdec invalue "Decay"
gkdec tablei kdec, giExp2, 1
outvalue "Decay_Value", gkdec
gksus invalue "Sustain"
krel invalue "Release"
gkrel tablei krel, giExp1, 1
outvalue "Release_Value", gkrel
endif
endin
instr 1 ; NOTE TRIGGERING INSTRUMENT
icps cpsmidi ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
asig subinstr i(gkvoice)+1, icps ;CALL SOUND GENERATING INSTRUMENT AS A SUB-INSTRUMENT
outs asig, asig ;SEND AUDIO TO OUTPUTS
endin
instr 2,3 ;SOUND GENERATING INSTRUMENTS
gkvoice init (i(gkvoice)=1?2:1) ;FLIP VOICE ALLOCATION AT INIT TIME
if gkvoice=p1-1 then ;IF THE OTHER VOICE IS NOW PLAYING...
turnoff ;...TURN THIS INSTRUMENT OFF (ENVELOPE RELEASE STAGE WILL BE ALLOWED TO COMPLETE)
endif ;END OF CONDITIONAL BRANCHING
; ATT | DEC | SUS | REL
aenv madsr i(gkatt), i(gkdec), i(gksus), i(gkrel) ;MIDI SENSING ADSR ENVELOPE WITH EXPONENTIALLY SHAPED SEGMENTS
;OUTPUT OPCODE AMP CPS FUNCTION_TABLE
asig oscili 0.1*aenv, p4, giwaveform ;AUDIO OSCILLATOR
outch 1, asig ;SEND AUDIO BACK TO INSTR 1
endin
instr 999 ;QUIT
exitnow ;EXIT CSOUND IMMEDIATELY
endin
i 10 0 3600 ;GUI - ALLOWS REAL-TIME PLAYING FOR 1 HOUR
461
257
1023
320
true
170
170
170
516
2
502
314
{aa607456-d368-4d59-8497-d16d608404c3}
true
0
0
center
Liberation Sans
18
3
0
0
0
244
248
200
border
5
2
520
22
495
292
{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}
true
0
0
left
Liberation Sans
14
3
0
0
0
255
255
255
noborder
1
1
2
2
512
314
{9cb1f282-09da-4c18-87db-ffd36d585a0c}
true
0
0
center
Liberation Sans
18
3
0
0
0
244
248
200
border
5
2
8
66
180
30
{2e52a7a7-dc13-405e-896d-db2a7431d8dd}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Attack
8
49
500
27
{6ab84e0f-82a7-4b9c-af23-35bd7d9b7fa2}
true
0
0
0.00000000
1.00000000
0.43400000
lin
continuous
-1.00000000
false
Attack_Value
448
66
60
30
{99d6bf8b-3c85-4911-a29a-7dd678a940ed}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
113
180
30
{a8da19ef-d61e-452d-af2c-a79924c6890d}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Decay
8
96
500
27
{be1cab81-da6b-442b-bcc8-22c97579c797}
true
0
0
0.00000000
1.00000000
0.89800000
lin
continuous
-1.00000000
false
Decay_Value
448
113
60
30
{9596f9bd-afff-4b1f-8c39-be869c440d66}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
160
180
30
{e646ae5a-1978-4b35-a55b-1c92c731a64a}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Sustain
8
143
500
27
{62fc68cb-e133-4202-8b11-1367e23ed833}
true
0
0
0.00000000
1.00000000
0.45000000
lin
continuous
-1.00000000
false
Sustain
448
160
60
30
{ba6bd246-c54c-48aa-844b-8bbd9a6d042c}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
207
180
30
{176b8dbf-8ba1-4489-95dc-30095dc766d9}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Release
8
190
500
27
{20c53bec-f5cf-46d6-81b7-f2f9574d567e}
true
0
0
0.00000000
1.00000000
0.91800000
lin
continuous
-1.00000000
false
Release_Value
448
207
60
30
{f9658342-cd32-4d15-90b6-a27b75042579}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
408
256
100
30
{ce398444-215b-4ae2-98af-eb885bd5ebad}
true
0
0
event
1.00000000
Exit
/
i 999 0 0
false
false
226
258
180
30
{642a77e6-d731-4f03-a687-3ae7c0afa1bd}
true
0
0
right
Liberation Sans
12
3
0
0
0
255
255
255
noborder
1
1