A few usefull classes for JUCE

Wow, Gin offers an astonishing set of functionality … OSM in my JUCE, oh my!

3 Likes

I love the webp image support that has only recently been added—so much better quality than jpeg. In our use-case, the files are so much shorter.

@RolandMR - Hi, I use gin modules in my projects; I updated today to Juce 7.0.5 develop, from 7.0.3.

I use Projucer to manage my projects.

I updated to the latest version of gin today. I am compiling on Mac at the moment.

As part of the 7.0.5 Projucer update, it apparently adds the compiler flag -Wfloat-equal, and because of this, gin is generating a whole bunch of warnings. Is this something you’re aware of?

I can just add the #pragma clang diagnostic ignored in various places, but I wondered why it wasn’t already in there?

I think that warning became on by default in a newer Xcode version. I guess I’m still using an older version. Anyway, I think I have it cleaned up now. Can you code review this and make sure I didn;t do anything backwards: Fix float compare warnings · FigBug/Gin@0089110 · GitHub

Thanks, that fixes it - I didn’t see anything that looked wrong offhand.

Incidentally, I use a much older version of Xcode so that is not it - the Projucer adds this flag now:

If anybody isn’t familiar with Gin, I created a blog post that is a high level overview:

12 Likes

Good call on the blog! So many goodies I wasn’t aware of.

Happy to see Gin getting some love. It was one of the first third party JUCE codebases I looked at and inspired me to want to package and release my own open source JUCE stuff. Stack blur in particular was a life saver :slight_smile:

2 Likes

@RolandMR Gin is awesome! The BMP image format class is super useful for achieving much faster load times with plugins that use high res raster UIs. Am also using FileSystemWatcher for my preset management system as well as my sample management system. Works fantastic. Will give the WT oscillator a go soon.

1 Like

So what’s the correct order in CMAKE in order to add Gin to an existing project?
I cloned Gin next to JUCE folder and did this:

add_subdirectory(JUCE)                 
add_subdirectory(Gin)

And inside Gin\CMakeLists.txt I commented out:
#add_subdirectory(Juce)

This will build fine, but if I try to include some header so I can use something from Gin
#include "../../Gin/modules/gin_dsp/gin_dsp.h"

I get a build error

Gin/modules/gin_dsp/gin_dsp.h:63:10: fatal error: 'gin/gin.h' file not found

What’s the CMAKE magic command to fix it?

You can just add the specific modules you want to use:

foreach(module_name IN ITEMS gin gin_dsp gin_graphics gin_gui gin_plugin)
	juce_add_module (
		"${CMAKE_CURRENT_LIST_DIR}/modules/Gin/modules/${module_name}"
		)
1 Like

Thanks. Please bear with me since I’m a little slow with CMAKE.
The folder Gin/modules already has a CMakeLists.txt file which calls juce_add_module for all of Gin’s modules, so adding your code will give a build error that the target already exists.

So I removed the call to add_subdirectory(Gin). The projects builds again but I am at the same spot where if I include a module’s header, the header file can’t find gin/gin.h

Sounds like what you are doing should work, gin_dsp depends on gin, so you need to add both modules. Can you post your full CMake file?

I have an example file here maybe you can copy? https://github.com/FigBug/GinPlugin/blob/main/CMakeLists.txt

You actually don’t need to explicitly add the dependencies of other modules, those are added automatically.
So adding juce_gui_extra, for example will also auto-add juce_gui_basics, juce_core, etc.

1 Like

Ok so I after I brute-forced my way into it and tried every possible combination this is how I got it to work:

In the main CmakeLists.txt file I do include both:

add_subdirectory(JUCE)                 
add_subdirectory(Gin)

In target_link_libraries:

target_link_libraries(...
        gin
        gin_dsp
        )

And in my source file where I want to use Gin:

#include "... Gin/modules/gin/gin.h"
#include "... Gin/modules/gin_dsp/gin_dsp.h"

So I do have to add Gin as a directory and explicitly call both gin and gin_dsp everywhere or else it will break for me.

When you link against a module it already gets added to the include directories.

You just need to include:

#include <gin_dsp/gin_dsp.h>

You shouldn’t have to add include directories directly for modules.

You do need to call add_subdirectory(gin), but you only need to link against gin_dsp, since it auto-adds gin. You also only need to include gin_dsp.h as that header also includes gin.h (and other JUCE headers required for that module, like juce_dsp.h that will also get linked directly).

1 Like

It seems the latest Gin has C++20 as the minimum supported?

Has JUCE moved to C++20 now?

JUCE is C++17 for minimum requirement, I moved to C++20 just because it makes a bunch of things nicer.

I added Gin via CPM / FetchContent.

This is what worked:

CPMAddPackage(NAME Gin
        GITHUB_REPOSITORY FigBug/Gin
        DOWNLOAD_ONLY TRUE
        GIT_TAG master)

juce_add_module(${Gin_SOURCE_DIR}/modules/gin)
juce_add_module(${Gin_SOURCE_DIR}/modules/gin_graphics)
...