Does JUCE need to own the main loop of my app?


#1

I am just starting out with JUCE, so sorry in advance if my questions show that I don’t understand JUCE properly. The truth is that I don’t, and that’s why I’m asking the questions!

I want to host VST plugins in my Windows app, and it looks like JUCE is going to be really helpful with this. From my experiments so far, it looks great! I’m beginning to get to grips with the VST code by looking at the Plugin Host sample, and I’ve make some simple sample apps of my own, but I have a few questions about using JUCE in general as well as about using it for hosting VST plugins.

  1. Do I need to use the JUCEApplication base class?
    I had tried to create an AudioProcessorGraph without this, but it didn’t work and didn’t hook up to the sound card. When I created an App class derived from JUCEApplication, it all started to work.

  2. Does the JUCEApplication have to ‘own’ the main loop of my program?
    When I use the START_JUCE_APPLICATION macro, this owns the main() and the main loop of the program. I don’t really want this. My app isn’t really a “JUCE application”. It’s more like a game with its own main loop. I want to use JUCE as a library to provide sound - via VST plugins - but don’t want to give control of my main loop to JUCE. If it’s best to use a class derived from JUCEApplication, could I run it on a different thread, or would that cause problems?

  3. Are there any gotchas with threading and hosting VST plugins?
    I read in another topic some things I didn’t really understand about creating plugins on the JUCE message thread and calling other functions on the audio thread. If I’m running my JUCEApplication on its own worker thread, should I marshal any changes - such as adding plugins - to that thread? Is the thread that JUCE runs on the message thread? Can I add midi events from any thread, or should this be done from a JUCE-specific thread? As you can tell, I’m a bit confused about this, so some advice would be useful. For example, maybe you could point me to some docs about which callbacks occur on which threads.

Sorry for all the questions. I’m really keen to use JUCE, as it looks very powerful and like it does exactly what I need. And a few pointers will really help me to get to grips with it.

thanks,
Richard


#2

Hi Richard Shepherd,

I can’t help you much with the questions as I’m as you just starting my Juce-journey. But nevertheless I have some helpful links about realtime audio programming, that I found worth sharing:
This one is about real time programming in general
http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing
this one is about lock-free queues that can be an alternative solution to the classical mutexes.
http://www.rossbencina.com/code/lockfree

Hope it helps you a bit,
StrangeMan


#3

Actually, his website has a great article describing the “sad state of Android audio latency:”

http://www.rossbencina.com/