Csound Csound-dev Csound-tekno Search About

[Csnd] csound.GetChannel() for string channels

Date2009-06-13 23:02
FromOeyvind Brandtsegg
Subject[Csnd] csound.GetChannel() for string channels
By using csound.GetChannel() I can read the value stored in a chn
channel, as long as the value is a float.
Is there a special method to read a string stored in a chn channel ?
Say, I want to dynamically manipulate a string in csound, and make
this string readable from the host (e.g. Python),
I tried to do

(in the global instr)
chn_S "pycallString", 3

instr 2
Snew	sprintf	"newitem %i", p4
chnset	Snew, "pycallString"
endin

Then I try to do this in Python:
print "testing", cs.GetChannel("pycallString")

.. and it prints
"testing" 0.0

I see that the API docs says
MYFLT* CHNGET::arg
So I should expect a float.
What should I do to read a string from a chn channel via the API?

all best
Oeyvind

Date2009-06-13 23:24
Fromvictor
Subject[Csnd] Re: csound.GetChannel() for string channels
Well, if this was C, you would use

PUBLIC int csoundGetChannelPtr(CSOUND *,
                                 MYFLT **p, const char *name, int type);

But I don't think this wraps well in Python (hence the common
use of Csound::GetChannel()). So I guess this might be hard in
Python. I can try to look for a means of wrapping it by hand,
but it will be a while until I can get to it.


Victor

----- Original Message ----- 
From: "Oeyvind Brandtsegg" 
To: "Csound mailing list address" 
Sent: Saturday, June 13, 2009 11:02 PM
Subject: [Csnd] csound.GetChannel() for string channels


> By using csound.GetChannel() I can read the value stored in a chn
> channel, as long as the value is a float.
> Is there a special method to read a string stored in a chn channel ?
> Say, I want to dynamically manipulate a string in csound, and make
> this string readable from the host (e.g. Python),
> I tried to do
>
> (in the global instr)
> chn_S "pycallString", 3
>
> instr 2
> Snew sprintf "newitem %i", p4
> chnset Snew, "pycallString"
> endin
>
> Then I try to do this in Python:
> print "testing", cs.GetChannel("pycallString")
>
> .. and it prints
> "testing" 0.0
>
> I see that the API docs says
> MYFLT* CHNGET::arg
> So I should expect a float.
> What should I do to read a string from a chn channel via the API?
>
> all best
> Oeyvind
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound" 


Date2009-06-15 06:13
FromOeyvind Brandtsegg
Subject[Csnd] Re: Re: csound.GetChannel() for string channels
Ok. Thanks for the explanation.
I'm trying to find a way that lets Csound call the host (e.g. as I've
done with pycall), in an asynchronous manner so it is possible to use
the performanceThread.
The idea with using a string channel was to concatenate function calls
as a string, then parse the string on the python side. Maybe not the
best approach after all... back to the drawing board.

best
Oeyvind

2009/6/14 victor :
> Well, if this was C, you would use
>
> PUBLIC int csoundGetChannelPtr(CSOUND *,
>                                MYFLT **p, const char *name, int type);
>
> But I don't think this wraps well in Python (hence the common
> use of Csound::GetChannel()). So I guess this might be hard in
> Python. I can try to look for a means of wrapping it by hand,
> but it will be a while until I can get to it.
>
>
> Victor
>
> ----- Original Message ----- From: "Oeyvind Brandtsegg" 
> To: "Csound mailing list address" 
> Sent: Saturday, June 13, 2009 11:02 PM
> Subject: [Csnd] csound.GetChannel() for string channels
>
>
>> By using csound.GetChannel() I can read the value stored in a chn
>> channel, as long as the value is a float.
>> Is there a special method to read a string stored in a chn channel ?
>> Say, I want to dynamically manipulate a string in csound, and make
>> this string readable from the host (e.g. Python),
>> I tried to do
>>
>> (in the global instr)
>> chn_S "pycallString", 3
>>
>> instr 2
>> Snew sprintf "newitem %i", p4
>> chnset Snew, "pycallString"
>> endin
>>
>> Then I try to do this in Python:
>> print "testing", cs.GetChannel("pycallString")
>>
>> .. and it prints
>> "testing" 0.0
>>
>> I see that the API docs says
>> MYFLT* CHNGET::arg
>> So I should expect a float.
>> What should I do to read a string from a chn channel via the API?
>>
>> all best
>> Oeyvind
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>


Date2009-06-15 11:48
FromVictor.Lazzarini@nuim.ie
Subject[Csnd] Re: Re: Re: csound.GetChannel() for string channels
AttachmentsNone  None  

Date2009-06-15 13:49
FromOeyvind Brandtsegg
Subject[Csnd] Re: Re: Re: Re: csound.GetChannel() for string channels
Yes, that could be possible. It might be difficult to implement
arguments to the python function calls in a flexible manner.... I'll
give it some more thought. Thanks for the idea.
Oeyvind

2009/6/15  :
> Can't you have a table of the functions you want to call
> in the Python script and then send an index (and possibly parameters)
> to look them up?
>
> Victor
>
> ----- Original Message -----
> From: Oeyvind Brandtsegg 
> Date: Monday, June 15, 2009 11:44 am
> Subject: [Csnd] Re: Re: csound.GetChannel() for string channels
> To: csound@lists.bath.ac.uk
>
>> Ok. Thanks for the explanation.
>> I'm trying to find a way that lets Csound call the host (e.g. as I've
>> done with pycall), in an asynchronous manner so it is possible
>> to use
>> the performanceThread.
>> The idea with using a string channel was to concatenate function calls
>> as a string, then parse the string on the python side. Maybe not the
>> best approach after all... back to the drawing board.
>>
>> best
>> Oeyvind
>>
>> 2009/6/14 victor :
>> > Well, if this was C, you would use
>> >
>> > PUBLIC int csoundGetChannelPtr(CSOUND *,
>> >                                MYFLT **p, const char *name,
>> int type);
>> >
>> > But I don't think this wraps well in Python (hence the common
>> > use of Csound::GetChannel()). So I guess this might be hard in
>> > Python. I can try to look for a means of wrapping it by hand,
>> > but it will be a while until I can get to it.
>> >
>> >
>> > Victor
>> >
>> > ----- Original Message ----- From: "Oeyvind Brandtsegg"
>> > To: "Csound mailing list address"
>> > Sent: Saturday, June 13, 2009
>> 11:02 PM
>> > Subject: [Csnd] csound.GetChannel() for string channels
>> >
>> >
>> >> By using csound.GetChannel() I can read the value stored in a chn
>> >> channel, as long as the value is a float.
>> >> Is there a special method to read a string stored in a chn
>> channel ?
>> >> Say, I want to dynamically manipulate a string in csound, and make
>> >> this string readable from the host (e.g. Python),
>> >> I tried to do
>> >>
>> >> (in the global instr)
>> >> chn_S "pycallString", 3
>> >>
>> >> instr 2
>> >> Snew sprintf "newitem %i", p4
>> >> chnset Snew, "pycallString"
>> >> endin
>> >>
>> >> Then I try to do this in Python:
>> >> print "testing", cs.GetChannel("pycallString")
>> >>
>> >> .. and it prints
>> >> "testing" 0.0
>> >>
>> >> I see that the API docs says
>> >> MYFLT* CHNGET::arg
>> >> So I should expect a float.
>> >> What should I do to read a string from a chn channel via the API?
>> >>
>> >> all best
>> >> Oeyvind
>> >>
>> >>
>> >> Send bugs reports to this list.
>> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> "unsubscribe>> csound"
>> >
>> >
>> >
>> > Send bugs reports to this list.
>> > To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> "unsubscribe> csound"
>> >
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> "unsubscribe csound"
>
> Dr Victor Lazzarini, Senior Lecturer, Dept. of Music,National University of
> Ireland, Maynooth
>