Csound Csound-dev Csound-tekno Search About

[Cs-dev] csoundGetChannelPtr()...well kind of...

Date2006-06-24 12:39
FromRory Walsh
Subject[Cs-dev] csoundGetChannelPtr()...well kind of...
I am trying to add more functionality to the GUI controls provided by 
lettuce by allowing for two-way communication between Csound and the 
host app's that Lettuce can generate. I would like for example to allow 
users to be able to change a label in their host application by calling 
*chnset* in Csound. The following line of code will create a label in 
the host app with a default value of "caption"

label "chanName", width, height, top, left, "caption", "colour"

I would like if "caption" would remain the label text *until* chnset is 
called in Csound. As it stands each host app has a timer that keeps 
calling GetValueOutChannel(see below), which in turn calls 
csoundGetChannelPtr(), which then sends data to the label channel which 
in turn overwrites "caption". The main issue here is that 
csoundGetChannelPtr() will create the channel is it does not already 
exist, and it seems to initialise it to 0. In my timer function(see 
below) I was doing a simple test, if(GetValueOutChannel()!=0) then 
update label, but as you can imagine this didn't work so well 
considering users would often like to send 0 to the label. So my 
question is how can I prevent data from being sent on a particular 
software channel until a call is made to *chnset*? I hope I have 
explained my self well, has anyone any suggestions?

Rory.


//-------------------------------------------------------------------
MYFLT GetValueOutChannel(CSOUND *cs, AnsiString name)
{
           MYFLT *pvalue;
           int result;
           result =
           csoundGetChannelPtr(cs, &pvalue, name.c_str(),
                   CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL);
           return *pvalue;
}
//-------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
for(int i=0;i(guiObj[i]))
       {
       if(GetValueOutChannel(pd->instance, channelname[i])!=0) 
 
 
 
 
       	((TPanel*)guiObj[i])->Caption=
  		(AnsiString)GetValueOutChannel(pd->instance,								channelname[i]);
       }
   etc, etc......
   }
}

P.S. guiObj is a vector of GUI objects while channelname is a vector of 
strings, and AnsiString is a Borland string type. It's ok to cast a 
value as an AnsiString in the fashion above without any problems.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-06-24 12:53
FromIstvan Varga
SubjectRe: [Cs-dev] csoundGetChannelPtr()...well kind of...
AttachmentsNone  

Date2006-06-24 13:37
FromRory Walsh
SubjectRe: [Cs-dev] csoundGetChannelPtr()...well kind of...
Thanks Istvan. I've changed my code so that I can now pass 'type' as the 
third parameter to my GetValueOutChannel() function so now I can check 
it like this

if(dynamic_cast(guiObj[i]))
{
if(GetValueOutChannel(pd->instance, channelname[i], 0)!=CSOUND_ERROR)
((TPanel*)guiObj[i])->Caption= 
(AnsiString)GetValueOutChannel(pd->instance, channelname[i], 
CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL);
}

Calling *chnset* does not declare a channel right? I have to use *chn_k* 
  don't I? Anyway I tried the following csound code but my label text is 
not updated as I thought it would...

chn_k "test", 2		;create channel "test"

instr 1
k2 line 0, p3, 100
chnset k2, "test"	;send data to channel "test"
endin


Am I right in assuming that once chn_k is called the channel is created 
and passing type 0 to csoundGetChannelPtr() will no longer return 
CSOUND_ERROR? If this is the case shouldn't my label text be updating? I 
Thanks again for your help and patience with my constant questions, I 
really appreciate it.

Rory.




Istvan Varga wrote:
> You can check if a channel exists (and if it does, find out its type)
> by calling csoundGetChannelPtr() with a zero type value. It will then
> fail, and either return CSOUND_ERROR if the channel does not exist yet,
> or the type (in the same format as the type argument) of the already
> existing channel.
> 
> On Saturday 24 June 2006 13:39, Rory Walsh wrote:
>

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-06-24 13:43
FromIstvan Varga
SubjectRe: [Cs-dev] csoundGetChannelPtr()...well kind of...
AttachmentsNone  

Date2006-06-24 13:52
FromRory Walsh
SubjectRe: [Cs-dev] csoundGetChannelPtr()...well kind of...
Cheers, I also see where my mistake is, I was testing the value of 
*pvalue which my function returns rather than the return value of 
csoundGetChannelPtr(). Thanks again,

Rory.

Istvan Varga wrote:
> On Saturday 24 June 2006 14:37, Rory Walsh wrote:
> 
>> Calling *chnset* does not declare a channel right?
> 
> It does declare the channel.
> 
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net