Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] did anyone see this?

Date2007-03-08 15:14
FromMichael Gogins
SubjectRe: [Cs-dev] did anyone see this?
I HAVE measured -- to some extent. I wrote a C++ synthesizer to emulate a simple Csound patch, and the C++ synthesizer was faster (not by much!). It was an FM patch with dynamic voice allocation, wavetable oscillators, writing float soundfiles.

Of course, I know, this is not really oranges vs. oranges, it's not really a fair test. What I did find, though, was that writing boilerplate, textbook-style C++ code using the standard C++ library templates and algorithms, and using C++ templates for matrices and vectors, produced really really fast code. For example, for linear algebra, boost uBlas measures faster than everything except commercial libraries and ATLAS (Fortran specifically tuned per processor).

This reinforces other experience -- over many years -- that writing simple, clear C++ code often produces small speedups because the algorithms become simpler and clearer. I think the same thing would happen if we made the CSOUND struct a C++ class. This is not a hasty opinion and it is based on a lot of real experience including some measurement. 

In doing this kind of code, one has to have a reasonable amount of C++ experience to preserve const correctness which allows passing objects by reference, and to avoid having the compiler produce lots of temporary objects and value copies behind one's back. But this is not hard to do once you understand the need.

In addition, Csound would become MUCH easier to maintain and extend -- of that I have no doubt. My C++ synthesizer contained a LOT less code than the Csound C code that does the same job.

If you want to look at it, it's online as the SilenceVST project on SourceForge.

Regards,
Mike

-----Original Message-----
>From: Victor Lazzarini 
>Sent: Mar 8, 2007 5:00 AM
>To: Michael Gogins , Developer discussions 
>Subject: Re: [Cs-dev] did anyone see this?
>
>I know that. This was meant as joke...
>
>I understand your point about C++. However, I am not sure about making
>it faster. As the unix fathers have said, bottlenecks can occur anywhere,
>you will only know if you measure. As far as I know no one has gone out to
>measure and assert that a C++ code would be faster.
>
>Victor
>
>At 14:42 07/03/2007, you wrote:
>>The 'curse' is not C++, but departing from the main branch. All versions 
>>of Csound whether they use C++ or not have faded in favor of the 
>>'canonical' version because that version has more developers -- it's that 
>>simple.
>
>Victor Lazzarini
>Music Technology Laboratory
>Music Department
>National University of Ireland, Maynooth 
>
>
>-------------------------------------------------------------------------
>Take Surveys. Earn Cash. Influence the Future of IT
>Join SourceForge.net's Techsay panel and you'll get the chance to share your
>opinions on IT & business topics through brief surveys-and earn cash
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>_______________________________________________
>Csound-devel mailing list
>Csound-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/csound-devel




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net