Apple GUI with Juce Audio


a friend of mine has already done the GUI, file-management etc. for an audio sequencer specifically designed for placing audio sources in 3d space and animating them. He has done this based on Apples Frameworks (Cocoa & co.). I’d like to (try to) write the missing piece, an “audio engine” for it, using Juce (It’s actually part of my semester thesis).
The connection between these two worlds is a class defined in a *.h and *.mm file, where Objective-C and C++ can be used side by side. In the constructor of this class, an object of type AmbisonicsAudioEngine - which is my “audio engine” - is initialized.
So far, everything is working. But as soon as I also wan’t to call a member function of this AmbisonicsAudioEngine object (meaning: as soon as Juce really gets involved), the GDB interrupts the application startup:

Loading program into debugger…
Program loaded.
[Switching to process 3310]
JUCE Assertion failure in /Users/sam/data/on_sam7/res/projects_dev/juce100311/juce/build/macosx/…/…/src/events/juce_MessageListener.cpp, line 37
Debugger() was called!
sharedlibrary apply-load-rules all

I think this happens because Juce is not initialised. But how to do this? And where to place it in the objective-c code? In a pure Juce Application, the macro START_JUCE_APPLICATION takes care of this - i think. But in this project, there is already a starting point…

Some more insights:

The “audio engine” is as simple as possible for now. It’s only capable of playing back one single audio file, which has to be chosen. Using it with a Juce GUI works fine, by the way.



#include "JuceLibraryCode/JuceHeader.h"

class AmbisonicsAudioEngine
	// constructor
	AmbisonicsAudioEngine ();
	// destructor
	~AmbisonicsAudioEngine ();	

	// This opens a dialogWindow to set up the audioDeviceManager
	void showAudioSettings();
	void start();
	void stop();
	// Temp
	// This opens a dialogWindow to choose the audio file
	bool chooseAudioFile();
	AudioDeviceManager audioDeviceManager;
	AudioSourcePlayer audioSourcePlayer;
	AudioTransportSource audioTransportSource;
	AudioFormatReaderSource* currentAudioFileSource;


and a snippet of AmbisonicsAudioEngine.cpp

void AmbisonicsAudioEngine::showAudioSettings()
	AudioDeviceSelectorComponent audioDeviceSelectorComponent (audioDeviceManager,
													0, 256,
													0, 256,
													true, true, true, false);
	audioDeviceSelectorComponent.setSize (500, 450);
	DialogWindow::showModalDialog (T("Audio Settings"),

It should be as simple as calling initialiseJuce_GUI() somewhere at startup - have a search for that function in the codebase for more info…

Thank you Jules, exactly what I was looking for!

(Kind of embarassing that I couldn’t find it in the sourcecode myself…)