;Written by Iain McCurdy, 2009
;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 for exp slider
; Add Browser for audio files, accept mono or stereo wav files (only channel 1 is used)
; Replace (1-kenv_n) by (kenv_n) in instr 3
; Changed instr 2, can't hide / show widgets from orc
; Used reinit in instr 3
/* risset rhythms
--------------------------------------------------------------------------------------------------------------------------
Risset rhythms is a variation of the Shepard-Risset Glissando which employs a rhythmic loop instead of a sine tone.
This implementation uses speed control of sampled loops to vary tempo, therefore pitch as well as tempo is modulated.
A repeating loop fades in as it gradually increases in tempo (and pitch). By the time it has doubled its tempo (and risen
in pitch by an octave) a second layer of this loop is faded in at the same initial tempo of the original layer. It then
follows the trajectory of the first layer, always half its tempo (and an octave lower). As the layers get faster and
faster, they eventually fade out, just as they faded in. As many layers can be used as desired but the greater the number
of layers, the greater the range of tempi (& pitch) covered. The effect of this should be a cognative contradiction in
which, from moment to moment, the music appears to be getting faster, but over the longer term doesn't get faster.
A frequently cited visual analog is that of the spinning barber's pole in which parallel lines appear to be rising but
obviously aren't.
In this implementation 'Rate' controls the rate of acceleration of the loops. One period will be the time it
take for a loop to begin fading in at its lowest tempo, to when it finally fades our at its highest tempo. Negative
values here will result in loops slowing down (getting lower in pitch). The greater the number of layers employed the
greater the rate of acceleration will appear as each loop will cover a greater range of tempi from fading in to fading out.
Careful tuning of the 'Number of Layers' and 'Rate' is needed to properly create the illusion. Setting rate too high
will reveal the workings of the illusion.
The amplitudes of each of the layers are adjustable using the numbered sliders. These are normally all left at maximum but
listening to one layer on its own can help in understanding the mechanism of this example. The yellow bars indicate how
the different layers fade in and out.
A choice of amplitude window functions are available. These determine exactly how each layer fades in and out.
A choice of four source loops are provided (including a sine tone which allows creation of the Shepard-Risset Glissando).
'Global Speed' scales the speed of all layers equally.
*/
;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
--env:SSDIR+=../../SourceMaterials
sr = 44100 ;SAMPLE RATE
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
giExp1 ftgen 0, 0, 129, -25, 0, 0.25, 128, 4.0 ;TABLE FOR EXP SLIDER
giAmpWindow1 ftgen 11, 0, 131073, 9, 0.5, 1, 0 ;HALF SINE
giAmpWindow2 ftgen 12, 0, 131073, 20, 3, 1 ;BARTLETT (TRIANGLE)
giAmpWindow3 ftgen 13, 0, 131073, 20, 5, 1 ;BLACKMAN-HARRIS
giLongSine ftgen 0, 0, 131073, 9, 1200, 1, 0
instr 1 ;GUI
ktrig metro 10
if (ktrig == 1) then
;SLIDERS
gkrate invalue "Rate"
kGSpeed invalue "GSpeed"
gkGSpeed tablei kGSpeed, giExp1, 1
outvalue "GSpeed_Value", gkGSpeed
gk1 invalue "K1"
gk2 invalue "K2"
gk3 invalue "K3"
gk4 invalue "K4"
gk5 invalue "K5"
gk6 invalue "K6"
gk7 invalue "K7"
gk8 invalue "K8"
gkOutGain invalue "OutGain"
;COUNTERS
gklayers invalue "Layers"
ktrig_layer changed gklayers
schedkwhen ktrig_layer, 0, 0, 2, 0, .1 ;RESTART INSTRUMENT 2
gkSineOnOff invalue "SineOnOff"
;MENUS
gkAmpWindow invalue "AmpWindow"
;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
giloop ftgen 0, 0, isize, 1, Sfile, 0, 0, 1 ;READ AUDIO FILE CHANNEL 1
;*******************************************************************************************************************************************
endif
endin
instr 2
ilayers init i(gklayers)
if ilayers < 3 then
outvalue "K3", 0
outvalue "Amp3", 0
endif
if ilayers < 4 then
outvalue "K4", 0
outvalue "Amp4", 0
endif
if ilayers < 5 then
outvalue "K5", 0
outvalue "Amp5", 0
endif
if ilayers < 6 then
outvalue "K6", 0
outvalue "Amp6", 0
endif
if ilayers < 7 then
outvalue "K7", 0
outvalue "Amp7", 0
endif
if ilayers < 8 then
outvalue "K8", 0
outvalue "Amp8", 0
endif
endin
instr 3
kSwitch changed gkAmpWindow, gklayers,gkSineOnOff
if gkfile_new == 1 || kSwitch == 1 then
gkfile_new = 0
reinit REINIT
endif
REINIT:
if i(gkSineOnOff)==1 then
ifn = giLongSine
ilen = ftlen(ifn)
else
ifn = giloop
ilen = nsamp(ifn)
endif
iAmpWindow = i(gkAmpWindow)+11
kSpeedRatio = sr*gkGSpeed/ilen ;PLAYBACK SPEED RATIO BASED ON FILE LENGTH AND 'GLOBAL SPEED' SLIDER
ilayers = i(gklayers)
kupdate metro 20
aout init 0 ;ACCUMULATING AUDIO VARIABLE INITIALISED
;CREATE FIRST LAYER
kspeed1 phasor gkrate ;PHASOR THAT TRACES AMPLITUDE ENVELOPE
kenv1 tablei kspeed1, iAmpWindow, 1 ;AMPLITUDE ENVELOPE
if kupdate == 1 then
outvalue "Amp1", kenv1
endif
kratio1 = octave((kspeed1*ilayers)-(ilayers*.5)) ;MOVING PLAYBACK RATIO
aptr1 phasor kratio1*kSpeedRatio ;PHASOR THAT TRACES MOVEMENT THROUGH THE SOUND FILE
asig1 tablei aptr1*ilen, ifn ;READ AUDIO FROM TABLE
aout = aout + (asig1*kenv1*gk1) ;ADD AUDIO TO ACCUMULATING AUDIO VARIABLE
;MACRO DEFINED FOR ALL SUBSEQUENT LAYERS
#define LAYER(N)
#
kspeed$N phasor gkrate, ($N-1)/ilayers ;PHASOR THAT TRACES AMPLITUDE ENVELOPE
kenv$N tablei kspeed$N, iAmpWindow, 1 ;AMPLITUDE ENVELOPE
if kupdate == 1 then
outvalue "Amp$N", kenv$N
endif
kratio$N = octave((kspeed$N*ilayers)-(ilayers*.5)) ;MOVING PLAYBACK RATIO
aptr$N phasor kratio$N*kSpeedRatio ;PHASOR THAT TRACES MOVEMENT THROUGH THE SOUND FILE
asig$N tablei aptr$N*ilen, ifn ;READ AUDIO FROM TABLE
aout = aout + (asig$N*kenv$N*gk$N) ;ADD AUDIO TO ACCUMULATING AUDIO VARIABLE
if gklayers==$N goto FINISH ;IF THIS IS THE FINAL LAYER JUMP TO 'FINISH' LABEL
#
;EXECUTE MACRO MULTIPLE TIMES
$LAYER(2)
$LAYER(3)
$LAYER(4)
$LAYER(5)
$LAYER(6)
$LAYER(7)
$LAYER(8)
FINISH: ;'FINISH' LABEL
outs aout*gkOutGain, aout*gkOutGain ;SEND AUDIO TO OUTPUTS
clear aout ;CLEAR ACCUMULATING AUDIO VARIABLE
endin
;INSTR | START | DURATION
i 1 0 3600 ;GUI
207
248
820
364
true
241
226
185
2
2
807
323
{aa607456-d368-4d59-8497-d16d608404c3}
true
0
0
center
Liberation Sans
18
3
255
255
255
5
27
150
border
5
2
8
64
200
30
{5cde19f3-b356-4945-9c8b-43dd67c604dd}
true
0
0
left
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
Rate
8
41
500
27
{d6d73a88-8d82-47de-a067-758f1917a3f2}
true
0
0
-0.10000000
0.10000000
0.00880000
lin
continuous
-1.00000000
false
Rate
448
64
60
30
{073ad371-9227-46fa-a005-ac10a210db79}
true
0
0
right
Liberation Sans
9
3
255
255
255
255
255
255
noborder
1
1
8
285
200
30
{b6afbe1e-677c-44a6-ba84-4c32dc21b0a7}
true
0
0
left
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
OutGain
8
262
500
27
{859d1ded-b337-4ee7-ac9b-48a1b5f77d16}
true
0
0
0.00000000
1.00000000
0.20000000
lin
continuous
-1.00000000
false
OutGain
448
285
60
30
{95f6cb02-77ec-46fe-876b-a93efac3c5e5}
true
0
0
right
Liberation Sans
9
3
255
255
255
255
255
255
noborder
1
1
8
116
200
30
{3ebc1139-1fdb-48dc-9150-49ee8dfdbd4a}
true
0
0
left
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
GSpeed
8
93
500
27
{2cf97843-5b49-438e-8034-62a459597e86}
true
0
0
0.00000000
1.00000000
0.50000000
lin
continuous
-1.00000000
false
GSpeed_Value
448
116
60
30
{e54486c5-f9aa-4d0e-9a67-6506dae3c790}
true
0
0
right
Liberation Sans
9
3
255
255
255
255
255
255
noborder
1
1
AmpWindow
182
215
150
30
{8ea371ed-50f1-450f-b078-4a586bcef87b}
true
0
0
Half-sine
0
Bartlett (triangle)
1
Blackman-Harris
2
0
false
523
41
275
272
{bdd673e3-e25a-40f8-863d-d577728cfcd3}
true
0
0
left
Liberation Sans
16
3
255
255
255
5
27
150
border
5
2
K2
552
114
240
16
{87938e2d-58f8-4df2-980a-5d9e090cde92}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.57500000
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
552
285
30
30
{798870a8-da25-4230-ab04-fec3e1af83de}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
54
220
120
24
{6decaf4d-be74-4edb-8815-51176aca4329}
true
0
0
right
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
Layers
687
60
40
30
{8cd8a941-663d-42a8-8506-9d6f626ee7ed}
true
0
0
right
Liberation Sans
14
0
0
0
255
255
255
1.00000000
2
8
false
8
560
69
120
24
{6360df02-ee77-4887-8a80-c42cec1f9e0d}
true
0
0
right
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
K3
552
132
240
16
{2449a622-bff3-4423-8025-19b452abe8f4}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.56250000
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K4
552
150
240
16
{8edf0689-9c06-43a5-9304-60021e1a7281}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.57083333
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K5
552
168
240
16
{a05e924d-d1eb-4261-a87a-7f5cad5f1018}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.57083333
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K6
552
186
240
16
{90e7ff59-af14-4d0a-b77d-7907420d4a0a}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.57500000
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K1
552
96
240
16
{847a0055-8bb1-4c09-bbff-6ef4ddc2ac35}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.57916667
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K7
552
204
240
16
{0b424caa-b6b4-440e-abf4-5fc04007bd83}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.58333333
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
K8
552
222
240
16
{a13d9481-85ce-4591-8154-5b34ea77066a}
true
0
0
0.00000000
1.00000000
0.00000000
1.00000000
0.55416667
0.48888889
fill
1
0.00000000
jump
255
85
0
false
0
0
0
552
239
30
45
{4ed33452-74d6-481f-ab08-99d86950b729}
true
0
0
Amp1
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.41300270
fill
1
0.00000000
jump
0
234
0
false
0
0
0
582
239
30
45
{7456792e-e3fa-44bc-9eca-254789bbd30b}
true
0
0
Amp2
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.73008597
fill
1
0.00000000
jump
0
234
0
false
0
0
0
612
239
30
45
{bdc55483-bac8-4356-8568-0f085cf23840}
true
0
0
Amp3
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.93602026
fill
1
0.00000000
jump
0
234
0
false
0
0
0
642
239
30
45
{ed3ff9dc-cd52-4a83-bc59-300ac50a5a12}
true
0
0
Amp4
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.99945396
fill
1
0.00000000
jump
0
234
0
false
0
0
0
672
239
30
45
{e456eef8-e8c9-4cde-8fbc-9aa0ca7ef708}
true
0
0
Amp5
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.91072983
fill
1
0.00000000
jump
0
234
0
false
0
0
0
702
239
30
45
{02f47c9e-dd19-4146-a821-3b672486d860}
true
0
0
Amp6
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.68335539
fill
1
0.00000000
jump
0
234
0
false
0
0
0
732
239
30
45
{26034605-de9c-4c45-8006-90c83afd6e37}
true
0
0
Amp7
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.35194626
fill
1
0.00000000
jump
0
234
0
false
0
0
0
762
239
30
45
{efab70b7-bf62-444a-add8-cb13edf74538}
true
0
0
Amp8
0.00000000
1.00000000
0.00000000
1.00000000
0.55833333
0.03304354
fill
1
0.00000000
jump
0
234
0
false
0
0
0
582
285
30
30
{edb43afc-4c3b-4bfb-8b14-e0c3de800f9b}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
612
285
30
30
{9a73d3de-64ba-41d4-b029-0d006db924a3}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
642
285
30
30
{dbef6f26-d72f-4079-b78e-221bbcb15520}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
672
285
30
30
{840b415c-78ab-4e76-b8b7-6e94ac7819ee}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
702
285
30
30
{d0fa83ca-1cff-4e4c-8d10-cf96de27eef3}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
732
285
30
30
{eccf5c79-9abc-4e93-8e1b-60f9b3cf78a5}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
762
285
30
30
{6d8b1231-bf33-49ec-953d-4dbf4b873582}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
94
30
30
{077611e5-8912-4129-8886-2ca33c4fd0b3}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
112
30
30
{7526ec67-8b53-4407-8418-6c72539ad95b}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
130
30
30
{d8869704-3682-4c0d-9981-49e27e937907}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
148
30
30
{d6d5cc99-71a5-4d1a-b5c6-3469d1598993}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
166
30
30
{71605fc2-1d80-46f2-84e3-78192116c5d8}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
183
30
30
{859d0add-2499-458a-b3e3-4ba103e72bac}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
202
30
30
{4c9d9007-6734-407b-b0ca-1ecbcdf05fde}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
521
222
30
30
{5bdebd1c-cb56-4ba1-a795-1dfd9359363c}
true
0
0
center
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
8
147
60
24
{75126f09-53b9-4498-862c-fcf60551bf39}
true
0
0
left
Liberation Sans
10
3
255
255
255
255
255
255
noborder
1
1
_Browse
8
169
170
30
{1757a18f-b418-4ef1-984d-bdee5e985805}
true
0
0
value
1.00000000
MFEM.wav
Browse Audio File
/
false
false
_Browse
178
170
330
28
{804f4f24-03f1-4ac2-8ba2-697f15df06cf}
true
0
0
left
Liberation Sans
10
3
0
0
0
235
232
228
nobackground
8
10
109
30
{acd14897-b49e-4b3e-93d7-fa6e52da70aa}
true
0
0
event
1.00000000
On / Off
/
i3 0 -1
true
false
SineOnOff
340
214
164
32
{134b8425-c4e0-4077-9630-678ac8d71669}
true
0
0
value
1.00000000
Sine Wave On / Off
/
true
false