oh God! haha niceee :)) completely wrong way then…
ok so here is the script…
I have added a script to change the colors every time you click the slot of a “SampleSlot”
(Ok I wanted only to change the label fontcolour, couldn’t find it, but for the moment this is fine, I will learn and work more).
And also I have changed the while iCnt < 16 to 17. Because when I was clicking on the SampleSlot16,
I couldn’t get the SFreqChannel(16)… I thought that the d% starting from 1 and not from 0, so maybe needed the 17 value there…
<Cabbage>
form caption("Simpler Sampler Test") size(800, 400), guiMode("queue"), colour(255, 255, 255), pluginId("def1")
keyboard bounds(12, 292, 780, 95)
soundfiler bounds(327, 7, 458, 194), channel("soundfiler1")
;image bounds(8, 6, 76, 62), channel("sampleSlot1"), outlineThickness(3), corners(10), outlineColour("black")
;button bounds(24, 40, 46, 22), text("Play"), channel("sampleSlotPlay1")
;label bounds(24, 16, 46, 18), text("1"), fontColour("black"), channel("sampleSlotLabel1")
;rslider bounds(338, 206, 60, 60) range(0, 2, 1, 1, 0.001), channel("sampleSlotFreq1"), text("Freq")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
;instrument will be triggered by keyboard widget
instr SampleSlot
iSlotNumber = p4
iX = p5
iY = p6
SImageCode sprintf "bounds(%d, %d, 76, 62), channel(\"sampleSlot%d\"), outlineThickness(3), corners(10), outlineColour(\"black\")", iX, iY, iSlotNumber
SButtonCode sprintf "bounds(%d, %d, 46, 22), text(\"Play\"), channel(\"sampleSlotPlay%d\")", iX+16, iY+34, iSlotNumber
SLabelCode sprintf "bounds(%d, %d, 46, 18), text(\"%d\"), fontColour(\"black\"), channel(\"sampleSlotLabel%d\")", iX+16, iY+10, iSlotNumber, iSlotNumber
SFreqCode sprintf "bounds(338, 206, 60, 60) range(0, 2, 1, 1, 0.001), channel(\"sampleSlotFreq%d\"), text(\"Freq\"), visible(0)", iSlotNumber
cabbageCreate "image", SImageCode
cabbageCreate "button", SButtonCode
cabbageCreate "label", SLabelCode
cabbageCreate "rslider", SFreqCode
SFileChannel sprintf "sampleSlot%d_file", iSlotNumber
SChannel sprintf "sampleSlot%d", iSlotNumber
SLabelChannel sprintf "sampleSlotLabel%d", iSlotNumber
SPlayChannel sprintf "sampleSlotPlay%d", iSlotNumber
kBounds[] cabbageGet SChannel, "bounds"
kX chnget "MOUSE_X"
kY chnget "MOUSE_Y"
kMouseDownImage, kImageTrig cabbageGetValue SChannel
kMouseDownLabel, kLabelTrig cabbageGetValue SLabelChannel
if kLabelTrig == 1 || kImageTrig == 1 then
cabbageSet 1, "soundfiler1", "file", chnget:S(SFileChannel)
event "i", "ShowFreqSlider", 0, .1, iSlotNumber
endif
SFile, kFileChanged cabbageGet "LAST_FILE_DROPPED"
SCurrentWidget, kWidgetChanged cabbageGet "CURRENT_WIDGET"
if kFileChanged == 1 then
if kX > kBounds[0] && kX < kBounds[0]+kBounds[2] && kY > kBounds[1] && kY < kBounds[1]+kBounds[3] then
cabbageSet kFileChanged, "soundfiler1", "file", SFile
chnset SFile, SFileChannel
endif
endif
kButton, kButtonTrig cabbageGetValue SPlayChannel
if kButtonTrig == 1 then
event "i", "ShowFreqSlider", 0, .1, iSlotNumber
cabbageSet 1, "soundfiler1", "file", chnget:S(SFileChannel)
event "i", 1, 0, 1, 60+iSlotNumber-1
endif
ending
instr ShowFreqSlider
iSlotNumber = p4
iCnt = 0
while iCnt < 17 do
SFreqChannel sprintf "sampleSlotFreq%d", iCnt
SLabelTColor sprintf "sampleSlotLabel%d", iCnt
if iCnt == iSlotNumber then
cabbageSet SFreqChannel, "visible(1)"
cabbageSet SLabelTColor, "colour:0", "red"
else
cabbageSet SFreqChannel, "visible(0)"
cabbageSet SLabelTColor, "colour:0", 100, 0, 0, 255
endif
iCnt += 1
od
endin
instr 1
print p4
SFileChannel sprintf "sampleSlot%d_file", (p4-60)+1
SFreqChannel sprintf "sampleSlotFreq%d", (p4-60)+1
kDummyEnv madsr .01, 0, 1, filelen(chnget:S(SFileChannel))*5
a1 diskin2 chnget:S(SFileChannel), chnget:i(SFreqChannel), 0, 0
outs, a1, a1
endin
</CsInstruments>
<CsScore>
i"SampleSlot" 0 z 1 8 6
i"SampleSlot" 0 z 2 88 6
i"SampleSlot" 0 z 3 168 6
i"SampleSlot" 0 z 4 248 6
i"SampleSlot" 0 z 5 8 72
i"SampleSlot" 0 z 6 88 72
i"SampleSlot" 0 z 7 168 72
i"SampleSlot" 0 z 8 248 72
i"SampleSlot" 0 z 9 8 138
i"SampleSlot" 0 z 10 88 138
i"SampleSlot" 0 z 11 168 138
i"SampleSlot" 0 z 12 248 138
i"SampleSlot" 0 z 13 8 204
i"SampleSlot" 0 z 14 88 204
i"SampleSlot" 0 z 15 168 204
i"SampleSlot" 0 z 16 248 204
;i"SampleSlot" 0 z 2
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>
***Also, I tried to work with the “Grain3FilePlayer.csd” and load a sample without the OpenDialog,
meaning to have already a specific path and file in the code (like C:\test1.wav) and put it directly to the “gSfilepath” variable, so when the instrument is running to have it already loaded…but I fail completely.
I should do another topic for this later on.
By the way, thank you for your amazing/direct support here.