Cabbage Logo
Back to Cabbage Site

Having trouble recreate the SimplerSampler Example

Hello to the community, very noob user here.
I am trying to recreate the SimplerSampler Example
(A Live-style sampler in Cabbage)

I am on Windows 10 machine,
I have installed the Cabbage 2.9.0 version.
In the begging, I was trying to run the SimplerSampler example without the Python script.
After I realize that I need to install it,
I install first the “python-3.11.3-amd64” release, but I had some errors finding the py.dll and one more .dll file.
after some small research on the web, I have found that I need to set up some Python folders.
I Did that,
set OPCODE6DIR64=C:\Program Files\Csound_x64\plugins64
set PATH=%PATH%;C:\Program Files\Csound_x64\bin
(I did some computer restarts) still, the problem was there.
I got confused a bit with some documents regarding Python 2.7, so I remove the v3.11 and install v2.7, again some other issues appear so in the end I remove all 2.7 and re-install the v3.11.3)
and after some restarts etc these errors stopped appearing.

Now running the last version of the SimpleSampler example,
I don’t have any errors, but from the moment I am dragging a sample,
this error appears…

/*============================================================*/
UnifiedCSD:  C:\Users\user\Desktop\Cabbage\SimpleSampler (2).csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: PortAudio module enabled ...
using callback interface
error:  Unable to find opcode entry for 'cabbageCreate' with matching argument types:
Found: (null) cabbageCreate S
Line: 32
 from file C:\Users\user\Desktop\Cabbage\SimpleSampler (2).csd (1)
Parsing failed due to syntax errors
Stopping on parser failure
cannot compile orchestra

Sorry for my noobieness, but don’t know where else to find startup solutions. :slight_smile:

Hi @JohnCX, welcome to the forum :slight_smile:

What Python script? You don’t need Python to run Csound or Cabbage. If you get some kind of warning about Python, just remove the py.dll file from your Csound folder. I’m afraid you went to a lot of trouble for nothing :grimacing:

When you say last version, you mean the one marked jpdated? I just downloaded and ran it here without any problems. If I run the first version, I get compile errors like the ones you listed. But the updated version works fine for me. Can you double check you are trying the correct version. Maybe you can attach the version you are trying so I can make sure it’s the correct one?

1 Like

oh God! haha niceee :)) completely wrong way then… :woozy_face: :innocent:

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. :slightly_smiling_face:

Is the sampler working now? Or do you still get that error? I’m not at my PC now…

Probably best to start a new thread about this :+1:

1 Like

No is not working.
The Sampler is running normally, I am dragging the .wav file without any problem and the waveform appears as expected.
The error message appears when I am trying to play the .wav file.

/*============================================================*/
UnifiedCSD:  C:\Users\user\Desktop\Cabbage\SimpleSampler.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: PortAudio module enabled ...
using callback interface
sample rate overrides: esr = 44100.0000, ekr = 1378.1250, ksmps = 32
sorting score ...
	... done
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 4096 sample-frame blocks
SECTION 1:
Cabbage version:2.9.0
instr 1:  p4 = 60.000
INIT ERROR in instr 1 (opcode diskin2) line 95: diskin2: number of output args inconsistent with     number of file channels
 from file C:\Users\user\Desktop\Cabbage\SimpleSampler.csd (1)
a1	diskin2	#S7	#i8	0	0	0	0	0	0	0	
		   T  5.761 - note deleted.  i1 had 1 init errors

That error is because this instrument is only set up to play mono files. That’s mentioned in the video as far as I remember. You can modify it to work with stereo files if you wish. The filechnls opcode will help you determine if it’s stereo or mono. :+1:

1 Like

Got it, thank you!:slight_smile:

1 Like