Csound Csound-dev Csound-tekno Search About

[Cs-dev] A student attempting to use the API

Date2006-07-13 08:03
Fromjpff@codemist.co.uk
Subject[Cs-dev] A student attempting to use the API
I have a student who is attempting to use the Java API acess to
Csound, and in particular using the Software Bus to get data in and
out.  I am not up to speed on the API, and know no Java, but what he
sems to be saying is that he annot get a-rate data out via the
GetChannel and SetChannel methods.  i woud appreciate hearing what he
is doing wrong

------- Start of forwarded message -------
Date: Wed, 12 Jul 2006 15:27:41 +0100
Subject: Csound Java API - difficulties with a-rate data

I've been working with the Java API wuth some success, but run into a fairly
fundamental problem with accessing a-rate data.

k- and i- rate data are fine, using the chnset and chnget opcodes and named
(i.e . string indexed) channels. These can be accessed through the API with
the GetChannel and SetChannel methods of the main Csound class.

a-rate data must obviously work differently, since the (Get|Set)Channel
methods have a single return (whereas we need ksmps returns). In any case,
using something like:

chnset a1, "output"

(where a1 is a-rate data which also goes to "out")

doesn't result in anything being passed to the named channel "output".

Annoyingly, I can see exactly how this works in the C API, and the Java API
does have methods for GetOutputBuffer and GetSpout, both of which return an
opaque type SWIG_p_double, which I assume is a pointer to the first MYFLT
(of ksmpls MYFLTs) in the output buffer. Unfortunately, I can't see a way to
access it. Obviously in Java there's no way to just dereference the pointer.

The only other sensible looking approach is to use the chano opcode. There
are Java methods (e.g. ChanOAGet) which take a SWIG_p_double (presumably a
pointer to the channel created with chano) and an integer (I presume an
index, as in the C function csoundChanOAGet). However, in Java, all I have
to work with is the function return (in this case an integer, which seems to
just be zero for a successful call).

------- End of forwarded message -------

==John ffitch


-------------------------------------------------------------------------
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-07-13 09:54
FromRory Walsh
SubjectRe: [Cs-dev] A student attempting to use the API
Hi John. I'm going out on a limb here as my programming skills are 
nothing in comparison to the others who frequent this list...anyway I've 
never used those methods but from looking at the csound.hpp header file 
I see that GetChannel() is defined as

virtual MYFLT GetChannel(const char *name)
{
     MYFLT *p;
     if (!(csoundGetChannelPtr(csound, &p, name,
                               CSOUND_CONTROL_CHANNEL |      						 
CSOUND_OUTPUT_CHANNEL)))
     return (*p);
     return (MYFLT) 0;
}

The 'type' passed to csoundGetChannelPtr() is CSOUND_CONTROL_CHANNEL 
where I think it should be CSOUND_AUDIO_CHANNEL if he wants to deal with 
a-rate signals. Perhaps if he were to call csoundGetChannelPtr() 
directly it would offer more flexibility? Like I said though, I could be 
way off the mark....

Rory.



jpff@codemist.co.uk wrote:
> I have a student who is attempting to use the Java API acess to
> Csound, and in particular using the Software Bus to get data in and
> out.  I am not up to speed on the API, and know no Java, but what he
> sems to be saying is that he annot get a-rate data out via the
> GetChannel and SetChannel methods.  i woud appreciate hearing what he
> is doing wrong
> 
> ------- Start of forwarded message -------
> Date: Wed, 12 Jul 2006 15:27:41 +0100
> Subject: Csound Java API - difficulties with a-rate data
> 
> I've been working with the Java API wuth some success, but run into a fairly
> fundamental problem with accessing a-rate data.
> 
> k- and i- rate data are fine, using the chnset and chnget opcodes and named
> (i.e . string indexed) channels. These can be accessed through the API with
> the GetChannel and SetChannel methods of the main Csound class.
> 
> a-rate data must obviously work differently, since the (Get|Set)Channel
> methods have a single return (whereas we need ksmps returns). In any case,
> using something like:
> 
> chnset a1, "output"
> 
> (where a1 is a-rate data which also goes to "out")
> 
> doesn't result in anything being passed to the named channel "output".
> 
> Annoyingly, I can see exactly how this works in the C API, and the Java API
> does have methods for GetOutputBuffer and GetSpout, both of which return an
> opaque type SWIG_p_double, which I assume is a pointer to the first MYFLT
> (of ksmpls MYFLTs) in the output buffer. Unfortunately, I can't see a way to
> access it. Obviously in Java there's no way to just dereference the pointer.
> 
> The only other sensible looking approach is to use the chano opcode. There
> are Java methods (e.g. ChanOAGet) which take a SWIG_p_double (presumably a
> pointer to the channel created with chano) and an integer (I presume an
> index, as in the C function csoundChanOAGet). However, in Java, all I have
> to work with is the function return (in this case an integer, which seems to
> just be zero for a successful call).
> 
> ------- End of forwarded message -------
> 
> ==John ffitch
> 
> 
> -------------------------------------------------------------------------
> 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