Juce Audio without any UI components?


#1

Hi Community,

I am currently evaluating Juce as a new technology for cross platform audio stuff. As fas as I can see it’s great because it is so versatile.

What I actually need is to have all those neat audio parts running completely apart from the UI. That means we probably can’t use the JUCE UI framework.
Therefore I just started with a very small Console test program (created from Introjucer) and compiled with VS2008 on Vista:

#include "../JuceLibraryCode/JuceHeader.h"
//==============================================================================
int main (int argc, char* argv[])
{
    AudioDeviceManager deviceManager;
    deviceManager.initialise(255,255,NULL, true);
    deviceManager.playTestSound();
    return 0;
}

Compile run well. Unfortunately it did not run, because of the missing event loop and the jassert inside Juce.

A juce application without a UI from juice seems not to be possible right now.
I found this entry on the forum: http://www.rawmaterialsoftware.com/viewtopic.php?f=4&t=8164

That’s why I check out the latest Juce from git. It’s 2.0.18 today. I tried it again but the command line still gets over the

in ChangeBroadcaster. It seems that Audiostuff without UI is still not possible. Has anyone else tried to do this before?
Can I eventually emulate this MessageManager by any chance? Is there another way to “initialize” Juce?

with kind regards
Matthias


#2

AFAIK you need to create a Juce application as well.

http://www.rawmaterialsoftware.com/juce/api/classJUCEApplication.html#_details


#3

You don’t actually need a JUCEApplication object, it’ll work without (as it does in plugins).

But you do need to initialise stuff - have a look in juce_Initialisation.h


#4

Thanks otristan for your answer.

Well, I didn’t want to start up a UI, so initialization a JUCEApplication wasn’t my prefered solution.
I can imagine to start a hidden JUCEApplication which only handles the event loop :wink:
But that might be overdozed. Isn’t there another solution?


#5

[quote]I can imagine to start a hidden JUCEApplication which only handles the event loop
But that might be overdozed. Isn’t there another solution?[/quote]

Did you not see my reply above?


#6

Yes, Jules you answed while I was typing :smiley:

This was the point I needed to know. Well, now I have a change request.

If you could rename initialiseJuce_GUI(); to initialiseJuce(); and shutdownJuce_GUI(); to shutdownJuce();
it would be much easier to find :wink:

The Solution now is the following. (The split has to be made because of a memory leak that might occour otherwise.)

void playTestSound()
{
    AudioDeviceManager deviceManager;
    deviceManager.initialise(255,255,NULL, true);
    deviceManager.playTestSound();
    Thread::sleep(5000);
}

//==============================================================================
int main (int argc, char* argv[])
{
       initialiseJuce_GUI();
       playTestSound();
       shutdownJuce_GUI();
    return 0;
}

#7

[quote]If you could rename initialiseJuce_GUI(); to initialiseJuce(); and shutdownJuce_GUI(); to shutdownJuce();
it would be much easier to find [/quote]

Well, there was originally a _NonGUI function as well, but that no longer exists… But you should be using ScopedJuceInitialiser_GUI anyway!


#8

Ok, changed:

void playTestSound()
{
	AudioDeviceManager deviceManager;
    deviceManager.initialise(255,255,NULL, true);
    deviceManager.playTestSound();
    Thread::sleep(5000);
}

//==============================================================================
int main (int argc, char* argv[])
{
	ScopedJuceInitialiser_GUI plattform;
	playTestSound();
    return 0;
}

It’s still a little bit weird to call a GUI function to initialize a framework to use without UI :wink:

One last question for today. How can I convince Introjucer to create a DLL/Sharelib/Staticlib instead of an executable? Since it overwrites the project files I cannot change it
in visual studio/Xcode/Makefile.


#9

But you DO want a GUI - or at least, you want all the GUI event loop handling code, even if you don’t open a window.

The introjucer can generate dlls and bundles for plugins, etc, but I’ve never added a mode to let you do custom ones. You could try modifying the introjucer yourself to do it if that’s a good solution for you.


#10

Hello slajar,
I tried your example, and somehow could not generate the exe file on Windows. How is your project/solution setup? Is there any specific compiler/linker flag required? I am using Visual Studio 2008, there is a C++ console solution/project, also adds the JUCE dll project to the solution. The console project links to the JUCE dll that is provided in “windows dll” directory from juce 2.0. Got following linker errors:
[list]Error 1 error LNK2001: unresolved external symbol “public: static class juce::String const juce::String::empty” (?empty@String@juce@@2V12@B) Main.obj MyTest
Error 2 error LNK2001: unresolved external symbol “private: static class juce::JUCEApplicationBase * juce::JUCEApplicationBase::appInstance” (?appInstance@JUCEApplicationBase@juce@@0PAV12@A) Main.obj MyTest
Error 3 error LNK2001: unresolved external symbol “public: static class juce::JUCEApplicationBase * (__cdecl* juce::JUCEApplicationBase::createInstance)(void)” (?createInstance@JUCEApplicationBase@juce@@2P6APAV12@XZA) Main.obj MyTest
Error 4 error LNK2001: unresolved external symbol “public: static class juce::ModalComponentManager * juce::ModalComponentManager::_singletonInstance” (?_singletonInstance@ModalComponentManager@juce@@2PAV12@A) Main.obj MyTest
Error 5 error LNK2001: unresolved external symbol “public: static class juce::AudioPluginFormatManager * juce::AudioPluginFormatManager::_singletonInstance” (?_singletonInstance@AudioPluginFormatManager@juce@@2PAV12@A) Main.obj MyTest
[/list]

Or a more general question: is there an example project of using “windows dll” for JUCE?

Thanks,
AY

[quote=“slajar”]Ok, changed:

void playTestSound()
{
	AudioDeviceManager deviceManager;
    deviceManager.initialise(255,255,NULL, true);
    deviceManager.playTestSound();
    Thread::sleep(5000);
}

//==============================================================================
int main (int argc, char* argv[])
{
	ScopedJuceInitialiser_GUI plattform;
	playTestSound();
    return 0;
}

It’s still a little bit weird to call a GUI function to initialize a framework to use without UI :wink:

One last question for today. How can I convince Introjucer to create a DLL/Sharelib/Staticlib instead of an executable? Since it overwrites the project files I cannot change it
in visual studio/Xcode/Makefile.[/quote]


#11

Hi guys,

let me know please is it possible to use JUCE audio on Android and/or IOS without any (UI) other component? On win32 ScopedJuceInitialiser_GUI works well ;)

Thx


#12

Well, as long as you avoid any event-based classes it should be fine.

Android is a bit unusual though, because unlike the other platforms there's all the nastiness involved in connecting it up with JNI, so I can't 100% guarantee everything will work without the special juce java wrappers. Building DLLs for use in other android apps isn't something I've ever tried.


#13

Thank you for your quick answer. Actually I'd like to record and playback a sound, nothing more special. I hope is it possible without any UI component?!


#14

Absoutely - the basic audio classes don't need any UI stuff.