Csound Csound-dev Csound-tekno Search About

[Csnd] Boolean with Strings

Date2014-04-25 15:35
Fromhlolli
Subject[Csnd] Boolean with Strings
Like many times, the solution could be very simple. But Im trying to use
strings as Boolean/conditional.

Made an example that generates error in my csound:

error:  error: boolean expression '==' with arg types SS not found, line 14 
Parsing failed due to 1 semantic error!
WARNING: Stopping on parser failure






sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1
giSine       ftgen     0, 0, 2^10, 10, 1

instr 1
asig oscil .5, 440, giSine
Senv = p4
if (Senv == "Expon") then
kenv expon 1, p3, 0.001
asig = asig*kenv
endif
outs asig, asig
endin



i 1 0 1 "Expon"





--
View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2014-04-25 15:44
FromSteven Yi
SubjectRe: [Csnd] Boolean with Strings
I don't think we have an opcode for that.  You could maybe use:

if ( strcmpk(Senv, "Expon") == 0 ) then



On Fri, Apr 25, 2014 at 10:35 AM, hlolli  wrote:
> Like many times, the solution could be very simple. But Im trying to use
> strings as Boolean/conditional.
>
> Made an example that generates error in my csound:
>
> error:  error: boolean expression '==' with arg types SS not found, line 14
> Parsing failed due to 1 semantic error!
> WARNING: Stopping on parser failure
>
>
> 
> 
> 
> 
> sr = 44100
> ksmps = 128
> nchnls = 2
> 0dbfs = 1
> giSine       ftgen     0, 0, 2^10, 10, 1
>
> instr 1
> asig oscil .5, 440, giSine
> Senv = p4
> if (Senv == "Expon") then
> kenv expon 1, p3, 0.001
> asig = asig*kenv
> endif
> outs asig, asig
> endin
>
> 
> 
> i 1 0 1 "Expon"
> 
> 
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>         https://github.com/csound/csound/issues
> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2014-04-25 15:59
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Boolean with Strings
Thank you Steven 

this works

If it would be possible to send beer trough the internet, I'd buy you one :)


2014-04-25 14:44 GMT+00:00 Steven Yi <stevenyi@gmail.com>:
I don't think we have an opcode for that.  You could maybe use:

if ( strcmpk(Senv, "Expon") == 0 ) then



On Fri, Apr 25, 2014 at 10:35 AM, hlolli <hlolli@gmail.com> wrote:
> Like many times, the solution could be very simple. But Im trying to use
> strings as Boolean/conditional.
>
> Made an example that generates error in my csound:
>
> error:  error: boolean expression '==' with arg types SS not found, line 14
> Parsing failed due to 1 semantic error!
> WARNING: Stopping on parser failure
>
>
> <CsoundSynthesizer>
> <CsOptions>
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 128
> nchnls = 2
> 0dbfs = 1
> giSine       ftgen     0, 0, 2^10, 10, 1
>
> instr 1
> asig oscil .5, 440, giSine
> Senv = p4
> if (Senv == "Expon") then
> kenv expon 1, p3, 0.001
> asig = asig*kenv
> endif
> outs asig, asig
> endin
>
> </CsInstruments>
> <CsScore>
> i 1 0 1 "Expon"
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>         https://github.com/csound/csound/issues
> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-04-25 16:01
FromSteven Yi
SubjectRe: [Csnd] Boolean with Strings
:) Glad that works for you.  I think because Strings don't really have
a rate, it might be better to use strcmp and strcmpk rather than try
to figure out some kind of magic with implementing a == opcode.  Nice
that there's a solution that works well. :)

On Fri, Apr 25, 2014 at 10:59 AM, Hlöðver Sigurðsson  wrote:
> Thank you Steven
>
> this works
>
> If it would be possible to send beer trough the internet, I'd buy you one :)
>
>
> 2014-04-25 14:44 GMT+00:00 Steven Yi :
>
>> I don't think we have an opcode for that.  You could maybe use:
>>
>> if ( strcmpk(Senv, "Expon") == 0 ) then
>>
>>
>>
>> On Fri, Apr 25, 2014 at 10:35 AM, hlolli  wrote:
>> > Like many times, the solution could be very simple. But Im trying to use
>> > strings as Boolean/conditional.
>> >
>> > Made an example that generates error in my csound:
>> >
>> > error:  error: boolean expression '==' with arg types SS not found, line
>> > 14
>> > Parsing failed due to 1 semantic error!
>> > WARNING: Stopping on parser failure
>> >
>> >
>> > 
>> > 
>> > 
>> > 
>> > sr = 44100
>> > ksmps = 128
>> > nchnls = 2
>> > 0dbfs = 1
>> > giSine       ftgen     0, 0, 2^10, 10, 1
>> >
>> > instr 1
>> > asig oscil .5, 440, giSine
>> > Senv = p4
>> > if (Senv == "Expon") then
>> > kenv expon 1, p3, 0.001
>> > asig = asig*kenv
>> > endif
>> > outs asig, asig
>> > endin
>> >
>> > 
>> > 
>> > i 1 0 1 "Expon"
>> > 
>> > 
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> > http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665.html
>> > Sent from the Csound - General mailing list archive at Nabble.com.
>> >
>> >
>> > Send bugs reports to
>> >         https://github.com/csound/csound/issues
>> > 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
>>         https://github.com/csound/csound/issues
>> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




Date2014-04-25 17:16
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re:
AttachmentsNone  

Date2014-04-25 23:28
Fromhlolli
Subject[Csnd] Re: Re:
More on strings, is there a way to send strings in p-fields in schedkwhen, I
know they only accept i rate values. But maybe there is a way to convert the
string to a number before csound compiles the code.

Im looking to use strings more to make the code more comfortable to watch, I
know macros is a possibility, but Im curious is strings are also possible to
use for same purpose.

example:
schedkwhen ktrigger, 0, 1, "flute", 0, 2.5, "a3", "ppp"



--
View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665p5734683.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2014-04-25 23:35
FromVictor Lazzarini
SubjectRe: [Csnd]
You can use scoreline as well, which takes the whole event as a string. You can construct the string with sprintf/k.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 25 Apr 2014, at 23:28, hlolli  wrote:

> More on strings, is there a way to send strings in p-fields in schedkwhen, I
> know they only accept i rate values. But maybe there is a way to convert the
> string to a number before csound compiles the code.
> 
> Im looking to use strings more to make the code more comfortable to watch, I
> know macros is a possibility, but Im curious is strings are also possible to
> use for same purpose.
> 
> example:
> schedkwhen ktrigger, 0, 1, "flute", 0, 2.5, "a3", "ppp"
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665p5734683.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> Send bugs reports to
>        https://github.com/csound/csound/issues
> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




Date2014-04-26 01:03
FromHlöðver Sigurðsson
SubjectRe: [Csnd]
Scoreline doesn't have mintime function that Im relying on from schedkwhen. So I chose to make udo with schedkwhen and I'll there convert the strings to floating i-rate values.(in so unlikely case that information might be helpful to someone)


2014-04-25 22:35 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
You can use scoreline as well, which takes the whole event as a string. You can construct the string with sprintf/k.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 25 Apr 2014, at 23:28, hlolli <hlolli@gmail.com> wrote:

> More on strings, is there a way to send strings in p-fields in schedkwhen, I
> know they only accept i rate values. But maybe there is a way to convert the
> string to a number before csound compiles the code.
>
> Im looking to use strings more to make the code more comfortable to watch, I
> know macros is a possibility, but Im curious is strings are also possible to
> use for same purpose.
>
> example:
> schedkwhen ktrigger, 0, 1, "flute", 0, 2.5, "a3", "ppp"
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665p5734683.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>        https://github.com/csound/csound/issues
> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Date2014-04-26 01:11
FromHlöðver Sigurðsson
SubjectRe: [Csnd]
Just as Im writing this Im surprised that there's no optional i-rate string in UDO(only S letter for intype, which is non-optional for i-rate strings), at least not according to the manual. But I can workaround it.


2014-04-26 0:03 GMT+00:00 Hlöðver Sigurðsson <hlolli@gmail.com>:
Scoreline doesn't have mintime function that Im relying on from schedkwhen. So I chose to make udo with schedkwhen and I'll there convert the strings to floating i-rate values.(in so unlikely case that information might be helpful to someone)


2014-04-25 22:35 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:

You can use scoreline as well, which takes the whole event as a string. You can construct the string with sprintf/k.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 25 Apr 2014, at 23:28, hlolli <hlolli@gmail.com> wrote:

> More on strings, is there a way to send strings in p-fields in schedkwhen, I
> know they only accept i rate values. But maybe there is a way to convert the
> string to a number before csound compiles the code.
>
> Im looking to use strings more to make the code more comfortable to watch, I
> know macros is a possibility, but Im curious is strings are also possible to
> use for same purpose.
>
> example:
> schedkwhen ktrigger, 0, 1, "flute", 0, 2.5, "a3", "ppp"
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665p5734683.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to
>        https://github.com/csound/csound/issues
> 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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"






Date2014-04-26 11:59
Fromjoachim heintz
SubjectRe: [Csnd]
you could probably also use strset?
if you prefer, you can also set strset declarations in the CsOptions via 
--stresetN=value, for instance --strset1=one --strset2=two.
best -
	joachim


Am 26.04.2014 02:03, schrieb Hlöðver Sigurðsson:
> Scoreline doesn't have mintime function that Im relying on from
> schedkwhen. So I chose to make udo with schedkwhen and I'll there
> convert the strings to floating i-rate values.(in so unlikely case that
> information might be helpful to someone)
>
>
> 2014-04-25 22:35 GMT+00:00 Victor Lazzarini  >:
>
>     You can use scoreline as well, which takes the whole event as a
>     string. You can construct the string with sprintf/k.
>
>     ========================
>     Dr Victor Lazzarini
>     Senior Lecturer
>     NUI Maynooth, Ireland
>     victor dot lazzarini at nuim dot ie
>
>
>
>
>     On 25 Apr 2014, at 23:28, hlolli      > wrote:
>
>      > More on strings, is there a way to send strings in p-fields in
>     schedkwhen, I
>      > know they only accept i rate values. But maybe there is a way to
>     convert the
>      > string to a number before csound compiles the code.
>      >
>      > Im looking to use strings more to make the code more comfortable
>     to watch, I
>      > know macros is a possibility, but Im curious is strings are also
>     possible to
>      > use for same purpose.
>      >
>      > example:
>      > schedkwhen ktrigger, 0, 1, "flute", 0, 2.5, "a3", "ppp"
>      >
>      >
>      >
>      > --
>      > View this message in context:
>     http://csound.1045644.n5.nabble.com/Boolean-with-Strings-tp5734665p5734683.html
>      > Sent from the Csound - General mailing list archive at Nabble.com.
>      >
>      >
>      > Send bugs reports to
>      > https://github.com/csound/csound/issues
>      > 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
>     https://github.com/csound/csound/issues
>     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
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"