Cabbage Logo
Back to Cabbage Site

Recal multiple Filepaths(Global String Vars) in VST

Hey, I’m new. I’m trying to build a sampler like VST instrument. And I have 3 Questions related to that project. I hope it’s not too much to ask all 3 in 1 go.

Question 1:
I need the VST to recall multiple paths. As for now, the only way I have found to recall a path in the VST is the File Button, which of course recalls just one path. Having a File Button for each sample and making them all invisible except of the one that’s currently in “edit mode” feels like a very desperate solution. I also would like to use drag & drop of samples into the VST, and ideally store much more data like start & ending points, which wouldn’t work out this way. I’m sure there’s an elegant way to store variables/strings that I just don’t see yet. Anyone care to help me out?

Question 2:
If I want to use file writing opcodes, is it possible to obtain the path of the host applications project file, so the files that I save can be saved with/in the same place of the project?

Question 3:
Is it possible to obtain text that’s been dragged into the VST UI? It seems like the so called VST-XML that Studio One uses when drag-dropping audio clips from the timeline isn’t recognised as a file by the “LAST_FILE_DROPPED” variable, so I guess it’s just text and not a file yet. I can copy paste it into the Csound Output Widget. I can drag it from Studio one to the Desktop, which creates a .textClipping - File. If I drag that onto the VST it’s recognised. Is there a workaround to this problem? Do I need to script in Python for something like this?
Thanks in advance!

I’m on OSX 10.14.6, if that’s relevant.

Hi Stefan. Welcome to Cabbage world! :rofl: (I really need to lobby Google for a Cabbage emoticon :thinking:)

You come at a good time. I added some custom opcodes that will let you save whatever generic data you want without having to set aside widgets. You’ll need to grab the latest beta build to use them. Click on the drop link to get the installer. Note these opcodes are hot of the press and relatively untested, but there were written to handle the very task you mentioned.

You can query the “CSD_PATH” channel using chnget. You can read more about the various reserved channels here

I’ll need to think about this. The routines I use for this functionality are all based around actual files. Leave it with me. I should be able to figure out pretty quickly if it’s going to be possible or now. :wink:

I’m just download Presonus Prime. I hope I can emulate the problem with this software.

[edit] :rage: Seems I can’t load any third party VSTs with that version of Studio One. You don’t happen to know of any other hosts that provide this functionality?

I was able to emulate that behaviour by simply dragging text from an editor to a Cabbage plugin. I have added support for text. You can get the text using the LAST_TEXT_DROPPED channel. I think it’s better to use a unique channel for this right? Otherwise you would have to constantly check if the data is a file or a string of text. You can grab the latest build here once it’s done.

Here’s an example .csd that shows this in action.

<Cabbage>
form caption("Presets") size(360, 200), colour(34, 34, 34), pluginid("MPre"), scale(1), identchannel("formIdent")
csoundoutput bounds(10, 100, 340, 100)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
;sr is set by the host
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
    SFile chngetks "LAST_TEXT_DROPPED"
    if changed(SFile) == 1 then 
        event "i", 2000, 0, 1
    endif
endin

instr 2000
    prints chnget:S("LAST_TEXT_DROPPED")
endin

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

Thanks for the quick reply! I found a different post about the new opcodes. I’m still trail-and-erroring my way through this whole coding in Csound in generell, but I came up with something that seems to be working for storing the paths or data in general for recall in the DAW:

instr StoreData
SData = p4
SPointer = p5
SDataInQuotes sprintfk “”%s"", SData
iRes setStateValue SPointer, SDataInQuotes
endin

This way I might actually not need to save files in a Host-DAW-Session-Folder, but I’ll definitely look into CSD_PATH. Thanks for the hint1

And thanks for checking on the VST-XML drag and drop topic!!! If that would work, that’d be fantastic, because I could obtain the start and end point of the audio clip from the XML code.

Wow! Supercool! Thanks ALOT! When will you upload that Beta?
I mean even NI Kontakt isn’t supporting this yet. So, whoop whoop!!!

I see it’s already up. AWESOME!

Not sure. But I think Cubase does this too.

Native Instruments is no match for me! :rofl: Let me know if you hit any further problems. :+1:

Blockquote
Hey Rory, great work! The text dropping works in Studio One.

Right now I’m hitting a wall with my opcode to read out the XML tags though. I am able to read out the strings that I need, even though I’m not sure why I have to use k-rate for it. But when I want to convert the string to integer for the starting and ending points of the dropped clip, I’m not getting past the strolk opcode at initialisation. The error message is about it pointing to an empty string, which of course happens on init run. This is the opcode:

opcode ReadXML,Skk,S
Sxml        xin
kStart      strindexk Sxml,"<filename>"
kEnd        strindexk Sxml,"</filename>"
SFile       strsubk Sxml,kStart+10,kEnd
kStart      strindexk Sxml,"<start>"
kEnd        strindexk Sxml,"</start>"
SFileStart  strsubk Sxml,kStart+7,kEnd

kFileStart  strtolk SFileStart

kStart      strindexk Sxml,"<end>"
kEnd        strindexk Sxml,"</end>"
SFileEnd    strsubk Sxml,kStart+5,kEnd

kFileEnd    strtolk SFileEnd

xout        SFile,kFileStart,kFileEnd     

endop

Putting it into an if statement, checking the length of the string didn’t help. I guess what I’m learning here is, that every line of code gets initialised, no matter what (which can be a b…). Or are there ways to exclude things from init? I have a feeling, that’s not how things work, right?. I guess these are just beginner problems. Anyway, any ideas/hints on how I can do this?
Thank you!

Solved it. Man some stuff just seems really random, but I guess you get used to it, or maybe someday it’ll all make sense.? :dizzy_face:

strset 1,"0" 
opcode ReadXML,Skk,S
Sxml        xin
kStart      strindexk Sxml,"<filename>"
kEnd        strindexk Sxml,"</filename>"
SFile       strsubk Sxml,kStart+10,kEnd
kStart      strindexk Sxml,"<start>"
kEnd        strindexk Sxml,"</start>"
SFileStart  strsubk Sxml,kStart+7,kEnd
SFileStart  strget 1
kFileStart  strtodk SFileStart
kStart      strindexk Sxml,"<end>"
kEnd        strindexk Sxml,"</end>"
SFileEnd    strsubk Sxml,kStart+5,kEnd
SFileEnd    strget 1
kFileEnd    strtolk SFileEnd
xout    SFile,kFileStart,kFileEnd
endop

Hi Rory,

this gives me my VST path, not the path of the Studio One song. Maybe DAWs actually don’t or can’t send this kind of information. The Melodyne plugin records into one specific Melodyne folder on the system for example. I figure that they would have figured this one out if it’s possible.

I don’t know of any ways within the common plugin framework to access this information. I’m inclined to agree with your assessment that if it was possible companies like Celemony would have worked it out.

Well done on the XML parsing stuff. I hate working with strings in Csound. You should be able to do it all with i-rate variables too, so long as you use the i-rate versions of those opcodes. Strings in Csound are a extremely frustrating. :roll_eyes:

Somehow that didn’t work. I didn’t get any output, I think not even a input for the string variables apart from some init stuff that seemed quite random to my newbie brain. As soon as I just switched from i to k with the vars and opcodes it worked just fine. Thanks for pointing out that strings suck even for you, that makes me feel better about my string-struggles.

Hey Rory,
Somehow with the 2.5.18 release the “LAST_TEXT_DROPPED” doesn’t work anymore. Instead the “LAST_FILE_DROPPED” recognises the text. Is that on purpose? It makes it a bit more complicated for me, but I can work my way around that of course. Just wanted to make sure if you intended the change.
Thanks!

That’s my fault. Sorry, I’ll fix that when I get a chance…

[edit] I just ;pushed the fix to git now. Should be available in Azure shortly.

Cool! Thanks!!