On 17 Jan 2010, at 04:59, torbenh wrote:
On Fri, Jan 15, 2010 at 10:49:21AM +0100, Stéphane
Letz wrote:
Le 15 janv. 2010 à 10:03, torbenh a écrit :
hi...
i am working on a c++0x DSP library.
variadic templates prove to be a nice way to handle
the massive function inlining required to build efficient samplebased
processing graphs.
the idioms i am currently using for the containers require gcc-4.5
though, so this is still a bit of a show-stopper :)
its still in a pretty early state. but you can already see where its
heading.
if somebody is interested:
http://hochstrom.endofinternet.org/trac/ttsoot/wiki
--
torben Hohn
How would this approach compare to the FAUST approach?
its more or less equivalent to faust scalar code.
the containers provide similar composition ops to the faust ones.
torben, Stéphane, LAD:
This exchange got me wondering... how "Faust-like" could a language, embedded
directly in C++ using template metaprograming techniques, be made to be?
Could it be made to accept e.g.:
(expr0:(expr1,expr2,expr3):expr4)
In place of e.g.:
Serial(Serial(expr0,Parallel(Parallel(expr1,expr2),expr3),expr4))?
Wondering turned to coding and I ended up with Xazz:
/*===========
begin sine.cpp
===========*/
#include <unistd.h>
#include "xazz/base.hpp"
#include "xazz/math.hpp"
#include "xazz/jack.hpp"
int main( void )
{
XAZZ_IMPORT_BASE
XAZZ_IMPORT_MATH
#define _ XAZZ_CONST
const auto samplerate = _(44100.0f);
const auto osc440 = _(440.0f)
(((twopi,samplerate) > div) > mul)
((add <= ( pi>lt, wire, (wire, twopi) > sub ) > select) & wire )
sin_;
#undef _
xazz::Jack<decltype(osc440)> MyJack(osc440, "osc440");
while( true ) { sleep(10); }
return 0;
}
/*===========
end sine.cpp
===========*/
That's a Jack app that outputs a 440Hz sine wave.
Notes:
1. C++ obviously doesn't have the same operators as Faust so Xazz uses:
">" serial composition (Faust's ":")
"," parallel composition (Faust's ",")
"<=" split composition (Faust's "<:")
">=" join composition (Faust's ":>" )
"&" recursive composition (Faust's "~")
"wire" identity (Faust's "_")
"cut" cut (Faust's "!")
2. It still needs c++0x but not so close to the bleeding edge. g++ 4.4 required.
3. It looks like we're composing the Xazz program at runtime (with consequent loss of
efficiency) but the "meat" of osc440 is what type it is, not what data it
contains. The compiler works that out at compile time and -- thanks to c++0x auto -- we
never have to write it down ourselves.
4. This is a V0.0 "proof of concept" release. Its LGPL.
5. Ummm.... thats it. Headers and a couple more examples here:
http://www.sjenkins.pwp.blueyonder.co.uk/xazz/xazz_0_0.tar.gz
Simon Jenkins
Bristol, UK