;Written by Iain McCurdy
; Modified for QuteCsound by René, January 2011
; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
;Notes on modifications from original csd:
;my flags on Ubuntu: -dm0 -iadc -odac -+rtaudio=jack -b16 -B4096 --expression-opt -+rtmidi=null
sr = 44100 ;SAMPLE RATE
ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
giRecBuf1 ftgen 1, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
giRecBuf1 ftgen 2, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
giRecBuf1 ftgen 3, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
giRecBuf1 ftgen 4, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
giRecBuf1 ftgen 5, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
giRecBuf1 ftgen 6, 0, 1048576, -7, 0, 1048576, 0 ;AUDIO DATA STORAGE
gitablelen init 1048576
girecdur1 init 0
girecdur2 init 0
girecdur3 init 0
girecdur4 init 0
girecdur5 init 0
girecdur6 init 0
instr 10 ;GUI
ktrig metro 10
if (ktrig == 1)then
gkSpeed1 invalue "Speed1" ;Rec Button 1 Starts / Stops instr 1 ;Play Button 1 Starts / Stops instr 2
gkSpeed2 invalue "Speed2" ;Rec Button 2 Starts / Stops instr 101 ;Play Button 2 Starts / Stops instr 102
gkSpeed3 invalue "Speed3" ;Rec Button 3 Starts / Stops instr 201 ;Play Button 3 Starts / Stops instr 202
gkSpeed4 invalue "Speed4" ;Rec Button 4 Starts / Stops instr 301 ;Play Button 4 Starts / Stops instr 302
gkSpeed5 invalue "Speed5" ;Rec Button 5 Starts / Stops instr 401 ;Play Button 5 Starts / Stops instr 402
gkSpeed6 invalue "Speed6" ;Rec Button 6 Starts / Stops instr 501 ;Play Button 6 Starts / Stops instr 502
endif
endin
#define RECORD_PLAY_INSTRS(COUNT'RECORD'PLAY)
#
instr $RECORD ;RECORD
ain inch 1 ;READ AUDIO FROM LIVE INPUT CHANNEL 1
andx phasor sr/gitablelen ;CREATE A POINTER FOR WRITING TO TABLE - FREQUENCY OF POINTER IS DEPENDENT UPON TABLE LENGTH AND SAMPLE RATE
andx = andx*gitablelen ;RESCALE POINTER ACCORDING TO LENGTH OF FUNCTION TABLE
gkrecdur$COUNT downsamp andx ;CREATE A K-RATE GLOBAL VARIABLE THAT WILL BE USED BY THE 'PLAYBACK' INSTRUMENT TO DETERMINE THE LENGTH OF RECORDED DATA
;OPCODE INPUT | INDEX | FUNCTION_TABLE
tablew ain, andx, $COUNT ;WRITE AUDIO TO AUDIO STORAGE TABLE
endin
instr $PLAY ;PLAYBACK INSTRUMENT
andx phasor (sr*gkSpeed$COUNT)/i(gkrecdur$COUNT) ;CREATE A POINTER FOR WRITING TO TABLE - FREQUENCY OF POINTER IS DEPENDENT UPON TABLE LENGTH AND SAMPLE RATE
andx = andx*i(gkrecdur$COUNT) ;RESCALE POINTER ACCORDING TO LENGTH OF PREVIOUS AUDIO RECORDING
;OUT OPCODE INDEX | FUNCTION_TABLE
asig tablei andx, $COUNT ;READ AUDIO FROM AUDIO STORAGE FUNCTION TABLE
outs asig, asig ;SEND AUDIO TO OUTPUTS
endin
#
$RECORD_PLAY_INSTRS(1'1'2)
$RECORD_PLAY_INSTRS(2'101'102)
$RECORD_PLAY_INSTRS(3'201'202)
$RECORD_PLAY_INSTRS(4'301'302)
$RECORD_PLAY_INSTRS(5'401'402)
$RECORD_PLAY_INSTRS(6'501'502)
i 10 0 3600 ;GUI
72
179
400
200
true
202
202
202
2
2
493
295
{395a9956-93f5-441f-b0ef-3828f1b2da1c}
true
0
0
center
Liberation Sans
18
3
0
0
0
181
199
255
border
5
2
6
47
60
30
{c54faf18-3b5b-4a78-b803-69b1c339890e}
true
0
0
event
1.00000000
Rec
/
i 1 0 -1
true
false
68
47
60
30
{63b09b32-866d-4b31-ba3c-fb6f456359dc}
true
0
0
event
1.00000000
Play
/
i 2 0 -1
true
false
497
2
237
295
{10e7ae72-c151-4c9d-9f49-e6b1585d8386}
true
0
0
center
Liberation Sans
18
3
0
0
0
181
199
255
border
5
2
500
49
232
189
{97dfe67c-26c1-4af5-b858-e301d6886c2e}
true
0
0
left
Liberation Sans
14
3
0
0
0
255
255
255
noborder
1
1
130
62
100
30
{2c897206-0dbc-47b5-ba68-915d83839ab6}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed1
130
44
360
27
{304e78d8-b320-453a-b28f-86b0ca872b86}
true
0
0
-2.00000000
2.00000000
0.92222222
lin
continuous
-1.00000000
false
Speed1
430
62
60
30
{94c7e961-7981-4d21-942f-80bcc647daf5}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
6
87
60
30
{ddf3031c-cb64-4768-97cb-ca0aa8ab3c74}
true
0
0
event
1.00000000
Rec
/
i 101 0 -1
true
false
68
87
60
30
{f194caaa-aef6-402e-ae6d-076065336c8a}
true
0
0
event
1.00000000
Play
/
i 102 0 -1
true
false
130
102
100
30
{e1f324bb-6be7-4085-bd53-e02f0354e2e3}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed2
130
84
360
27
{a320c4f9-5369-410a-bb66-8abb83aa40ae}
true
0
0
-2.00000000
2.00000000
1.00000000
lin
continuous
-1.00000000
false
Speed2
430
102
60
30
{153f5fcc-bd6c-4641-a298-d96fa7c22fa3}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
6
128
60
30
{844fa25d-fca2-40d6-abeb-00e6ef320f88}
true
0
0
event
1.00000000
Rec
/
i 201 0 -1
true
false
68
128
60
30
{28514a95-627b-4d3c-8f46-02e39c8c752e}
true
0
0
event
1.00000000
Play
/
i 202 0 -1
true
false
130
143
100
30
{25830b1d-4b29-440b-87a6-0ed8b06b1074}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed3
130
125
360
27
{0bc28f5f-fd9d-49d3-8cf6-f561eb5a7442}
true
0
0
-2.00000000
2.00000000
1.00000000
lin
continuous
-1.00000000
false
Speed3
430
143
60
30
{d74c9383-db86-4f2d-972d-07cacef31c8f}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
6
169
60
30
{701cc471-2d58-4097-a145-20059bc68c5b}
true
0
0
event
1.00000000
Rec
/
i 301 0 -1
true
false
68
169
60
30
{2a2de3d4-4e42-46b5-a22c-8eb452666d35}
true
0
0
event
1.00000000
Play
/
i 302 0 -1
true
false
130
184
100
30
{c5a99415-8c36-4604-95d7-2c25b46c3f36}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed4
130
166
360
27
{6e98985b-47e4-4f28-b13a-0750426e8a03}
true
0
0
-2.00000000
2.00000000
1.00000000
lin
continuous
-1.00000000
false
Speed4
430
184
60
30
{3d129890-c0be-4eaa-b14a-57da3efafcce}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
6
210
60
30
{b52e515e-5cf4-4d0d-8cf9-1595a8a61cd6}
true
0
0
event
1.00000000
Rec
/
i 401 0 -1
true
false
68
210
60
30
{c6d1742d-6d78-4ee8-bc3e-5bfd41005662}
true
0
0
event
1.00000000
Play
/
i 402 0 -1
true
false
130
225
100
30
{ce30b726-3dfa-44db-ba0c-2e3c8baa7cc9}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed5
130
207
360
27
{136fc532-28ec-4b6c-8054-94a6c62fdb6c}
true
0
0
-2.00000000
2.00000000
1.00000000
lin
continuous
-1.00000000
false
Speed5
430
225
60
30
{ca615dfb-837e-4b18-850f-b3bdf320233a}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1
6
251
60
30
{134729e8-99a2-4874-822d-9e2ed415fd2a}
true
0
0
event
1.00000000
Rec
/
i 501 0 -1
true
false
68
251
60
30
{7a21ea24-ca09-443b-b2a6-48d2e8a4c844}
true
0
0
event
1.00000000
Play
/
i 502 0 -1
true
false
130
266
100
30
{f7014497-5e23-4ac0-8d69-e4ad72632c19}
true
0
0
left
Liberation Sans
10
3
0
0
0
255
255
255
noborder
1
1
Speed6
130
248
360
27
{edf3fbea-b222-44cb-8c6e-627273d9b545}
true
0
0
-2.00000000
2.00000000
1.00000000
lin
continuous
-1.00000000
false
Speed6
430
266
60
30
{2f07bb86-18f6-46be-a7a6-e2fcaba9f9f3}
true
0
0
right
Liberation Sans
9
3
0
0
0
255
255
255
noborder
1
1