Flute synthesis with Faust

A while ago I purchased an Akai EWI 4000s wind controller and as a Ubuntu user I tried to find suitable synthesizers to be used with my controller, since the built in sounds are fairly synthetic sounding.

After having searched for a while I decided that I could write my own. Java is my strongest programming language, but Java didn’t feel like a good tool to write a synthesizer, because of my fear that garbage collection cycles would cause lots of clicks and glitches in the audio output.

Now I delved a bit more into synth programming. I read some books on C and C++ programming and picked the LV2 audio plugin standard as the glue library between my DSP code and a synth host. LV2 is the successor to the LADSPA standard, and as we are talking about Linux standards here, it is not the only one, and seems to be competing at least with VST for Linux and DSSI.

The C API for LV2 is fairly understandable, but I picked the object oriented way, because I found the excellent LV2 C++ tools wrapper library. LV2 programming for the complete idiot is a very good tutorial for this library. Also the study of the lv2-mdaEPiano sources was helpful.

After I had mastered enough C++ and had picked the right libraries I was ready to get started. I was already before familiar with Physical modeling synthesis, and picked it as the synthesis paradigm. To be more exact, Waveguide synthesis.

I picked the STK library as another dependency, to get the proper building blocks for waveguide synthesis and some example models. While the STK source code is quite nice to read, the library is a little bit verbose and after some time I got frustrated and decided to replace the STK library with something more agile.

I searched around and found the stk-faust project, a port of the STK instruments to the Faust programming language. Faust is a functional programming realtime audio signal processing. I read some tutorials on Faust and decided that the compact syntax, the block diagram auto-generation and benchmarks were convincing enough to try it out.

After that I studied the Faust based STK instrument ports and tried to integrate the flute model into LV2 context. This proved to be quite easy, all I had to was connecting the audio buffers and sync the control parameters. But I wanted to try a little bit more expressive model of the Flute. I picked an improved Waveguide model of a Flute and began to port it into Faust.

This took some while as modeling feedback loops and crossing connections in Faust is well supported, but syntactically weird. Nevertheless I got it finished after some time and managed to play some Flute like sounds with it.

Here is the top level diagram for it :

The sources are accessible from GitHub

The model has several shortcomings though. I have not yet been able to model the involved lowpass filters properly, toneholes are not included in the model which makes pitch changes sound unnatural and the excitation is pure white noise.

Concerning using Faust for your DSP projects, I believe that it is a very good language for structurally unchanging models. If there lots of dynamic components in your model that can be added, removed and moved around than Faust is probably not the right tool. If your model is fairly static and C++ works for you as an integration language, then give it a try.

I was very convinced by the Faust syntax, block diagram generation, UI building approach and easy integration into various contexts.