Diskin2 reading files from an integer

Hi,

I’m trying to use diskin2 to play some shorts sounds very close from each others with a trigger. But I want to give to diskin2 some lists to play so i don’t want to use caracters to call my sounds but integer numbers so i can stock them in arrays or tables.
The problem is that I don’t understand what means ‘’ An integer denotes the file soundin.ifilcod’’ in the documentation and it seems that I can’t find any example where diskin2 is used with integers to call de sounds that are played.
Thanks if you can help me!
Félix

One way to do what you are trying to do is to link an integer to a string using strset
Use strset before defining the instruments, and use diskin2 with a number to call the sample you defined. For example:

strset 13, “sample13.aiff”

instr 1
as1 diskin2 13
outs as1, as1
endin

Best,
Luís

Another approach is to use sprintf to add a number to each one of your samples. That is what I typically do. I just have to make sure I give each of my samples a name that ends with a number, sample1, sample2, sample3, etc. (Note that Reaper has a great batch process function that will let you easily rename a bunch of audio files.)


instr 1
SFile sprintf "sample%d.wav", p4
a1, a2 diskin SFile....
...

Hi!
Thanks for the help!
I use sprintf to fill an array of strings gSarr:

instr 1

gSarr[] init 17

indx init 1

until indx == 17 do

gSarr[indx] sprintf "%i.wav", indx

prints gSarr[indx]

indx += 1

od

kline line 1, p3, 16

knum = int(kline)

ktrig metro 3

if (ktrig == 1) then

event "i", 10, 0, p3, knum

endif

endin

The difficulty I have now is how to trigger my event only when the index is changing… Currently when I make it move with line and triggering with metro it happens that some sounds are skipped or somes are played twice because the trigger and the index are not linked.

You can probably just check if knum has changed? i.e, if(changed:k(knum) == 1)

Btw, I reformatted your code. You can format code by selecting it and hitting the </> button. It really makes it easier to read.

hi felix -

this is somehow outdated, i think. it was somehow to give soundin
(diskin) an opportunity to get the sound file without paassing a string
to it. so if you have a folder with sound files which are named

  • soundin.1 (NO .wav or .aiff extension)
  • soundin.2
  • etc
    then you could call soundin (diskin) with a line like this:

aL, aR soundin 1

i remeber i used this way end of 1990s because of issues with strings.
but fortunately this is no longer necessary, so in your case you can
name the sounds “01.wav” or similar.

best -
joachim

One way to do what you are trying to do is to link an integer to a string using strset
Use strset before defining the instruments, and use diskin2 with a number to call the sample you defined. For example:

strset 13, “sample13.aiff”

instr 1
as1 diskin2 13
outs as1, as1
endin

Best,
Luís