Cabbage Logo
Back to Cabbage Site

Text Editor example crashes

https://cabbageaudio.com/docs/texteditor/

I was trying to run this example because it has been a while since I’ve used a texteditor widget, and in copying and pasting it into Cabbage, it crashes my machine.

I looking at the code, it seems there isn’t a texteditor for the “scoText” identifier. So, I added one… still crashes.

I looked at the instr 1 and found there was no definition for the SText string, and in giving it one, everything runs fine… except…

  1. There is no “mode” identifier called in the widget definition, but these texteditors seem to be operating in “multi” mode, as it needs a “command-return” combination to send the data to csound.

  2. I get a system error warning beep every time I use the “command-return” combination to send the data to csound. I’m on Mac OS 10.13.6, running Cabbage 2.8.2.

Rory, any idea how I can get rid of the system error beep?

Sorry, I completely missed this one. Can you try this one, that .csd has some obvious issues. To test, just uncomment the schedule line and hit Ctrl+Enter :wink:

<Cabbage>
form caption("Texteditor Example") size(380, 300), guiMode("queue"), colour(2, 145, 209) pluginId("def1")

texteditor bounds(18, 20, 341, 204) fontSize(16), channel("orcText"), scrollbars(1), wrap(1),  fontColour(124, 210, 0), colour(0, 0, 0, 100)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 16
nchnls = 2
0dbfs = 1


; Rory Walsh 2021 
;
; License: CC0 1.0 Universal
; You can copy, modify, and distribute this file, 
; even for commercial purposes, all without asking permission. 

instr 1

    SText  = {{
/* A Cabbage texteditor is a simple text editor that can show static text, or provide a way of edit new or existing text. You can also send text back to Csound by hit Ctrl+Enter. When you do so, Csound will pick up the entire editor string.\n\nIn the this example we create a simple live-coding type environment. Each time we modify the Csound code it gets sent to Csound and compiled on the fly.\n\nAll of the Cabbage widget examples use simple texteditor widgets to show basic information, but they can also load entire text files using the 'file()' identifier.  */

;simple instrument
instr 1
    kEnv madsr .1, .4, .5, 1
    a1 oscili kEnv, p4
    outs a1, a1
endin

;schedule(1, 0, 2, 300)
    }}
    

    cabbageSet "orcText", "text",  SText

    SText cabbageGetValue "orcText"
    if changed:k(SText) == 1 then
        event "i", 2, 0, 1
    endif

endin

instr 2
    SText chnget "orcText"
    prints SText
    ires compilestr SText 
    print ires ; -1 as could not compile
endin

</CsInstruments>
<CsScore>
i1 0 z
</CsScore>
</CsoundSynthesizer>

Ok, this works, but I still get a system error beep every time I hit “cntrl-return”, but cabbage still operates as expected. I can turn the volume down on the system error messages, but I would really like to still get some error messages.

It’s pretty annoying. I simply disabled the system beeps, but it’s not a great solution. I’m in the process of updating my JUCE code base to the latest version. I hope the latest versions offer an easier way to manage this. I’ll keep you posted.