Cabbage Logo
Back to Cabbage Site

Iterate through samples with knob

No, the sample is already on disk with the convention explained.

Like DRUMS_SNARES_SNARELOW.WAV already exists on disk, no further summing needed

So this identified sample will be played back when identified with the help of the 3 dimensions.

Right, I get it now! Sorry, that just wasn’t clicking. So this is basically an exercise in creating the file names and triggering the samples? Do you already have a folder set up with some samples in it? If so can can you zip it and post it? You don’t need to include all the samples, just a handful so I get the picture. I might not be able to get back to you till tomorrow, but I’ll take a look when I get a chance.

Yes! Creating the filenames and then triggering the identified samples.

In the attachment is an example folder. examples.zip (2.9 MB)

Thank you!!!

I can’t open that zip file?

My bad, I got it now…

This simple instrument will let you create a file name based on the current values of the comboboxes. It this what you were looking for?

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
combobox bounds(10, 18, 80, 20) channel("combo1"), channelType("string"), value("DRUMS") text("DRUMS", "MELODY", "SYNTH", "VOX")
combobox bounds(100, 18, 80, 20) channel("combo2"), channelType("string"), value("FXDRUMS") text("FXDRUMS", "LOWPERC", "SNARE", "TOM")
combobox bounds(190, 18, 80, 20) channel("combo3"), channelType("string"), value("KIKK") text("KIKK", "BAY01", "TOMOH", "SAW1")
button bounds(10, 44, 80, 40) channel("button1"), text("Set sample")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;DRUMS_FXDRUMS_KIKK.wav
;DRUMS_LOWPERC_BAY01.wav
;DRUMS_SNARE_TRANSIENTSNARE.wav
;DRUMS_TOMS_TOMOH.wav
;MELODY_HOOKS_MELHOOK01.wav
;MELODY_HOOKS_MELHOOK02.wav
;SYNTH_BASIC_SAW01.wav
;VOX_PHRASES_PHRASE01.wav

;instrument will be triggered by keyboard widget
instr 1

SCombo1, kTrigC1 cabbageGetValue "combo1"
SCombo2, kTrigC2 cabbageGetValue "combo2"
SCombo3, kTrigC3 cabbageGetValue "combo3"

kBut, kSetSampleTrig cabbageGetValue "button1"
printf "%s_%s_%s.wav\n", kSetSampleTrig, SCombo1, SCombo2, SCombo3

endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
i1 0 z
f0 z
</CsScore>
</CsoundSynthesizer>

FANTASTIC!!! @rorywalsh

One question left how to I hand over this string to diskin2 in best way possible?

And as soon as I try to let a knob control the combobox values, it only works if I remove
“channeltype(“strings”)”

kSliderValue cabbageGetValue "knob"
cabbageSetValue "combo1", kSliderValue

thanks so much!

You can use a sprintfk to create the string at run time.

Like so ?

String   sprintfk  "%s_%s_%s.wav", SCombo1, SCombo2, SCombo3
a1 diskin2 String

Maybe I miss something with that but I do get this failure:

INIT ERROR in instr 1 (opcode diskin2) line 37: diskin2: __.wav: failed to open file (No Error.)

thanks for assisting me!

No, this is back to the same problem as before, you can’t change the filename to diskin at runtime. So you either trigger another instrument to play the sample, or use an reinit. I would probably just trigger another instrument to do the playback whenever I change the sample. Write the sample name to a channel, and then pick it up in the playback instrument.

ok will try my best on it to solve it!

But, Will it be possible to link a knob to the combobox to switch through the strings?

From above: As soon as I try to let a knob control the combobox values, it only works if I remove
“channeltype(“strings”)”

kSliderValue cabbageGetValue "knob"
cabbageSetValue "combo1", kSliderValue

In that case use the code I posted previously on how to get the items from the combobox.

ok, I am nearer to what I need. I use a workaround for now using “strget” & “strset” combinations.
Diving deepr into the sprintfk opcode now.

1 Like