Showing posts with label multiplatform. Show all posts
Showing posts with label multiplatform. Show all posts

Monday, April 6, 2009

VST plugins with Qt user interface

I recently did an spike on what we need to make VST plugins first class CLAM citizens. CLAM allows to visually build JACK and PortAudio based applications with Qt interfaces as well as GUI-less VST and LADSPA plugins. The more flashy feature of VST is user interfaces that are mostly built using VSTGUI. We are using Qt as interface for JACK and Portaudio based apps because we are using the nice features of Qt toolkit to dynamically bind the UI elements and the underlaying processing. Moreover, Qt styling features enables shinning designer-made interfaces. Why not being able to reuse the same interface for VST and JACK? That has been a long standing TODO in CLAM so now is time to address it.

In summary, we fully solved croscompiling vst's from linux and we even started using qt interfaces as vst gui. In that last point, there still is a lot of work to do, but the basic question on whether you can use qt to edit a vst plugin is now out of any doubt.

To make the spike simpler, and in order not to collide with other CLAM developers, currently working on it, i just left apart all the CLAM wrapping part, just addressing vst crosscompiling and Qt with the sdk examples.

Cross compilation was pretty easy. This time I found lot more documentation on mingw and even scons. Just by adding the crossmingw scons tool we are already using for the apps and i managed to get Linux cross-compiled plugins running on Wine.

Adding a regular vstgui user interface is just a matter of compiling vstgui sources along with the example editor that comes in the sdk.

Once there, we should address Qt. VSTGUI is just a full graphical toolkit implementing the 'editor interface' plus a toolkit with some provided widgets and, i guess, a way of automating the binding of controls to processing. So what we need for qt is to implement the AEffEditor interface using the qt toolkit instead. The first problem is about the graphical loop. You have to create a QApplication and calling qApp::processEvents() on the editor's idle method so that qt widgets get responsive. The problem then is that, if you don't provide a QWidget as parent to your interface, it becomes a top level window ignoring the host provided window that still appears as an empty one.

VST host provides such window as a native Windows handle. How do you create a widget on an existing window handle? Months ago trolls redirected me to a commercial solution. Not such a 'solution' for us, a FLOSS project. So i was digging in windows qt source code for a hack when i found the answer just at the public and multiplatform QWidget api. QWidget::create works like a charm. The following simple class is a native window wrapper you can use as a regular QWidget.


class QVstWindow : public QWidget
{
Q_OBJECT
public:
QVstWindow(WId handle) {create(handle);}
QVstWindow::~QVstWindow() {}
};

Still there are some issues: focus handling, reopening, drag&drop... But the basic mouse clicking and resizing works

Once i got that, loading a designer ui file was very easy.

As I said there are still many caveats to solve. A matter of playing with it and refining things. Here is a list of TODO's:

  • Communicate controls from and to the interface
  • Handle focus and other events properly
  • Build a CLAM network wrapper which reensembles more the one for LADSPA
  • Wiki documentation on how to build your own plugin
  • One button plugin generator like the one we have for LADSPA ;-)

I feel that there is more people around other projects interested in using Qt for VST plugins so this is also a call for collaborative research on pending issues, at least the generic ones. Contact us on the CLAM development list or for a broader audience in the Linux Audio Developers list.

Monday, October 29, 2007

GSoC 2007 mentor submit

A couple of weeks ago, Pau and me were at San Francisco for the Google Summer of Code Mentor Submit. At the submit we joined some interesting sessions on how to improve the next GSoC, but also we met a lot of other hackers of free software projects all around the world: Mixxx, Inkscape, KDE, Amarok, Pidgin, Scumvm, Haiku, Crystal Space, Ogre, Moin Moin, Drupal, VideoLan, XMMS2, audacious... Well, as you can see in this picture we were pretty much people:

Family photo of GSoC 2007 mentors

I knew about most of all other projects, but, sadly, nearly no one knew about CLAM. :-( The good news is that most of them get pretty interested as they saw CLAM capabilities on audio processing and application prototyping. We need independently packaged end user tools!!

I also was glad to confirm the collaboration between projects that one could figure out being competitors:

  • People working on desktops (KDE, Gnome...) are in fact in a very close collaboration.
  • Wiki implementations (Moin Moin, Wikimedia...) meet there
  • Also several 3D engines (Crystal Space, Ogre...) met there
  • Comunity portals such as Drupal, Joomla, Plone...

They all share common challenges and solutions and they used the submit to join efforts.

Related to common issues and efforts, we took a very productive meeting on multiplatform development where some multiplatform projects, including us, shared experiences. We explained how we faced such problem at CLAM: the use of portable 3rd party libraries, crosscompiling from Linux to other platforms, and the use of testfarm to rapidly detect multiplatform issues. Some projects, such VideoLan had automated third party compilation scripts a step we have not automated at all. We realized that a lot of people was also solving such problems and we compromised to share experiences and results. For example, we talked about having a single repository of precompiled binaries of third party libraries. We also realized about our not-so-open-source mind we most of us realized that we were not reporting back patches we did to external libraries. We compromised to send them to upstream or making them available in a common place for the other project using them.

Monday, July 2, 2007

Deprecating Windows as development platform

In this entry i will explain how we got ride of Windows as development platform for the CLAM project still providing Windows binaries by using the tandem mingw32 (for Linux) and Wine. We dealt with crosscompilation of most of CLAM dependencies such as Portaudio, Asio, libsndfile, liboggvorbis, pthreads, fftw3, libmad, id3lib, XercesC, libxml++, NSIS and Py2Exe.




After a very dissapointing and fustrating effort from Pau and me of trying to have a reproducible build environment for CLAM based on Visual Express 2005, we decided that the whole thing was foolish and decided give mingw a try.

I am proud of not having a Windows box available at home ;-) but that doesn't mean i cannot contribute to that part of the development so the last days i did an spike on having mingw crosscompiling CLAM from Linux! We succeeded to compile it all, the dependencies, CLAM and the applications. Because some dll conflicts when installing that could not go into the 1.1.0 version of CLAM. After a gutsy update we could compile it all,
so expect rewamped windows binaries for the next release... and maybe development binaries. You can already give a try to the latest svn snapshots.


The key point has been using Wine to install with their own windows installers some libraries and tools such as Qt4, GTK (for pkg-config, libxml++ and dependencies), and NSIS to build windows installers from Linux!

Wine and mingw are a great tandem to compile and test the binaries. Also SConstruct has been a nice tool to hack a quick build environment for third party libraries when the one provided (normally based on autotools) was too messy to get on with.

We kept a reproducible log of the mingw crosscompilation at the clam wiki. This includes how to get all the dependencies working, which may be usefull for you own project. CLAM dependencies we addressed were: Portaudio, Asio, libsndfile, liboggvorbis, pthreads, fftw3, libmad, id3lib, XercesC, libxml++, NSIS and Py2Exe.

Friday, January 26, 2007

Adding dynamic libraries to a macosx application bundle

CLAM team is now geared toward having again MacOSX binary distribution. We are learning how things in Mac works and it is being a long process. At last it seems that we are getting enough insight. Until now, our Mac packages for CLAM applications depended on the installation of another bundle with clam and third party libraries. Following the advice of Volker Schumacher this would be more handy by having, as we have in windows, all third party libraries within the handle. So we used otool and install_name_tool as the mac developer documentation says. But CLAM has a lot of third party dependencies which are recursive and this was a very hard problem to do it by hand, so Pau and me pair programmed a handy python script which eases the process a lot.

What it does is firstly using otool to retrieve all the dependencies recursively and removes system ones. Then it copies all them to the bundle, changes their id and then changes all cross references among libraries and applications accordantly.

The script is available on the CLAM svn repository. A SCons tool is also work in progress. I will wrote more on int when finished.