Csound Csound-dev Csound-tekno Search About

[Csnd-dev] setting macros through API...

Date2015-11-09 12:39
FromRory 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?

Date2015-11-09 13:27
Fromjpff
SubjectRe: [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?
> 

Date2015-11-09 14:14
Fromjpff
SubjectRe: [Csnd-dev] setting macros through API...
This works in tcsh -- you might tru bash

Date2015-11-09 15:24
FromRory Walsh
SubjectRe: [Csnd-dev] setting macros through API...
I was trying to do using the csoundSetOption() method:

csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\\),text\\(\"Hello\"\\)\"");

After Csound compiles I get an error:

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!

line 18 reads

prints $ATTRIBS

??



On 9 November 2015 at 14:14, jpff <jpff@codemist.co.uk> wrote:
This works in tcsh -- you might tru bash

./csound --omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"Hello\\\"\)\" bugmac2.csd


Date2015-11-09 15:26
FromRory Walsh
SubjectRe: [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:
I was trying to do using the csoundSetOption() method:

csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\\),text\\(\"Hello\"\\)\"");

After Csound compiles I get an error:

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!

line 18 reads

prints $ATTRIBS

??



On 9 November 2015 at 14:14, jpff <jpff@codemist.co.uk> wrote:
This works in tcsh -- you might tru bash

./csound --omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"Hello\\\"\)\" bugmac2.csd



Date2015-11-09 15:34
Fromjpff
SubjectRe: [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!

Date2015-11-09 15:36
Fromjpff
SubjectRe: [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  wrote:
>       I was trying to do using the csoundSetOption() method:
> 
> csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\
>       \),text\\(\"Hello\"\\)\"");
> 
> After Csound compiles I get an error:
> 
> 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!
> 
> line 18 reads
> 
> prints $ATTRIBS
> 
> ??
> 
> 
> 
> On 9 November 2015 at 14:14, jpff  wrote:
>       This works in tcsh -- you might tru bash
>
>       ./csound--omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"Hello\\\"\
>       )\" bugmac2.csd
> 
> 
> 
> 
>

Date2015-11-09 15:47
FromRory Walsh
SubjectRe: [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
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 <rorywalsh@ear.ie> wrote:
      I was trying to do using the csoundSetOption() method:

csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\
      \),text\\(\"Hello\"\\)\"");

After Csound compiles I get an error:

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!

line 18 reads

prints $ATTRIBS

??



On 9 November 2015 at 14:14, jpff <jpff@codemist.co.uk> wrote:
      This works in tcsh -- you might tru bash

      ./csound--omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"Hello\\\"\
      )\" bugmac2.csd






Date2015-11-09 15:51
FromFelipe Sateler
SubjectRe: [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  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  wrote:
>>
>> 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  wrote:
>>>       I was trying to do using the csoundSetOption() method:
>>>
>>>
>>> csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\
>>>       \),text\\(\"Hello\"\\)\"");
>>>
>>> After Csound compiles I get an error:
>>>
>>> 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!
>>>
>>> line 18 reads
>>>
>>> prints $ATTRIBS
>>>
>>> ??
>>>
>>>
>>>
>>> On 9 November 2015 at 14:14, jpff  wrote:
>>>       This works in tcsh -- you might tru bash
>>>
>>>
>>> ./csound--omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"Hello\\\"\
>>>       )\" bugmac2.csd
>>>
>>>
>>>
>>>
>



-- 

Saludos,

Date2015-11-09 16:13
Fromjpff
SubjectRe: [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  wrote:
>       ie I ould try
> csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\\\"red\\\"),size\(100,1
>       00\),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
>              wrote:
>                   I was trying to do using the csoundSetOption()
>             method:
> 
> csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\
>
>                   \),text\\(\"Hello\"\\)\"");
>
>             After Csound compiles I get an error:
>
>             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!
>
>             line 18 reads
>
>             prints $ATTRIBS
>
>             ??
> 
> 
>
>             On 9 November 2015 at 14:14, jpff
>              wrote:
>                   This works in tcsh -- you might tru bash
>
>                  ./csound--omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"He
>             llo\\\"\
>                   )\" bugmac2.csd
> 
> 
> 
> 
> 
> 
>

Date2015-11-09 17:58
FromRory Walsh
SubjectRe: [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++

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 <jpff@codemist.co.uk> wrote:
      ie I ould try
csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\\\"red\\\"),size\(100,1
      00\),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
            <rorywalsh@ear.ie> wrote:
                  I was trying to do using the csoundSetOption()
            method:

csound->SetOption((char*)"--omacro:ATTRIBS=\"colour\(\"red\"),size\\(100,100\

                  \),text\\(\"Hello\"\\)\"");

            After Csound compiles I get an error:

            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!

            line 18 reads

            prints $ATTRIBS

            ??



            On 9 November 2015 at 14:14, jpff
            <jpff@codemist.co.uk> wrote:
                  This works in tcsh -- you might tru bash

                 ./csound--omacro:ATTRIBS=\"colour\(\\\"red\\\"\),size\(100,100\),text\(\\\"He
            llo\\\"\
                  )\" bugmac2.csd