gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
Brief intro to GTK+ IOStream.


This software is for the following :

  • the implementation of audio clients for playing/recording and the processing of sound, good for digital signal processing (DSP) as well
  • building GUIs
  • the interfaceing of C++ to using Eigen3 matrices.
  • the implementation of feeforward neural networks
  • Object Request Broking (ORB) classes over networks

The audio system interfaces to the both ALSA and a Jack audio server. The ALSA code allows you to produce ALSA plugins or directly output/input and do full duplex processing. This jackd server allows real time audio processing when you have a patched kernel or if your operating system is capable of schedueling in some real time manner.

Apart from jackd and ALSA, this code also interfaces to SoX (the swiss army knife of audio processing). This allows you to read and write audio files of almost any type. Further, various tools for DSP are supplied, such as audio masking (psychoacoustic type audio masking as used in mp3), also WSOLA which allows you to speed up audio and slow it down, without changing its pitch. The IIO code in this project is also used in jackd as a driver for interfacing IIO capable chips.

The GUI related classes are intended to be light weight GTK wrappers for use in C++. As far as the GUI software is concerned, it is all contanined in the class header files, this means that you can simply include the headers and code away without having to worry about compiling any source code files other then your own. I have put a set of tutorials to get the basic idea of GUI programming across to you up here it is targeting newbies.

Octave is interfaced using Eigen3 and/or openCV matrices which are hardware optimised matrix computation library, OpenCV also being a image processing library.

The feedforward neural networks use Eigen3 for their implementation, which ensures the efficient evaluation using hardware vector processing and parrallel computation, where possible.

Various other parts of this distribution include

  • AudioMasker, an audio masking model which is similar to the psychoacoustical model used in mp3 compression.
  • WSOLA, time scale modification for multichannel audio, this allows you to speed up and slow down audio without chaning its pitch.
  • WSOLA and WSOLAJackGTK are also provided as binary executables which can be run from the command line with or without a GUI, respectively.
  • IIO processing which is embedded as a driver in jackd2.

The ORB (object request brokering) classes ORBOriginator and ORBReplicator utilise Zeroc Ice to implement the actual ORB application layer. When the term ORB is used, it implies the following :

  • The mirroring of classes from one side of the network to the other.
  • The execution of class methods on the origintaing side of the network from the replicating side of the network.
  • The ability to call methods synchronously OR asynchronously (threaded execution).

This distribution also ships with many examples of how to use the various classes contained within.

Support this project by purchasing our hardware.

   _____                              _      __                            __ _
  / ____|                            | |    / _|                          / _| |
 | (___  _   _ _ __  _ __   ___  _ __| |_  | |_ _ __ ___  ___   ___  ___ | |_| |___      ____ _ _ __ ___
  \___ \| | | | '_ \| '_ \ / _ \| '__| __| |  _| '__/ _ \/ _ \ / __|/ _ \|  _| __\ \ /\ / / _` | '__/ _ \
  ____) | |_| | |_) | |_) | (_) | |  | |_  | | | | |  __/  __/ \__ \ (_) | | | |_ \ V  V / (_| | | |  __/
 |_____/ \__,_| .__/| .__/ \___/|_|   \__| |_| |_|  \___|\___| |___/\___/|_|  \__| \_/\_/ \__,_|_|  \___|
              | |   | |
              |_|   |_|

GUI detail

The general paradigm is that you can very easily construct GTK object and in some cases use the C++ IOStream paradigm to build graphical user interfaces (GUIs).

For example, I will create labels in a Vertical box like so :

VBox vbox; // create a VBox
Labels labels; // Create a labels structure
labels<<"First Label"<<"Second Label"; // Load some labels
vbox<<labels; // Put the labels into the VBox; // show the VBox

Similar things can be done with buttons (label buttons, toggle buttons, XPM and transparent XPM buttons are also supported)

This example runs gtk as normal and loads an HBox into the GTK top window. The HBox is loaded with a quit label button.

// The quit button callback
static void quit(void *wid, gpointer data){
int main(int argc, char *argv[]){
gtk_init( &argc, &argv ); // start GTK
Window topWindow; // create the top window
HBox hbox; // create a horizontal box for holding the buttons
Buttons buttons; // create a buttons holder
buttons<<BUTTONLABELSTRUCT("Quit", quit, NULL); // load a label button - other button types are also available
hbox<< buttons; // add the button to the HBox; // show the HBox
topWindow<< hBox; // load the HBox into the top window
gtk_main(); // run GTK

The Labels and Buttons are actually based on the LinkList datatype - which is a templated lightweight doubly linked list.

If you want to get compact, you can write like so :

topWindow << (hbox << buttons<<BUTTONLABELSTRUCT("Quit", quit, NULL)).show();

If you want access to the GTK+ widgets, it is easy

GtkWidget* widget=hbox.getWidget(); // Standard GtkWidgets are readily accessible for all classes.

Plotting example

Plotting is easy and is similar to (Matlab) style plotting commands.

For example the following code :

#define cnt 4
float x[cnt]={0.0, 1., 2., 3.};
float y1[cnt]={0.0, 1., 2., 3.};
float y2[cnt]={1.0, 2., 3., 4.};
Plot figure; // create and show a Figure
figure.plot(x,y1,cnt); // Plot the first line with default colours
figure.hold(true); // hold the current curve and add another
figure.plot(x,y2,cnt, "r1"); // plot this one as a red line
// Changing the style of the plot
figure.limits(-1.0,4.0,-1.,5.0); // open the window out to be able to see all
figure.grid(true); // show a grid
figure.title("Figure 1 title"); // add the title, x label and y label
figure.xLabel("X axis label");
figure.yLabel("Y axis label");

Produces this :


Octave detail

Octave is simplistically instantiated and run like so :

Octave octave(args);
output = octave.runM("yourMFile.m", input);

A more detailed description can be found in the Octave class detailed description.

To utilise the Octave code, the Octave.C file must be linked with your code. The reason for separating the Octave source from the header is that octave uses, where as you may want to use in your own code. By separating the Octave code out from the Octave header file, you are able to link against the Octave header and utilise octave without having to link against its shared libraries directly.

Object Request Broking detail

ORB is desigend to be trivial.

On the originating side of the network, the following is executed
ORBOriginator origin(argc, argv, string("BasePipe")); // This is the original locaiton where the classes are created
// Create a class and add it to the ORB application layer
ORBTestClass *otc = new ORBTestClass; // this is the class to be added to the ORB application layer
origin.addClass(otc, otc->name); // add it to the originator

On the replication side of the network, the following is executed

// create the replicator which will connect to loopback
ORBTestReplicator replicator(argc, argv, string("BasePipe"), string("")); // This is the replicating locaiton where the classes are proxies
// If you want the same class with the same state as it is on the originator, you can like so :
ORBTestClass *otc = replicator.getObjectPointer<ORBTestClass>(ORBTestClass::name);
cout<<"variable = "<<otc->variable<<endl;
// By using a proxy, you can execute the originator class's methods
ORBTestICEPrx oRBTestICEPrx = replicator.getObjectProxy<ORBTestICEPrx>(ORBTestClass::name);
cout<<"input = "<<oRBTestICEPrx->method(1)<<endl;

A more detailed example is in the ORBTest.C class. There is also other documentation in the ORBOriginator and ORBReplicator class documentation.

To utilise the ORB (ORBOriginator and ORBReplicator) code, you must specify your network protocol in a .ice file. This .ice file specifies in object oriented code what objects you will be sending over the network (simple types are int, float, vector<TYPE> and many others). The slice2cpp application is run at compile time to machine generate .C code from the .ice files. These then are linked into your application.

Neural Network computation

Neural network computation is also designed to be efficient and quick to use. For more detail and example code reference here NeuralNetwork.

Audio playback/recording and digital signal processing (DSP)

Jack is utilised for audio playback. Currently Jack runs on OSX, IOS, Linux, Microsoft (and hopefully soon android!). See JackClient for more detail.

Installation and Compilation

If you only want to use the GTK GUI building classes, then there is no need to build and you can simply point your preprocessor or IDE to the correct header file location.

If you want to use the ORBing system, Octave, Sox and some future additions, then you should install.

Requirements : You will need the Octave system, libsox, and ZeroC Ice. On a Debian derived system (e.g. Ubuntu) you can use the following :

sudo apt-get install zeroc-ice34 libzeroc-ice34-dev ice34-translators
sudo apt-get install liboctave-dev libsox-dev
sudo apt-get install doxygen graphviz

To build the code, first run ./tools/ then configure, make and make install. To clean the code, either make clean OR run ./tools/ to clean everything !


Copyright 2001 to 2013 Matt Flax


This software is governed by the GPL license.

Interesting multimedia and hardware from this author.





gtkIOStream: Brief intro to GTK+ IOStream.
GTK+ IOStream  Beta