CX: Psychology Experiments in C++


I spent a number of years hoping that someone would create a psychology experiment software package that uses C++ as the user programming language. I wanted such a thing because C++ is an excellent programming language and is very well-suited to real-time tasks, such as psychology experiments, due to it's speed. Due to widespread use, C++ has high quality IDEs and compilers, extensive learning resources, and a great deal of code that you can use in your experiments. While searching, I found Tscope, but it is basically C, not C++, so it doesn't feature object-orientation or templating. After wishing and hoping, planning and dreaming that a nice C++ experiment system would come into my life for a while, I gave up and made one myself.

It's called the C++ Experiment System (shortened to CX). CX is based on openFrameworks, which is a cross-platform, open-source C++ platform that is used for a variety of multimedia applications. You can download a recent release of CX from its GitHub repository. CX has a detailed manual (or see the online version here) and several examples to help you get started. The manual includes installation instructions, documentation for functions, and other information. For more advanced users, or people with unusual requirements, you will be happy to know that CX is not a walled garden, like most experimental software is. It's open-source C++: you can do anything with it! You can fork CX, improve on it, and send me a request to incorporate your changes into CX. It's still beta software, so it has some rough edges, but I have been using it to run experiments for over a year.


Code sample

Here is a simple code sample that will compile and run. It will display the text "Hello, world!" in the middle of the screen.

#include "CX.h"

void runExperiment(void) {


    ofDrawBitmapString("Hello, world!", Disp.getCenter());



The "Hello, world!" example on GitHub contains explanatory comments for the functions used in this minimal example.