[Csnd-dev] setting macros through API...
| Date | 2015-11-09 12:39 |
| From | Rory Walsh |
| Subject | [Csnd-dev] setting macros through API... |
Bump..
Subject: setting macros through API? From: Rory Walsh <[log in to unmask]> Reply-To:Csound-developers <[log in to unmask]> Date:Fri, 23 Oct 2015 21:35:40 +0100 Content-Type:multipart/alternative Parts/Attachments: I would like to pass some string macros to Csound on startup but it won't work right when I'm sending strings. I would like to send messages like colour("red"), size(100, 100), text("Hello") I can send the strings on channels and retrieve them. I can also use strset but this also invovle retrieving the value. I would love to be able to do this: -odac --omacro:ATTRIBS="colour(\"red\"), size(100, 100), text(\"Hello\")" and then call it directly as prints $ATTRIBS Any ideas? I see the S_MACRO Struct. Any way of popping some strings into one of those? |
| Date | 2015-11-09 13:27 |
| From | jpff |
| Subject | Re: [Csnd-dev] setting macros through API... |
What error do you get? I have an Unmatched " from the shell. Are yiu
using bash?
On Mon, 9 Nov 2015, Rory Walsh wrote:
> Bump..
>
> Subject: setting macros through API?
> From: Rory Walsh <[log in to unmask]> Reply-To:Csound-developers <[log in to
> unmask]> Date:Fri, 23 Oct 2015 21:35:40 +0100
> Content-Type:multipart/alternative Parts/Attachments:
>
> I would like to pass some string macros to Csound on startup but it won't work
> right when I'm sending strings. I would like to send messages like
> colour("red"), size(100, 100), text("Hello")
>
> I can send the strings on channels and retrieve them. I can also use strset
> but this also invovle retrieving the value. I would love to be able to do
> this:
>
> -odac --omacro:ATTRIBS="colour(\"red\"), size(100, 100), text(\"Hello\")"
>
> and then call it directly as
>
> prints $ATTRIBS
>
> Any ideas? I see the S_MACRO Struct. Any way of popping some strings into one
> of those?
> |
| Date | 2015-11-09 14:14 |
| From | jpff |
| Subject | Re: [Csnd-dev] setting macros through API... |
This works in tcsh -- you might tru bash |
| Date | 2015-11-09 15:24 |
| From | Rory Walsh |
| Subject | Re: [Csnd-dev] setting macros through API... |
I was trying to do using the csoundSetOption() method: After Csound compiles I get an error:csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\\),text\\(\"Hello\"\\)\""); error: syntax error, unexpected T_IDENT, expecting NEWLINE or ',' (token "red") from file /Users/walshr/sourcecode/cabbageaudio/test.csd (1) line 18: >>>prints "colour("red <<< Parsing failed due to invalid input! ?? On 9 November 2015 at 14:14, jpff <jpff@codemist.co.uk> wrote: This works in tcsh -- you might tru bash |
| Date | 2015-11-09 15:26 |
| From | Rory Walsh |
| Subject | Re: [Csnd-dev] setting macros through API... |
Perhaps it's just a case of getting the right escape sequences? I've tried quite a few different variants, but all lead to that same error from Csound. On 9 November 2015 at 15:24, Rory Walsh <rorywalsh@ear.ie> wrote:
|
| Date | 2015-11-09 15:34 |
| From | jpff |
| Subject | Re: [Csnd-dev] setting macros through API... |
Havung an even number of \ characters is rare and leads to a real \. You will notetat my example (which byw alsp works in bash) has three \ before " mainly. My recommendation is to get the \ right! |
| Date | 2015-11-09 15:36 |
| From | jpff |
| Subject | Re: [Csnd-dev] setting macros through API... |
ie I ould try csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\\\"red\\\"),size\(100,100\),text\(\\\"Hello\\\"\)\\\""); assuming the mail did not messup On Mon, 9 Nov 2015, Rory Walsh wrote: > Perhaps it's just a case of getting the right escape sequences? I've tried > quite a few different variants, but all lead to that same error from Csound. > > On 9 November 2015 at 15:24, Rory Walsh |
| Date | 2015-11-09 15:47 |
| From | Rory Walsh |
| Subject | Re: [Csnd-dev] setting macros through API... |
That gives me the following error? using callback interface unterminated string found on line 20 >>"colour(\"red\"),size(100,100),text(\"Hello\")\" #source 1d endin << error: syntax error, unexpected $end (token "") from file /Users/walshr/sourcecode/cabbageaudio/test.csd (1) line 21: >>> <<< Parsing failed due to invalid input! Stopping on parser failure cannot compile orchestra On 9 November 2015 at 15:36, jpff <jpff@codemist.co.uk> wrote: ie I ould try |
| Date | 2015-11-09 15:51 |
| From | Felipe Sateler |
| Subject | Re: [Csnd-dev] setting macros through API... |
I think that should be: csound->SetOption((char*)"--omacro:ATTRIBS=\"colour(\\\"red\\\"),size(100,100),text(\\\"Hello\\\")\""); or csound->SetOption((char*)"--omacro:ATTRIBS=colour(\"red\"),size(100,100),text(\"Hello\")"); I don't think the parenthesis should be escaped. Saludos On 9 November 2015 at 12:47, Rory Walsh |
| Date | 2015-11-09 16:13 |
| From | jpff |
| Subject | Re: [Csnd-dev] setting macros through API... |
error is at end last " needs one less level -- prob my attempt to convert shell to C++ On Mon, 9 Nov 2015, Rory Walsh wrote: > That gives me the following error? > > using callback interface > unterminated string found on line 20 > >>"colour(\"red\"),size(100,100),text(\"Hello\")\" > #source 1d > endin > > << > > error: syntax error, unexpected $end (token "") from file > /Users/walshr/sourcecode/cabbageaudio/test.csd (1) > line 21: > >>> <<< > Parsing failed due to invalid input! > Stopping on parser failure > cannot compile orchestra > > > On 9 November 2015 at 15:36, jpff |
| Date | 2015-11-09 17:58 |
| From | Rory Walsh |
| Subject | Re: [Csnd-dev] setting macros through API... |
Thanks guys. It's working now. It was the need for 3 backslashes that was catching me out! On 9 November 2015 at 16:13, jpff <jpff@codemist.co.uk> wrote: error is at end last " needs one less level -- prob my attempt to convert shell to C++ |