| I just tried to call csoundGetCha.. directly from my button function. I
create and allocate space for my_string in my main class constructor but
I still only see rubbish characters? My OnButtonClick function looks
like this
void __fastcall TForm1::OnButtonClick(TObject *Sender)
{
csoundGetChannelPtr(pd->instance, (MYFLT **)&my_string, "menu1",
CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL);
strcpy(my_string, "hello\n");
}
There must be something being assigned to the channel as the rubbish
characters only appear once I press my button. If they're was nothing be
sent to the channel Csound would not be printing anything at all, right?
Rory.
Victor Lazzarini wrote:
> Try to create my_string outside your Set... function, passing it
> to it as a parameter. In fact you can do the csoundGetCh... call
> outside and then just copy the string in your function.
>
> What the csoundGet.... is doing is linking a channel with the
> string location you created. Anything written into that location
> will appear on the channel.
>
> At 15:11 28/08/2006, you wrote:
>> Hi Victor, I've just tried your code which as you said works. I did have
>> to cast the result of malloc to a char*, maybe this is because we are
>> using different compilers? Anyway I then tried it out in a GUI
>> application. I basically modified my previous function to look like this:
>>
>> void SetValueInChannelStr(CSOUND *cs, char *name, AnsiString string){
>> char *my_string;
>> my_string = (char*)malloc(csoundGetStrVarMaxLen(cs));
>> int result;
>> result = csoundGetChannelPtr(cs, (MYFLT **)&my_string, name,
>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL);
>> //change 'hello' to AnsiString string once it works...
>> if (!result)strcpy(my_string, "hello");
>> }
>>
>> I have it set up so that SetValueInChannelStr() is called when I press a
>> button. The problem is that when I run my test instead of "hello" being
>> printed to the screen I get rubbish characters. Any idea why this might
>> be happening?
>>
>> Rory.
>>
>>
>> Victor Lazzarini wrote:
>>> and here's a simple example that works:
>>>
>>> int main(int argc, char **argv)
>>> {
>>> CSOUND *csound;
>>> char *fname = NULL;
>>> int i, result;
>>> char *string;
>>>
>>> /* initialise Csound library */
>>> csoundInitialize(&argc, &argv, 0);
>>>
>>> /* Create Csound. */
>>> csound = csoundCreate(NULL);
>>>
>>> string = malloc(csoundGetStrVarMaxLen(csound));
>>> /* One complete performance cycle. */
>>> result = csoundCompile(csound, argc, argv);
>>> result = csoundGetChannelPtr(csound, (MYFLT **)&string, "pitch",
>>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL);
>>> strcpy(string, "hello\n");
>>>
>>> while (!result){
>>> result = csoundPerformKsmps(csound);
>>> }
>>> /* delete Csound instance */
>>> csoundDestroy(csound);
>>> free(string);
>>> return (result >= 0 ? 0 : result);
>>> }
>>>
>>>
>>>
>>>
>>> At 13:10 28/08/2006, you wrote:
>>>> The 'string' argument does not get passed to csoundGetChannelPtr(), so
>>>> csound never gets it.
>>>>
>>>>
>>>>> }
>>>>> //--------------------------------------------------------------
>>>>> void SetValueInChannelStr(CSOUND *cs, char *name, char* string)
>>>>> {
>>>>> MYFLT *pvalue_tmp;
>>>>> int result;
>>>>> result = csoundGetChannelPtr(cs, &pvalue_tmp, name,
>>>>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL);
>>>>> char *pvalue = reinterpret_cast(pvalue_tmp);
>>>>> if (!result)strcpy(pvalue, "test string");
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------------
>>>>> 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
>>>> Victor Lazzarini
>>>> Music Technology Laboratory
>>>> Music Department
>>>> National University of Ireland, Maynooth
>>>>
>>>>
>>>> -------------------------------------------------------------------------
>>>> 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
>>> Victor Lazzarini
>>> Music Technology Laboratory
>>> Music Department
>>> National University of Ireland, Maynooth
>>>
>>>
>>> -------------------------------------------------------------------------
>>> 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
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> Victor Lazzarini
> Music Technology Laboratory
> Music Department
> National University of Ireland, Maynooth
>
>
> -------------------------------------------------------------------------
> 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 |