Cabbage Logo
Back to Cabbage Site

Combobox/populate under Mac OS X

It seems to me that combobox with populate does not work properly on Mac OS (10.15.7). Here is the example code: https://drive.google.com/file/d/18MSydroZOG46DE3sOoJLNsG49uGcD3yk/view?usp=sharing (You need to create a directory Mpresets here from https://gitlab.com/RZ-FZJ/rz-cabbage-recipes/-/tree/master/Mpresets or just create it with dummy files as foo.mset, bar.mset…)

When I run this on Mac OS I get in the console:

Csound output message console

/============================================================/
WARNING: could not open library ‘/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Resources/Opcodes64/libfluidOpcodes.dylib’ (-1)
WARNING: could not open library ‘/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Resources/Opcodes64/librtjack.dylib’ (-1)
UnifiedCSD: /Users/zorn/P/Texte/OwnMusic/Cabbage/Cboxtest.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: PortAudio module enabled …
using callback interface
opcode changed deprecated
sample rate overrides: esr = 44100.0000, ekr = 1378.1250, ksmps = 3
sorting score …
… done
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 1024 sample-frame blocks
SECTION 1:
Cabbage version:2.8.0
Filename from Combobox: |0.0|
Filename from Combobox: |Pluck|
Filename from Combobox: |Scratch|

The first item (Filename from Combobox: |0.0|) appears even before I select anything. In the second and third item (after selecting in the GUI) there is only the file base name (without extension and path), i.e. just what is displayed in the GUI. This made my instrument “Morpheus” crash what made me aware of the problem.

If I start the same test code under Windows (10) the result is as expected from the docs:

WARNING: could not open library ‘C:\Program Files\Csound6_x64\plugins64\py.dll’ (-1)
UnifiedCSD: C:\Users\Reiner\Documents\OwnMusic\Cabbage\Cboxtest.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: PortAudio module enabled …
using callback interface
opcode changed deprecated
sample rate overrides: esr = 48000.0000, ekr = 1500.0000, ksmps = 32
sorting score …
… done
midi channel 1 using instr 20

midi channel 64 using instr 20
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 4096 sample-frame blocks
SECTION 1:
Cabbage version:2.7.0
Filename from Combobox: |C:/Users/Reiner/Documents/OwnMusic/Cabbage/Mpresets/Pluck.mset|
Filename from Combobox: |C:/Users/Reiner/Documents/OwnMusic/Cabbage/Mpresets/Scratch.mset|

There is nothing sent by the combobox before I choose a file and the filename returned is with full path as expected from the docs.

Is it possible to change the Mac OS code so that it works like on a PC? That would save me from coding some clause in Csound to add the path and extension if it is not included with the combobox value.

PS: I tried to trap this error with a

if (filevalid(SLoad)==1) then

but for some reason filevalid also does not return 1 if the file really exists. Does it check for anything else but existence of a file? What would be the correct way to check for file existence in Cabbage? (Python’s “try” is the most ugly concept in the history of programming languages. But at that point it would be handy.)

Can you leave it with me. I know some code did change there a few months back in order to accommodate more robust custom preset systems. I will have to search back through the commits. Only I won’t have a chance to look into it till tomorrow. Sorry about that. I’ll get back to you then.

1 Like

I’ve been seeing some oddities with combobox on OSX too, is it perhaps related to this?

I don’t see it all of the time, so I was trying to figure out if it was something I was doing wrong… but certain comboboxes first appear as blank with no choices displayed. Once I click on it, the menu appears with all of the correct choices, and afterwards the box appears populated as normal.

I hadn’t reported yet because I’ve fallen so behind, I was trying to figure out why I seem to only see this in some cases (but consistently in those), plus I’m doing a lot of non-standard things, such as using macros in the combobox definition, and changing visibility (still via identchannel) based on different criteria etc etc.

Don’t hurry. I am back home using my windows PC again. For me it’s only an issue when I have to use the Macbook on travel.

I had a few minutes now to look at this, and I’m not sure what is going on. I have other examples that seem to work fine, but right now I can’t tell why they do and this doesn’t. I’ll be less tired tomorrow when I look at it!

I’ve just triggered a new build with a fix for this. I think I removed it at some point to test some things and then accidently left it in. My apologies. I guess we have to keep in mind that all of these beta builds are coming from the dev branch. Anyhow, I also updated the currentDir identifier so that it also returns the full path, even if a relative one is passed to the populate() identifier :wink:

I did a quick test on my Macbook. Version 2.8.9, isn’t it? Maybe I overlooked something, but now I get an empty combobox:

even though there are files of type *.mset in a subdirectory Mpresets which should be loaded by

combobox bounds(552, 194, 104, 32), channelType(“string”), channel(“load”), populate(".mset",“Mpresets”)
filebutton bounds(606, 230, 50, 32), channel(“save”), text(“save”), mode(“save”), populate("
.mset",“Mpresets”)

Also the save seems not to work as it should, always saving into the current directory.

Do you have a quick idea why this happens? I can also do some more tests later today.

Sorry, I bricked it yesterday with a change I made to the currentDir identifier AFTER I had fixed this issue. I just pushed an update now. I will like currentDir to return an absolute path, but for now it’s not a big deal. First, let’s get this working as you expect :wink:

Thank you! But I fear there is still a difference PC vs Mac in how the combobox works. Here is the Mac console output of the test code mentioned in the beginning:

SECTION 1:
Cabbage version:2.8.10
Filename from Combobox: |0.0|
Filename from Combobox: |/Users/zorn/P/Texte/OwnMusic/Cabbage/Mpresets/Default Dry.mset|

The important thing is that “Filename from Combobox: |0.0|” is output before I select anything, presumably at i time. This is not happening on a PC where the first output is written only after I make a selection in the combobox.

As I said before errors resulting from this could be trapped by checking for file existence. (That would also be nice for the case that the user deletes a file ‘behind the scenes’.) But unfortunately (although there is a ftloadk) there is no ftvalidk in Csound. I made a feature request for Csound to include this.

Yes, i see this now also, sorry, I didn’t think to check this on the Mac. I’ll try to get this sorted asap.

So just now something occurred to me. You are not using guiMode(“queue”). Add this to the form declaration and everything works fine. I will try the fix so it works regardless of the guiMode() used, but at least for now it should make things consistent across platforms.

Yes, the code is from pre-queue times. With “queue” I guess I will have to change chnset to some Cabbage command because otherwise the sliders in the GUI will not move when the channel value is changed?

It’s up to you. You can continue to use the old style way of doing things, which causing more strain on the CPU, or the newer way of doing things, which is more efficient and doesn’t ever block the audio thread (not that I ever saw this happen with the older system…).

For more info on the new way of updating widgets, look here. You no longer need to use an identchannel. All communication is done on the same channel. Either way, I don’t plan on removing the old system. It’s mark deprecated, but will continue to work.

I took a deeper look at this and the reason why it print 0.0 is that Cabbage doesn’t recognise straight away that this is a string channel. So it gives it a default numerical value, i.e, 0.0. But if you wish to stick with the older style ident channel stuff, just set the default value to “”, i.e.:

combobox bounds(10, 10, 104, 32), channelType("string"), channel("load"), populate("*.mset","Mpresets"), value("")

That will stop the initial change from being triggered, and things will once again work as they had before.

Thank you for this solution. Of course, on the long run I should convert the old instruments to queue-style. But you have seen how many chnsets are in the Morpheus instrument…

BTW, Csound people will include filevalid:k in 6.17. So there will be a check possible whether the filename returned by combobox corresponds to an existing file. This would also catch the somewhat unrealistic case that someone deletes a file after it has been listed by populate.

Each time you call populate it refreshes from disk, so if a file is deleted, it should also disappear from the list. But you would need to call populate in your Csound code.