Skip to content
open-ephys edited this page Dec 6, 2012 · 7 revisions

The primary way to add functionality to the GUI is through custom processors. Processors are wired together inside the ProcessorGraph, which handles the application's data processing stream. Processors that generate data are known as Sources, those that modify data are known as Filters, and those that send data outside the ProcessorGraph are called Sinks. Ideally, each processor should have a simple, well-defined function, and should be compatible with any type of input (even if it just ignores it).

The creation of new processors is simplified by the fact that they are all derived from the GenericProcessor class, which is itself a subclass of the JUCE AudioProcessor. Processors only need to have a handful of methods defined in order to operate within the ProcessorGraph. Of course, it's likely that more complex processors will end up implementing a number of private methods. But this isn't necessary.

How to create a new processor

  1. Generate the .h and .cpp files through the Jucer. Rather than creating these files manually, it's better to generate them automatically through the Jucer. This ensures that the files will be properly added to the Linux makefile, Xcode project, and Visual Studio project, regardless of which operating system you're using. If you haven't already, you can compile the Jucer from the JuceLibraryCode/jucer/Builds folder. When you run the Jucer and load the open-ephys.jucer file, you'll see a list of folders and files along the left-hand side. Right-click on the icon for the Sources/Processors folder and choose "Add New CPP & Header File...". Enter the name of your processor (make it as descriptive as possible), and hit "Save." Then save your project by choosing File > Save Project from the Jucer menu.

  2. Add the boilerplate code. First, open up your newly created .h file alongside ExampleProcessor.h. Copy the license information at the top of the file above the #indef...#define directives. Then copy all the code between the preprocessor directives to your new file. No matter what OS you're currently on, make sure that #include <Windows.h> directive is there. And you'll always have to include the JuceHeader.h and GenericProcessor.h files for your code to compile. For the .cpp file, just copy everything over.

  3. Change the processor name where appropriate. In both the .h and .cpp file, find all the instances of "ExampleProcessor" and replace them with the name of your file. In the class constructor, change the "Example Processor" string into the name you want to be visible to users. It doesn't have to match the name of your file, although it's more convenient if they're similar.

  4. Specify the type of processor. If your processor is a filter, you don't have to do anything for this step. If it's a source or a sink, change the return value of the isSource() or isSink() method to true (but never both).

  5. Make your processor visible to the user. In the file ProcessorList.cpp, add the name of your processor as a subitem of the appropriate ProcessorListItem ("Sources," "Filters," or "Sinks"). The name must match the name of your processor as defined in the constructor.

  6. Allow the ProcessorGraph to recognize your processor. Open ProcessorGraph.cpp and make sure your processor's header is included. Then, in the method ProcessorGraph::createProcessorFromDescription, add an else if statement to generate your processor. Again, the name must match that defined in the constructor.

  7. Try to build the software. At this point, the GUI should compile, and you should be able to drag your new processor into the signal chain. If not, go back and check steps 1-6.

  8. Add functionality! This is the fun part. By updating your processor's "process" method, you'll determine how it manipulates incoming data, or introduces new data into the signal chain. Look at the code in existing processors for examples.

The future of processors

The steps above may seem complicated, but they take about 5 minutes if you know what you're doing. However, we're working on ways to make things even simpler, namely by allowing processors to be compiled separately from the main application. Once we get the plugin/host architecture up and running, you'll only have to modify your processor's .h and .cpp files to make everything work.

<< Back to Windows | Continue to Data format >>

Clone this wiki locally