guitarix icon indicating copy to clipboard operation
guitarix copied to clipboard

guitarix lv2 plugins for osx

Open proboofficial opened this issue 5 months ago • 17 comments

hi I try build lv2 plugins of Guitarix 0.44.0 on Mac OS I spent much time for this. I install all dependencies via home-brew. first I configured with ./waf configure --prefix=/opt/guitarix-osx --includeresampler --includeconvolver --optimization --no-avahi --install-roboto-font --no-faust --no-standalone --no-lv2-gui and modified some files and now I can compile and run lv2 with generic ui on macOS. Next step I configure ./waf configure --prefix=/opt/guitarix-osx --includeresampler --includeconvolver --optimization --no-avahi --install-roboto-font --no-faust --no-standalone and again change some part code when I give compile errors every changes in py file I change via

if sys.platform == 'darwin':
        run Mac OS code
    else:
        original code

and cpp/h files all changes I make with 


#IFNDEF __APPLE__
orginal code
#ENDIF

or 

#IFDEF __APPLE__
 macOS code
#ELSE 
oryginal code
#ENDIF

now I can compile with lv2 gui without errors but still work only generic ui in ardour on Mac when I try load some gx lv2 with normal gui I have: "failed to instantiate LV2 GUI"

Where I can send this changes for yours review

proboofficial avatar Jul 22 '25 10:07 proboofficial

Please make a fork of guitarix and send a pull request with your changes. I'll review and merge them then.

Nice to hear that the plugs works on Mac. For the GUI's, yes, they use libxputty to create the GUI's, on windows it use HWND and on Linux it use X11. Mac support is not implemented in libxputty so they wont be shown on Mac. It could be done, the file defining the functions needed to be ported to Mac been here: https://github.com/brummer10/guitarix/blob/master/trunk/src/LV2/xputty/header/xwidget-platform.h

and this is the related wrapper for linux:

https://github.com/brummer10/guitarix/blob/master/trunk/src/LV2/xputty/xwidget-linux.cpp

what we need is such a wrapper for mac Cocoa to make it work on Mac.

brummer10 avatar Jul 22 '25 11:07 brummer10

pls check I make good pull request

proboofficial avatar Jul 22 '25 14:07 proboofficial

Hey im in good step for cocoa implementation xwidget-macos.mm but still must work for some elements. knobs rotate not work good, not see actual value for knobs, menu for choice amp amp-style and amp-cab not work for click.(

Image

)

proboofficial avatar Jul 28 '25 07:07 proboofficial

Cool!

brummer10 avatar Jul 28 '25 07:07 brummer10

i have idea ask. When I finish lv2 implementation for Mac it's possible Make from guitarix standalone gx_head vst3 plugin with cocoa. I know you make wrapper vst3 using juice but I like look guitarix standalone.

proboofficial avatar Jul 28 '25 07:07 proboofficial

That would be possible, yes. Just that will be a lot of work to recreate the original guitarix GUI with xputty. I'm personally didn't like the vst3 standard much, LV2, CLAP and even vst2 been much cleaner in my opinion.

As a side hint, the original libxputty is here: https://github.com/brummer10/libxputty In guitarix (LV2) I use just a subset of it, but for rebuild the original guitarix GUI we may need the full version of libxputty.

brummer10 avatar Jul 28 '25 08:07 brummer10

but can we make from gx_head lv2 plug than and add drag drop need plugins? or technically its not possible?only vst3 or clap can only

proboofficial avatar Jul 28 '25 08:07 proboofficial

Yes, we can do that in LV2 as well. libxputty is dnd aware.

brummer10 avatar Jul 28 '25 08:07 brummer10

Hey how you make on Linux and Windows popup menu combobox show under combobox my in Cocoa show in 0,0 position and have size width 25 height 10

proboofficial avatar Jul 31 '25 08:07 proboofficial

This is done in xmenu_private.cpp line 139 in function void _configure_menu(Widget_t *parent, Widget_t *menu, int elem, bool above) https://github.com/brummer10/guitarix/blob/master/trunk/src/LV2/xputty/widgets/xmenu_private.cpp#L139

important been that the calls to the following functions been implemented: os_get_window_metrics os_translate_coords os_get_root_window os_resize_window os_move_window

Aslo, I just see that I've put a #ifndef _WIN32 in the create_menu function. That's bad and should be changed to something like #ifdef linux

https://github.com/brummer10/guitarix/blob/master/trunk/src/LV2/xputty/widgets/xmenu.cpp#L65

brummer10 avatar Jul 31 '25 10:07 brummer10

I've made a lot of changes to the Cocoa GUI implementation. I'm stuck with the following problems:

  • When launching the plugin, the GUI doesn't update the view, and all the knobs don't have the default values from DSP.
  • The pop-up menu is narrow at the default size from Xputty, even though the logs show that it expands after clicking, and there are different width and height values. The value from the combobox only appears when the mouse is hovered over the combobox.
  • By default, the plugin is enabled, and the on/off button has an off icon, which also changes to on only when the mouse is hovered over it. Can you help me with this problems

proboofficial avatar Aug 03 '25 14:08 proboofficial

Yes, sure. Could you upload your state to your fork, I'll have a look at the main loop for macos to see what goes on.

brummer10 avatar Aug 03 '25 16:08 brummer10

ok I push files into my fork look into file src/xputty/xwidget-cocoa.mm

proboofficial avatar Aug 03 '25 17:08 proboofficial

ok i change 2 functions and this help with set button icon on and default dsp values

void os_adjustment_callback(void *w_, void *user_data) {
    Widget_t *w = (Widget_t *)w_;
    transparent_draw(w, user_data);

    id obj = (__bridge id)w->widget;
    if ([obj isKindOfClass:[NSWindow class]]) {
        NSView *contentView = [(NSWindow*)obj contentView];
        [contentView setNeedsDisplay:YES];
        [contentView displayIfNeeded];
    } else if ([obj isKindOfClass:[NSView class]]) {
        [(NSView*)obj setNeedsDisplay:YES];
        [(NSView*)obj displayIfNeeded];
    }
}

void os_expose_widget(Widget_t* w) {
    if (!w || !w->widget || !w->surface || !w->cr) return;
    if (w->state == 4) return;

    transparent_draw(w, NULL);

    id obj = (__bridge id)w->widget;
    if ([obj isKindOfClass:[NSWindow class]]) {
        NSView *contentView = [(NSWindow*)obj contentView];
        [contentView setNeedsDisplay:YES];
        [contentView displayIfNeeded];
    } else if ([obj isKindOfClass:[NSView class]]) {
        [(NSView*)obj setNeedsDisplay:YES];
        [(NSView*)obj displayIfNeeded];
    }
}

I make forced redraw here

now only poup menu must be repair

proboofficial avatar Aug 03 '25 20:08 proboofficial

Nice. Maybe you should add some printouts to the _configure_menu() function to check the values calculated there. https://github.com/proboofficial/guitarix/blob/master/trunk/src/LV2/xputty/widgets/xmenu_private.cpp#L139

In special, check x1, y1 (they give the position for the popup menu) and item_width, height*elem ( they give the size )

brummer10 avatar Aug 04 '25 06:08 brummer10

I've found the cause of the problem with the pop-up menu not displaying correctly and not responding to the clicked item. On Windows and Linux, each window is a child window, and the hierarchy is maintained. In Cocoa, the window creating the pop-up menu is a separate window; it doesn't share anything with the main window. It's not a child window like it is in Linux and Windows. I need to find a workaround to force the os_expose_widget function to work for a pop-up menu with a forced redraw function that isn't in the main window's hierarchy.

proboofficial avatar Aug 05 '25 20:08 proboofficial

A pointer to the popup window is in any case in main->childlist and a direct pointer to the Widget_t struct from the popup Window is main->hold_grab. Only one widget could hold the grab. Maybe that helps.

brummer10 avatar Aug 06 '25 06:08 brummer10