First time here? Check out the FAQ!
x

How to randomly select from an array of samples?

0 votes
806 views
I would like to build an instrument that selects a random sample from a list of 6 to 8 sounds, each time it is triggered. I've been messing around with Sample, Soundswitcher, and poking around with Capytalk (I was excited by the recent script "Set Oscillator waveforms from array of filenames"), but I'm not sure how to script it. With a Mixer? Should it even be a script?

Sorry if this is too much of a newbie question!
asked May 4, 2016 in Using Kyma by stephen-taylor (Adept) (1,620 points)

2 Answers

+1 vote
Hi Stephen,

I wouldn't head for a script here.. The script in the bespoke example is only needed because we wanted to encapsulate the Sound.

To randomly select from samples I suggest using the MultifileDiskPlayer. Provide it with an array of filenames, then use a little capytalk for the index like: (!Trigger nextRandom abs * 7) rounded. Each time you hit Trigger the index will change to a new positive random value, multiply by the number of samples - 1 you are using.

To randomly select a Sound using the SelectableSound you can use the same code for the selection parameter, just multiply by the number of inputs -1 and add 1 (because the SoundSelector starts indexing at 1 not 0). For example: (!Trigger nextRandom abs * 7) rounded + 1.

Cheers,

Gustav
answered May 4, 2016 by kymaguy (Virtuoso) (10,580 points)
Also you could press the little (i) icon in the bottom corner of the MultiFileDiskPlayer, whilst your cursor is inside the Index field, and Kyma will suggest to you many Capytalk expressions you could use to select from  random samples in the list.

One of my favourites is a type of random selector that never repeats the same selection twice (it needs at least three elements to choose from)

!Trigger nextRandomIndexMod: 7    (if you have 7 samples in the list)
Fantastic - thanks guys!
Hi Stephen,
In the Prototypes, the Multisample shows an example of how to select and trigger at random from a list of samples.  You can find it in the Sample playback category (or search the Prototypes using Ctrl+B).

In the Sound library if you search for Sound class name: Multisample
Then click the Plus (+) sign and search for Sound parameter value: random

the search will find some examples of Multisample and MultisampleCloud in the Sound Library with random selection and triggering.

You might also find Morph1dSampleCloud an interesting starting point.
+1 vote

Here is a fun example that has random triggers of overlapping samples. (You need to log in first to be able to see the download link in the Community Library.)

answered May 4, 2016 by ssc (Savant) (128,080 points)
Thanks a million! This gives me some great stuff to study!
...