| Thank you David, that code should go into the Csound API hall of fame!
You've really saved me a lot a time, thanks again,
Rory.
> You could try using csoundListChannels(). For example:
>
> CsoundChannelListEntry *csoundChanList = NULL;
> int numCsoundChannels;
> int type = CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL;
>
> numCsoundChannels = csoundListChannels(csound->GetCsound(),
> &csoundChanList);
>
> for(i=0; i {
> if((csoundChanList[i].type & type) == type &&
> strcmp(csoundChanList[i].name, "amp") == 0)
> {
> cout << "a channel named amp exists..";
> }
> }
> if(csoundChanList) csoundDeleteChannelList(x->csound, csoundChanList);
>
>
> The only caveat being that you'll have to either declare your channels
> with chn_i/chn_k or start the Csound performance so that any channels in
> your code are created before you call csoundListChannels().
>
> Happy CsoundAPI'ing,
>
> Davis
>
>
>
> --- Rory Walsh wrote:
>
>> As I understand it if I call csoundGetChannelPtr with type set to 0 it
>> will check that the channel exists but not create one if it doesn't
>> exist.
>> If so the following code(see below) should not print "a channel named
>> amp
>> exists.." when run given that I don't set up a channel called "amp" in
>> my
>> csd file. Unfortunately it does print this message. Can anyone see why
>> this is? I really need to be able to check for channels without creating
>> them if they don't exist, anyone ideas?
>>
>> Rory.
>>
>> #include "csound.hpp"
>> #include "csPerfThread.hpp"
>> #include
>> using namespace std;
>>
>> int main(int argc, char *argv[])
>> {
>> int hold=1;
>> MYFLT* val;
>> /*create a Csound object*/
>> Csound* csound = new Csound;
>> /*pre-compile instance of csound*/
>> csound->PreCompile();
>> /*compile instance of csound*/
>> csound->Compile("test.csd");
>> /* create a CsoundPerfThread object */
>> CsoundPerformanceThread* perf =
>> new CsoundPerformanceThread(csound->GetCsound());
>> /* start csound thread */
>> perf->Play();
>>
>> while(hold){
>> if (csoundGetChannelPtr(csound->GetCsound(),
>> &val,
>> "amp",
>> 0)==CSOUND_CONTROL_CHANNEL|CSOUND_OUTPUT_CHANNEL){
>> cout << "a channel named amp exists..";
>> }
>> cin >> hold;
>> csound->SetChannel("freq", (MYFLT)hold);
>> }
>>
>> /* stop thread */
>> perf->Stop();
>> /*delete instance of csound*/
>> delete csound;
>> }
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |