Skip to content
jsiegle edited this page Dec 15, 2012 · 17 revisions

Introduction to Juce

Juce (http://www.rawmaterialsoftware.com/juce.php) is a GPL-licensed library for writing C++ software. "Juce" stands for "Jules' Utility Class Extensions," as it was written by one person, Julian Storer. Capitalization of its name doesn't seem to matter—we've seen it written as "Juce," "juce," and "JUCE" in official documents.

At the start of development, we considered a number of open-source, cross-platform libraries, including Qt, GTK+, FLTK, wxWidgets, openFrameworks, GLUT, and Clutter. After experimenting with each, Juce emerged as the best of the bunch.

Advantages of Juce

  • Completely open-source, which allows us to tweak the library as needed
  • No licensing restrictions for non-commercial applications
  • Intuitive class structure based on components
  • Completely cross-platform so we can compile the same code for Linux, Windows, and Mac
  • Extremely lightweight, which allows us to include the source code in our GitHub repository. Compiling Juce in its entirety takes about 2 minutes, as opposed to 2 hours for Qt.
  • Great documentation
  • A very helpful forum
  • Built-in audio processor classes, which make it easy to set up processing pipelines for ephys data

Disadvantages of Juce

  • Only one available tutorial. However, the Juce package contains example applications that cover almost every aspect of the library.
  • It's not widely adopted, which means you can't purchase Juce books or find extensive online examples, as you can with Qt. However, we have found Juce's online documentation and forum to be more than adequate for learning and troubleshooting.

How to acquire Juce

Because the entire library is so compact (less than 13 MB), we've included it in the GUI repository in the JuceLibraryCode folder. Therefore, if you clone the repository, you automatically download a copy of Juce. If you want the application to run, you NEED to use this version of Juce, as some methods have been customized (see details below).

The library files contained in this repository are based on Juce version 1.53, the latest stable release. If you want to check out the original source, you can download a .zip file at SourceForge. In addition to the source code, this package contains example applications that are useful for gaining familiarity with Juce.

Juce 1.53 was last updated in June 2011 and since then, there have been many useful changes to the library. Some of these changes have been manually incorporated into the version of Juce in the GUI repository, but most have not. If you want to keep track of the latest updates, you can browse the source tree or clone the Juce git repository: git clone --depth 1 git://juce.git.sourceforge.net/gitroot/juce/juce

Juce dependencies

After a clean install of Ubuntu 10.10, it's necessary to download the following packages to get Juce up and running:

  • freeglut3-dev
  • libfreetype6-dev
  • libxinerama-dev
  • libxcursor-dev
  • libasound2-dev

The easiest way to obtain these packages is to run the install_dependencies.sh script, found in the Builds/Linux/build folder. (e.g. sudo ./install_dependencies.sh). NOTE: this only works on Linux distros that use apt-get for package management. If you're using Red Hat or something similar, you're on your own.

On Mac, we didn't need to install additional packages, but we did need to tweak the settings to get things to compile in Xcode 4 (see the wiki page on OS X issues for more info).

For Windows dependencies, check out the Windows wiki page.

Audio processing in Juce

The Juce library was originally created to build audio processing applications, and thus it includes well-developed classes for manipulating audio data. As you'll see in the Juce forums, most of the people using Juce are building audio apps and plugins. Why does this matter for the GUI? As it turns out, the steps involved in acquiring, processing, and storing audio data are profoundly similar to those required for electrophysiological signals. Using Juce's built-in audio classes with very little modification has made it surprisingly easy to build a sophisticated processing pipeline for neural data without worrying about the nitty-gritty details of buffering, message passing, and threading. Therefore, many classes used in this application have "Audio" or "Midi" in their name. Neural data processors are derived from the Juce AudioProcessor class, continuous signals are stored in AudioSampleBuffers, and spike events are sent in MidiBuffers. At some point in the future, it may be prudent to build a custom backend for data handling, but for now, Juce's audio classes have made the development process much faster without any noticeable detriment to performance.

Changes to the Juce source code

As mentioned above, you should be aware than the Juce source files included in the GUI repository are not identical to those obtained directly from SourceForge. So far, we've made the following changes:

  • The graph-building operations in src/audio/processors/juce_AudioProcessorGraph.cpp were modified based on the issues raised in this discussion. After these changes were implemented, graph building went from taking a few seconds to being almost instantaneous.
  • MidiBuffer::addEvent in src/audio/midi/juce_MidiBuffer.cpp was modified to handle MIDI events of arbitrary length. This allows spikes and other event-based data to be passed between processors via the MIDI buffer.
  • Two methods were added to src/gui/components/windows/juce_ResizableWindow.cpp: ResizableWindow::setContentNonOwned and ResizableWindow::setContentOwned. These functions were copied from the latest version of Juce. They will allow data visualizers to appear in separate windows without getting deleted when the window is destroyed.
  • When loading custom fonts from memory on Linux machines, we would always get a Failed to create typeface: error. In an effort to solve this problem, several methods in src/native/linux/juce_linux_Fonts.cpp were replaced with their updated versions from the latest Juce repository. This didn't help, so instead the issue was solved by using a command-line font serializer, found in this discussion and available in an improved form in the Resources/Fonts/ folder. Nevertheless, the changes to the source code remain.
  • Three lines (1667, 1668, and 1672) were commented out in src/native/mac/juce_mac_NSViewComponentPeer.mm, because they were unable to be compiled in Xcode 4, and didn't seem to be essential for any of the GUI functionality.
  • Added "getEnvironmentVariable" from the December 15, 2012 version of JUCE in an attempt to fix a problem loading fonts on Ubuntu 12.12. This resulted in changes to juce_win32_SystemStats.cpp, juce_posix_SharedCode.h, and juce_linux_Fonts.cpp.

<< Back to TODO list | Continue to libFTDI >>

Clone this wiki locally