[Csnd] Csound with C++ -embed your orchestra
| Date | 2011-06-23 15:26 |
| From | Michael Gogins |
| Subject | [Csnd] Csound with C++ -embed your orchestra |
| Attachments | None None |
| For general information, I have determined that versions of the GNU C++ compiler (g++) from 4.5.2 onwards implement a new form of string literal that can contain embedded line breaks. This includes MinGW 4.5.2. This is of obvious usefulness for those who use Csound as a synthesizer for algorithmic compositions written in C++. You can now embed your Csound orchestra in your C++ source code, simply by pasting your orchestra into your C++ source code and assigning it to a string variable.
Such string literals are declared and defined like this in C++ code: const char *literal = u8R"XXX(I'm a "raw UTF-8" string. And I have an embedded line break.)XXX";
The R symbol indicates the new "raw" string literal form. The u8 prefix means encode the literal as UTF-8 (which should work fine for Csound). The "XXX and XXX" symbols are used to demarcate the beginning and end of the multi-line string literal.
The following also should work (the same, except using plain ASCII assigned to a C++ string object): std::string literal = R"XXX(I'm a "raw ASCII" string.
And I have an embedded line break.)XXX"; To use this facility with g++, you must pass to the compiler the command-line option -std=c++0x, and you must invoke the g++ command not the gcc command.
I will be experimenting with using C++ as a composing language. I know that it is possible to get around problems with libraries and build tools by #including all required sources and using a simple build script. I will post examples.
The advantages of composing in C++ would be the more or less as fast as possible execution speed of the code and the ability to use a vast array of libraries, not least including the standard C++ collections and algorithms.
Regards, Mike
-- Michael Gogins Irreducible Productions http://www.michael-gogins.com Michael dot Gogins at gmail dot com |
| Date | 2011-06-23 15:57 |
| From | Adam Puckett |
| Subject | Re: [Csnd] Csound with C++ -embed your orchestra |
Thanks for this update, Mike! On 6/23/11, Michael Gogins |
| Date | 2011-06-29 20:08 |
| From | Brian Wong |
| Subject | RE: [Csnd] Csound with C++ -embed your orchestra |
|
This is very interesting Mike! I look forward to seeing your future experiments in this area. BW > Date: Thu, 23 Jun 2011 09:57:40 -0500 > From: adotsdothmusic@gmail.com > To: csound@lists.bath.ac.uk > Subject: Re: [Csnd] Csound with C++ -embed your orchestra > > Thanks for this update, Mike! > > On 6/23/11, Michael Gogins <michael.gogins@gmail.com> wrote: > > For general information, I have determined that versions of the GNU C++ > > compiler (g++) from 4.5.2 onwards implement a new form of string literal > > that can contain embedded line breaks. This includes MinGW 4.5.2. > > > > This is of obvious usefulness for those who use Csound as a synthesizer for > > algorithmic compositions written in C++. You can now embed your Csound > > orchestra in your C++ source code, simply by pasting your orchestra into > > your C++ source code and assigning it to a string variable. > > > > Such string literals are declared and defined like this in C++ code: > > > > const char *literal = u8R"XXX(I'm a "raw UTF-8" string. > > And I have an embedded line break.)XXX"; > > > > The R symbol indicates the new "raw" string literal form. The u8 prefix > > means encode the literal as UTF-8 (which should work fine for Csound). The > > "XXX and XXX" symbols are used to demarcate the beginning and end of the > > multi-line string literal. > > > > The following also should work (the same, except using plain ASCII assigned > > to a C++ string object): > > > > std::string literal = R"XXX(I'm a "raw ASCII" string. > > And I have an embedded line break.)XXX"; > > > > To use this facility with g++, you must pass to the compiler the > > command-line option -std=c++0x, and you must invoke the g++ command not the > > gcc command. > > > > I will be experimenting with using C++ as a composing language. I know that > > it is possible to get around problems with libraries and build tools by > > #including all required sources and using a simple build script. I will post > > examples. > > > > The advantages of composing in C++ would be the more or less as fast as > > possible execution speed of the code and the ability to use a vast array of > > libraries, not least including the standard C++ collections and algorithms. > > > > Regards, > > Mike > > > > -- > > Michael Gogins > > Irreducible Productions > > http://www.michael-gogins.com > > Michael dot Gogins at gmail dot com > > > > Send bugs reports to the Sourceforge bug tracker > > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > > Discussions of bugs and features can be posted here > > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe > > csound" > > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > |