CT-gui-ftor is a toolkit for Linux and Android. The 'C' stands for clicking the mouse, the 'T' for touching the screen. The 'ftor' indicates that use has been made of functors, without using the STL (no #include <functional> etc.).

Included is demo project CT-synth, which is a polyphonic synthesizer that can be played with an on-screen keyboard or with a real MIDI keyboard connected via USB. An Android tablet can be used if it has USB-host capability. The connection is done with an on-the-go (OTG) cable. PulseAudio (Linux) or OpenSLES (Android) is used for sound. No Jack interface for Linux is provided, mainly to get no conflicts if e.g. a browser is running.

Building for Linux

Go to CT-gui-ftor/linux and type 'make'. Apart from the graphics library a demo application test-ct will be created. This will show the available touch-friendly widgets and also the graphics primitives. In general, blue-colored areas are clickable or touchable. Several widgets are animated.

The path to a suitable TrueType font file is more or less hard-coded in ct-widgets.cpp, but any other TTF font library can be used instead.

For the synthesizer go to CT-projects/CT-synth/linux and again type 'make'. If all goes well, program 'ct-synth' is created. You can try it using the mouse. If you click the button 'flip keyboard', then the keyboard will be replaced by a short manual explaining what all those sliders are for. If you created a new patch, you can hit the 'P' key, then your patch will be printed to the terminal. You can copy/paste it to file patch.cpp, and recompile. If you run the program with option -h the available options are printed. With options -mx and -my the screen dimensions can be scaled.

If you have a MIDI keyboard available, it can be connected via USB. Press the red button to establish the connection. If the system recognizes the keyboard, the red button will turn to green and you can play. Any keyboard with a class-compliant MIDI interface should work. The control knobs for pitch bend and modulation should function as expected.

Building for Android

Go to CT-projects/CT-synth/android. In build.xml modify the path to your sdk directory. In jni/ maybe you must modify the architecture. Then type 'ndk-build'. Supposing that all Android tools and libraries have been installed, the C++ files will be compiled. Now connect your tablet to the computer via USB, and type 'ant debug install'. An app called 'CT Synth Ftor' will be installed. With command 'ANDROID_LOG_TAGS="TestNative:D *:E" adb logcat' you can get useful information when the app runs.

The connection with a MIDI keyboard is slightly different from Linux: if you plug it in, Android will display a list of all appropriate apps that are installed on your device. Choose 'CT Synth Ftor'. Touch the red button. It should turn to green, and not turn to red again. If the keyboard was plugged-in already before the app was started, then a different popup screen may appear, asking you for permission to access the USB device.

The app uses the so-called immersive mode. Thus, if you are missing the back-, home- and list icons, give a swipe gesture at the top of the screen, they will appear for a short time.

Notice that 'adb logcat' is not available when the USB connection is occupied by the MIDI keyboard. The adb tool can also be used via a wifi connection, however this is rather impractical. It is simpler to remove the connection to the MIDI keyboard and re-connect the computer. Previous adb messages are still present on the device.

Source code

The common code for Linux and Android is in CT-gui-ftor/common and CT-synth/common. Directives #ifdef _ANDROID_ and #ifdef _LINUX_ are used to isolate the differences between Android- and Linux-specific parts. The comments are sparse, and there is no manual. The whole project is meant for developers who know how to install and use tools, libraries, permissions, etc.

Regarding licenses:
My own code is free, the code that I borrowed from others is indicated as such.

Wouter Boeke
w dot boeke at upcmail dot nl