When it comes to the IP address I think reinit
is your only option, or an event opcode to kill and start a new instance of the sending instrument. You can press up and down in the test editor to bring up the previous strings. It has a history, but this is wiped each time you restart the instrument. You could combine a listbox with the text editor?
User input strings for OSCsend
Thanks for the suggestions!
Do I get it right that texteditor
cannot selectively send strings, or can it send individual lines?
Do you think I’d be able to add listbox
items by getting input from texteditor
and would these items be saved for the next session after restarting the instrument? This is obviously interesting beyond the scope of OSC sending.
It sends individual lines each time you hit return.
You could populate a listbox from a file on disk, which could contain the IP address and commands you wish to use?
Hmmm… on MacOS, I have to hit cmd+enter and then texteditor
send all lines not individual lines (same as right clicking and selecting send text).
I’m trying to change listbox items at k-rate. Possible?
The listbox example crashes Cabbage 2.8.121.
Is your texteditor set to multiline? It shouldn’t be?
Thanks I’ll take a look tomorrow.
Thanks! I see that by setting wrap(0)
I can hit Enter on texteditor
to pass 1 string.
But in multiline (wrap(1)
), cmd+Enter passes ALL strings. So, I suppose it is not possible to pass selected strings?
With listbox I could load items from file and maybe(?) change items like you show here: Combobox vs Listbox Dynamicism
The “problem” with that is a fixed length array of item strings.
Is there a simple way to change, append and delete items/lines in a text file? I think it is easy with numbers but it seems complicated with strings.
You know you can append items to a combobox using cabbageSet, IF the combobox string channel types? Check this example, it dynamically changes the items in the combobox:
<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
keyboard bounds(8, 158, 381, 95)
combobox bounds(20, 24, 160, 30) channel("combo1"), channelType("string")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
giNoteCounter init 0
;instrument will be triggered by keyboard widget
instr 1
cabbageSet "combo1", {{ items("one", "two", "three"), value("one") }}
endin
instr 2
cabbageSet "combo1", {{ items("two", "three", "four"), value("two") }}
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
i1 0 1
i2 2 1
</CsScore>
</CsoundSynthesizer>
Cool! That is useful. Thanks!
I’m still looking for a way to save user input to a file though. Maybe this is more of a Csound question rather than Cabbage. I could find the readf
opcode but I don’t know how I could write to a text file. Maybe I just have to go with a preset file containing all IP addresses or manually type in an address each time?
A work around might be to have a few texteditors with init strings like “localhost” or an IP number (which can be modified) and a radiogroup to select which string is being sent to OSCsend
…
Thanks! That one was hiding from me. Can this work with strings? Maybe one needs to convert string to number?
I guess it might involve some kind of conversion. You can use these opcodes directly in Cabbage. In particular the file to string and string to file. When used with strToArray, they can be quite useful.
Thanks! These are really precious opcodes! I think I can make it with them.
My plan is to: get input from multiple texteditors, concatenate strings with space separator, save to disk, load, separate stings with strToArray
, update texteditors (this would be the init if file exists).
It seems however, that strings in string arrays can be maximum 7 characters long. Is this a bug in strToArray
or is it a Csound limitation?
i’d say definitely a bug in Cabbage, I’ll take a look. Apologies for the delay in getting back to you, my kids are on school holidays, which means I struggle to find time to work on this stuff. But I will look into it soon , along with the other issue posted.
I just pushed a fix for this issue. Passes my tests
Thanks! I imagined you must be extra busy this time of year - no worries!
The other issues (buttons in Reaper, automation and gestures in Live, Non-latched buttons & automation) are more “baffling” as you say.
I just tested your fix on splitting strings and maybe it was too early, but it still seem to behave like before. I’ll give it a go another day.
I can workaround this by making a UDO using strindex
and strsub
. I couldn’t find a way to detect the number of separator strings other counting them in a loop, using this count to define a string array and then run a loop again to fill up the array, so I’m probably doing it in a stupid way and your opcode is surely more efficient.
I suppose I could use a local path for external opcodes and bundle
them, right?
Btw, it seems that reinit
might work best in my case for OSCsend
, so I don’t need to change all 20+ k-rate variables to global for an OSC instrument to receive them. Or am I missing something?
I doubt it, a few well placed reinit
s can be very powerful. I just tested here with 2.8.124 and it’s working fine?
What do you doubt? It seems you’re confirming my opinion about reinit
.
This splits fine S2split = "1234 123456789 12345678"
but try splitting this: S2split = "1234 12345678 123456789"
my output (in 2.8.124) from
SArray[] strToArray S2split, " "
iCnt = 0
while iCnt < lenarray(SArray) do
prints SArray[iCnt]
iCnt += 1
prints "\n"
od
is
1234
1234567
123456789
Sorry , I meant I doubt you are missing anything and you’re understanding of the solution is spot on. In hindsight, I could have phrased that better.
I’ll check that example later, I don’t know if it makes any difference but the string I was testing with had ‘,’ delimiters.
OK. Thanks!
It doesn’t seem to make any difference.
Can you try the latest build when it’s ready?