[Csnd] strange things with strings

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] strange things with strings

zappfinger
I have this piece of code:

if (kgm==1) then
     ;printks "in if...%s",1, Spath
     Sbank strsubk Spath, 7, 9
     Spres strsubk Spath, 18, 23
     printks "bank:%s, preset:%s",1, Sbank, Spres
     klen strlenk Sbank
     printk2 klen
     if (klen>0) then
         kbank strtodk Sbank  ;<= here the output says: empty string
         kpres strtodk Spres
         printks "bank:%f, preset:%f",1, kbank, kpres
     endif

endif


See the commented line, csound output gives an error about Sbank being
an empty string

But this is what I try to avoid by the if (klen>0) construction! It
looks like the code is already executed??

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

Andy.Fillebrown
Try skipping over it at i-time or initializing it to a non-empty string at i-time.


On Mon, Nov 23, 2020 at 7:30 AM Richard <[hidden email]> wrote:
I have this piece of code:

if (kgm==1) then
     ;printks "in if...%s",1, Spath
     Sbank strsubk Spath, 7, 9
     Spres strsubk Spath, 18, 23
     printks "bank:%s, preset:%s",1, Sbank, Spres
     klen strlenk Sbank
     printk2 klen
     if (klen>0) then
         kbank strtodk Sbank  ;<= here the output says: empty string
         kpres strtodk Spres
         printks "bank:%f, preset:%f",1, kbank, kpres
     endif

endif


See the commented line, csound output gives an error about Sbank being
an empty string

But this is what I try to avoid by the if (klen>0) construction! It
looks like the code is already executed??

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

zappfinger

I would not know how to skip at i-time, but initializing the string does not work: I get the same error message.

Here's the code:

instr 11
Spath chnget "GM"
printks "now.....%s",1,Spath    ;when this line is commented out, the change shows the previous value!
kgm changed Spath
printk2 kgm
if (kgm==1) then
    Sbank = "0"        ;<= initialized here
    ;printks "in if...%s",1, Spath
    Sbank strsubk Spath, 7, 9
    Spres strsubk Spath, 18, 23
    printks "bank:%s, preset:%s",1, Sbank, Spres
    klen strlenk Sbank
    printk2 klen    ;<= nothing is printed here
    if (klen>0) then
        kbank strtodk Sbank     ;<= error about empty string here
        kpres strtodk Spres
        printks "bank:%f, preset:%f",1, kbank, kpres
    endif
   
endif
endin

On 23/11/2020 14:51, andy fillebrown wrote:
Try skipping over it at i-time or initializing it to a non-empty string at i-time.


On Mon, Nov 23, 2020 at 7:30 AM Richard <[hidden email]> wrote:
I have this piece of code:

if (kgm==1) then
     ;printks "in if...%s",1, Spath
     Sbank strsubk Spath, 7, 9
     Spres strsubk Spath, 18, 23
     printks "bank:%s, preset:%s",1, Sbank, Spres
     klen strlenk Sbank
     printk2 klen
     if (klen>0) then
         kbank strtodk Sbank  ;<= here the output says: empty string
         kpres strtodk Spres
         printks "bank:%f, preset:%f",1, kbank, kpres
     endif

endif


See the commented line, csound output gives an error about Sbank being
an empty string

But this is what I try to avoid by the if (klen>0) construction! It
looks like the code is already executed??

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

jpff
= is not i-time initialisatio; init is for that.

Not sure if that is yur problem though. A complete csd would e so much
easier to see what if happening by reading the actual compiled code.


On Mon, 23 Nov 2020, Richard wrote:

>
> I would not know how to skip at i-time, but initializing the string does not
> work: I get the same error message.
>
> Here's the code:
>
> instr 11
> Spath chnget "GM"
> printks "now.....%s",1,Spath    ;when this line is commented out, the change
> shows the previous value!
> kgm changed Spath
> printk2 kgm
> if (kgm==1) then
>     Sbank = "0"        ;<= initialized here
>     ;printks "in if...%s",1, Spath
>     Sbank strsubk Spath, 7, 9
>     Spres strsubk Spath, 18, 23
>     printks "bank:%s, preset:%s",1, Sbank, Spres
>     klen strlenk Sbank
>     printk2 klen    ;<= nothing is printed here
>     if (klen>0) then
>         kbank strtodk Sbank     ;<= error about empty string here
>         kpres strtodk Spres
>         printks "bank:%f, preset:%f",1, kbank, kpres
>     endif
>    
> endif
> endin
>
> On 23/11/2020 14:51, andy fillebrown wrote:
>       Try skipping over it at i-time or initializing it to a non-empty
>       string at i-time.
>
>
> On Mon, Nov 23, 2020 at 7:30 AM Richard <[hidden email]> wrote:
>       I have this piece of code:
>
>       if (kgm==1) then
>            ;printks "in if...%s",1, Spath
>            Sbank strsubk Spath, 7, 9
>            Spres strsubk Spath, 18, 23
>            printks "bank:%s, preset:%s",1, Sbank, Spres
>            klen strlenk Sbank
>            printk2 klen
>            if (klen>0) then
>                kbank strtodk Sbank  ;<= here the output says:
>       empty string
>                kpres strtodk Spres
>                printks "bank:%f, preset:%f",1, kbank, kpres
>            endif
>
>       endif
>
>
>       See the commented line, csound output gives an error about
>       Sbank being
>       an empty string
>
>       But this is what I try to avoid by the if (klen>0)
>       construction! It
>       looks like the code is already executed??
>
>       Csound mailing list
>       [hidden email]
>       https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>       Send bugs reports to
>               https://github.com/csound/csound/issues
>       Discussions of bugs and features can be posted here
>
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here
>
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

zappfinger
I also tried init.

But you are right, a csd is needed.

Here it is:




On 23/11/2020 22:50, john wrote:

> = is not i-time initialisatio; init is for that.
>
> Not sure if that is yur problem though. A complete csd would e so much
> easier to see what if happening by reading the actual compiled code.
>
>
> On Mon, 23 Nov 2020, Richard wrote:
>
>>
>> I would not know how to skip at i-time, but initializing the string
>> does not
>> work: I get the same error message.
>>
>> Here's the code:
>>
>> instr 11
>> Spath chnget "GM"
>> printks "now.....%s",1,Spath    ;when this line is commented out, the
>> change
>> shows the previous value!
>> kgm changed Spath
>> printk2 kgm
>> if (kgm==1) then
>>     Sbank = "0"        ;<= initialized here
>>     ;printks "in if...%s",1, Spath
>>     Sbank strsubk Spath, 7, 9
>>     Spres strsubk Spath, 18, 23
>>     printks "bank:%s, preset:%s",1, Sbank, Spres
>>     klen strlenk Sbank
>>     printk2 klen    ;<= nothing is printed here
>>     if (klen>0) then
>>         kbank strtodk Sbank     ;<= error about empty string here
>>         kpres strtodk Spres
>>         printks "bank:%f, preset:%f",1, kbank, kpres
>>     endif
>>
>> endif
>> endin
>>
>> On 23/11/2020 14:51, andy fillebrown wrote:
>>       Try skipping over it at i-time or initializing it to a non-empty
>>       string at i-time.
>>
>>
>> On Mon, Nov 23, 2020 at 7:30 AM Richard <[hidden email]> wrote:
>>       I have this piece of code:
>>
>>       if (kgm==1) then
>>            ;printks "in if...%s",1, Spath
>>            Sbank strsubk Spath, 7, 9
>>            Spres strsubk Spath, 18, 23
>>            printks "bank:%s, preset:%s",1, Sbank, Spres
>>            klen strlenk Sbank
>>            printk2 klen
>>            if (klen>0) then
>>                kbank strtodk Sbank  ;<= here the output says:
>>       empty string
>>                kpres strtodk Spres
>>                printks "bank:%f, preset:%f",1, kbank, kpres
>>            endif
>>
>>       endif
>>
>>
>>       See the commented line, csound output gives an error about
>>       Sbank being
>>       an empty string
>>
>>       But this is what I try to avoid by the if (klen>0)
>>       construction! It
>>       looks like the code is already executed??
>>
>>       Csound mailing list
>>       [hidden email]
>>       https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>       Send bugs reports to
>>               https://github.com/csound/csound/issues
>>       Discussions of bugs and features can be posted here
>>
>> Csound mailing list [hidden email]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>>
>> Csound mailing list [hidden email]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and
>> features can
>> be posted here
>>
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

zappfinger
In reply to this post by jpff
Sorry, sent too soon.

Here is the csd and the text file


On 23/11/2020 22:50, john wrote:

> = is not i-time initialisatio; init is for that.
>
> Not sure if that is yur problem though. A complete csd would e so much
> easier to see what if happening by reading the actual compiled code.
>
>
> On Mon, 23 Nov 2020, Richard wrote:
>
>>
>> I would not know how to skip at i-time, but initializing the string
>> does not
>> work: I get the same error message.
>>
>> Here's the code:
>>
>> instr 11
>> Spath chnget "GM"
>> printks "now.....%s",1,Spath    ;when this line is commented out, the
>> change
>> shows the previous value!
>> kgm changed Spath
>> printk2 kgm
>> if (kgm==1) then
>>     Sbank = "0"        ;<= initialized here
>>     ;printks "in if...%s",1, Spath
>>     Sbank strsubk Spath, 7, 9
>>     Spres strsubk Spath, 18, 23
>>     printks "bank:%s, preset:%s",1, Sbank, Spres
>>     klen strlenk Sbank
>>     printk2 klen    ;<= nothing is printed here
>>     if (klen>0) then
>>         kbank strtodk Sbank     ;<= error about empty string here
>>         kpres strtodk Spres
>>         printks "bank:%f, preset:%f",1, kbank, kpres
>>     endif
>>
>> endif
>> endin
>>
>> On 23/11/2020 14:51, andy fillebrown wrote:
>>       Try skipping over it at i-time or initializing it to a non-empty
>>       string at i-time.
>>
>>
>> On Mon, Nov 23, 2020 at 7:30 AM Richard <[hidden email]> wrote:
>>       I have this piece of code:
>>
>>       if (kgm==1) then
>>            ;printks "in if...%s",1, Spath
>>            Sbank strsubk Spath, 7, 9
>>            Spres strsubk Spath, 18, 23
>>            printks "bank:%s, preset:%s",1, Sbank, Spres
>>            klen strlenk Sbank
>>            printk2 klen
>>            if (klen>0) then
>>                kbank strtodk Sbank  ;<= here the output says:
>>       empty string
>>                kpres strtodk Spres
>>                printks "bank:%f, preset:%f",1, kbank, kpres
>>            endif
>>
>>       endif
>>
>>
>>       See the commented line, csound output gives an error about
>>       Sbank being
>>       an empty string
>>
>>       But this is what I try to avoid by the if (klen>0)
>>       construction! It
>>       looks like the code is already executed??
>>
>>       Csound mailing list
>>       [hidden email]
>>       https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>       Send bugs reports to
>>               https://github.com/csound/csound/issues
>>       Discussions of bugs and features can be posted here
>>
>> Csound mailing list [hidden email]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>>
>> Csound mailing list [hidden email]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and
>> features can
>> be posted here
>>
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

GM_test.txt (2K) Download Attachment
chnget.csd (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] strange things with strings

jpff
I fiddled with your program a bit as I do not have cabbage or the sf file
you use but the problem is in instr 11 were you use strtodk which runs at
both i-time and k-rate.  But Sbank is not given a value at init time only
on each k-cycle.

Thisis because strsubk is also run at i- and k-time so as the range given
is ourside the blank string of Spath,  Sbank is set to an empty string.

Many string operations run at both times which often causes problems

==John ff

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here