Convert application to a static library returning a UIView/NSView

I have developed a first single-window application with JUCE, which analyses sound and does some visualisation… In a grand scheme of things, I would like to convert visualisation to use SceneKit (with Metal). It’s so horrendous to try to access audio in native way on iOS/MacOS that, after much research, I’ve decided I need to stick with JUCE for audio access.

I’ve been researching here on forum and elsewhere about combining JUCE with some extra code that uses Swift and is native to iOS/MacOS. The best suggestion so far comes from here: How Set up project to use Cocoa in Juce?

It seems to suggest that the best way is to create static library with JUCE and then use it from a native project for iOS/MacOS. I would also like to use some GUI elements that I’ve created for the app. So far, I’ve come up with the following approach:

  1. Create a static library with JUCE
  2. It would have a method where I could pass a lambda (from Swift) that would handle the audio
  3. I would also like the library to initialise a component internally (NSView/UIView depending on platform) and make that view accessible to library users.
  4. The native application would then get the view from the library and place it somewhere in its native user-interface. For my use case, I would make an SCNView in a native app that would just do the drawing. I would then place the NSView returned from the library over it. The NSView from the library would be partially transparent, so you would still see SCNView under it. The view from the library would be used to configure the audio and other settings.

I have the following questions:

  1. How can I make a static library method that, when called, would access the audio, and start processing it with the default settings (like it now happens with the regular app), but without actually making and starting the whole application?
  2. Can the library just instantiate it’s only component and just hold it in a static variable, and then give a reference to it to the main native app, which would display it wherever it wants?
  3. Any other suggestions, alternative approaches?

Thanks in advance!

1 Like

P.S. No replies. This is what is do now: Recepe (How To): Metal-backed control (SceneKit/SpriteKit) for iOS/MacOS

1 Like