;Written by Iain McCurdy, 2009
;Modified for QuteCsound by René, March 2011
;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
;Notes on modifications from original csd:
; Add Browser for impulse file, accept mono or stereo wav files
; INIT instrument added
; Use event_i and instrument 5 to simulate a FLsetVal_i opcode
; Removed subinstr opcode in midi instrument 1 because midi note was played with previous freq and amp values (only on my csd, original FLTK csd is ok)
;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0
sr = 44100 ;SAMPLE RATE
ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
givfn ftgen 0,0,4096,10,1 ;A SINE WAVE
instr 2 ;GUI
ktrig metro 10
if (ktrig == 1) then
gkamp invalue "Amp"
gkfreq invalue "Freq"
gkhrd invalue "Hard"
gkpos invalue "Pos"
gkvibf invalue "VibFreq"
gkvamp invalue "VibAmp"
;AUDIO FILE CHANGE / LOAD IN TABLES ********************************************************************************************************
Sfile_new strcpy "" ;INIT TO EMPTY STRING
Sfile invalue "_Browse"
Sfile_old strcpyk Sfile_new
Sfile_new strcpyk Sfile
kfile strcmpk Sfile_new, Sfile_old
gkfile_new init 0
if kfile != 0 then ;IF A BANG HAD BEEN GENERATED IN THE LINE ABOVE
gkfile_new = 1 ;Flag to inform instr 1 that a new file is loaded
reinit NEW_FILE ;REINITIALIZE FROM LABEL 'NEW_FILE'
endif
NEW_FILE:
ilen filelen Sfile ;Find length
isr filesr Sfile ;Find sample rate
isamps = ilen * isr ;Total number of samples
isize init 1
LOOP:
isize = isize * 2
if (isize < isamps) igoto LOOP ;Loop until isize is greater than number of samples
gimp ftgen 0, 0, isize, 1, Sfile, 0, 0, 1 ;READ AUDIO FILE CHANNEL 1
;*******************************************************************************************************************************************
endif
endin
instr 1 ;MIDI ACTIVATED INSTRUMENT
ifreq cpsmidi ;FREQUENCY IS READ FROM INCOMING MIDI NOTE
iamp ampmidi 0.5 ;AMPLITUDE IS READ FROM INCOMING MIDI NOTE
event_i "i", 5, 0, 0.1, iamp, ifreq ;SEND AMPLITUDE VALUE TO AMPLITUDE SLIDER and FREQUENCY VALUE TO FREQUENCY SLIDER
kSwitch changed gkhrd, gkpos ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if gkfile_new == 1 || kSwitch == 1 then
gkfile_new = 0
reinit UPDATE
endif
UPDATE:
ares gogobel iamp, ifreq, i(gkhrd), i(gkpos), gimp, gkvibf, gkvamp, givfn
rireturn
aenv linsegr 1, 3600, 1, 0.1, 0 ;CREATE AN AMPLITUDE ENVELOPE. THIS WILL BE USED TO PREVENT CLICKS.
outs ares*aenv, ares*aenv ;SEND AUDIO TO OUTPUTS
endin
instr 3
kSwitch changed gkhrd, gkpos ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
if gkfile_new == 1 || kSwitch == 1 then
gkfile_new = 0
reinit UPDATE
endif
UPDATE:
ares gogobel i(gkamp), i(gkfreq), i(gkhrd), i(gkpos), gimp, gkvibf, gkvamp, givfn
rireturn
outs ares, ares
endin
instr 4 ;INIT
outvalue "Amp", 0.2
outvalue "Freq", 750
outvalue "Hard", 0.5
outvalue "Pos", 0.65
outvalue "VibFreq", 5
outvalue "VibAmp", 0
endin
instr 5 ;UPDATE
outvalue "Amp", p4 ;SEND AMPLITUDE VALUE TO AMPLITUDE SLIDER
outvalue "Freq", p5 ;SEND FREQUENCY VALUE TO FREQUENCY SLIDER
endin
;INSTR | START | DURATION
i 2 0 3600 ;GUI
i 4 0 0.1 ;INIT
72
179
400
200
true
241
226
185
2
2
511
330
{aa607456-d368-4d59-8497-d16d608404c3}
true
0
0
center
Liberation Sans
18
3
0
0
0
147
154
255
border
5
2
8
125
220
30
{640b50b7-7200-4f81-8394-89d9843ae939}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Amp
8
108
500
27
{5585fa6f-0f63-4ac3-bf1b-809c2b1d9134}
true
0
0
0.00000000
1.00000000
0.19531250
lin
continuous
-1.00000000
false
Amp
448
125
60
30
{b731b52e-e14a-476a-a583-f3b2bd885539}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
160
220
30
{989564b0-b237-4c22-9d10-b76b7c7e4e4c}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Freq
8
143
500
27
{84cd664e-fb67-4dd4-aac3-adbcf2c81fe6}
true
0
0
20.00000000
2000.00000000
772.40000000
lin
continuous
-1.00000000
false
Freq
448
160
60
30
{ba8682a6-056f-4432-946b-4e3ee82c47a1}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
194
200
30
{76044785-79c4-4202-b7ce-07aee4868219}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Hard
8
177
500
27
{0f952e77-ff9b-4621-b1af-23252bb9c2a6}
true
0
0
0.00000000
1.00000000
0.50000000
lin
continuous
-1.00000000
false
Hard
448
194
60
30
{7b92c0ca-2fe8-4b4f-9ed0-f618c1b3cb5c}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
229
220
30
{ca41878c-b561-486b-9cf9-d0da6b48448b}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Pos
8
212
500
27
{2800fb88-347a-402c-88ed-fc97af6a36be}
true
0
0
0.00000000
1.00000000
0.64999998
lin
continuous
-1.00000000
false
Pos
448
229
60
30
{5d1ba94c-536a-4178-be6c-c0d9d2f75e3d}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
264
220
30
{cdd71125-b224-471a-9c41-9c05d8d28d0c}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
VibFreq
8
247
500
27
{7a83bb1f-f25d-47e0-bf2d-9c5c86e0756b}
true
0
0
0.00000000
15.00000000
5.00000000
lin
continuous
-1.00000000
false
VibFreq
448
264
60
30
{7f8d2709-bf8c-46ab-83f0-36fc620b0d56}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
515
2
271
330
{74928ed2-b701-4668-9a11-74763d317e9b}
true
0
0
center
Liberation Sans
18
3
0
0
0
147
154
255
border
5
2
517
25
267
296
{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}
true
0
0
left
Liberation Sans
14
3
0
0
0
255
255
255
noborder
1
1
8
16
100
30
{04d44ebe-12eb-4bb0-a3f5-9e4fd3e7830e}
true
0
0
event
1.00000000
Strike !
/
i 3 0 -1
false
false
8
300
220
30
{ca67a321-de0d-4a0f-8efd-864d9a51098c}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
VibAmp
8
283
500
27
{0341fedb-6323-4661-b4c3-8207291fcd90}
true
0
0
0.00000000
1.00000000
0.00000000
lin
continuous
-1.00000000
false
VibAmp
448
300
60
30
{3c428724-1329-4e7c-bdb5-6e1277f3c2ce}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
8
51
97
30
{3c19fbdc-3d2b-4583-8316-52f7a3a433e2}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
_Browse
8
73
170
30
{43341095-bc3a-4607-bd0e-01254da7bc67}
true
0
0
value
1.00000000
marmstk1.wav
Browse Audio File
/
false
false
_Browse
177
74
330
28
{b66f3878-dfd0-4290-9b9d-73be88197222}
true
0
0
left
Arial
10
3
0
0
0
240
235
226
nobackground