| I found csnd.csnd.csoundGetChannelPtr() and it looks like it will take
in a double pointer. I had only looked at the Csound class up until
now. It looks like you can use it by doing:
csnd.csnd.csoundGetChannelPtr(csound.getCsound(), channel.getPtr(), ...);
where csound is a Csound object. I haven't tried it, but my guess is
that it should work. Nice find!
This looks like a viable workaround, though it would be nice to find a
way to get it working with the Csound object too.
On Tue, Feb 9, 2010 at 4:31 PM, Victor Lazzarini
wrote:
> But, the Csound class has a different definition:
>
> virtual int GetChannelPtr(MYFLT* &p, const char *name, int type)
> {
> MYFLT *tmp;
> int retval;
> retval = csoundGetChannelPtr(csound, &tmp, name, type);
> p = tmp;
> return retval;
> }
>
> using a reference. I guess it becomes a MYFLT ** in Python, but not
> in Java.
>
> Is there a csoundGetChannelPtr() function in the Java wrapper? That
> should
> match.
>
> Another solution, easier; use floatArray or doubleArray
>
> >>> a = csnd.floatArray(10)
> >>> a.cast()
>
>
> This should do the trick.
>
> Victor
>
>
>
> On 9 Feb 2010, at 21:21, Victor Lazzarini wrote:
>
>> I tested alright. Note this:
>>
>>>>> import csnd
>>>>> a = csnd.CsoundMYFLTArray(10)
>>>>> a.GetPtr()
>>
>>>>>
>>
>> and
>>
>> PUBLIC int csoundGetChannelPtr(CSOUND *,
>> MYFLT **p, const char *name, int
>> type);
>>
>> so, the two should go together alright. I'm not sure why the Java
>> wrapper is different, since it comes from the same C (or C++) code.
>>
>> Victor
>>
>>
>>
>> On 9 Feb 2010, at 20:37, Michael Gogins wrote:
>>
>>> Well, that's why I thought it didn't work.
>>>
>>> I wonder if Victor tested his example!
>>>
>>> It is quite possible that there is a significant difference between
>>> what the SWIG code generator does for Java and what it does for
>>> Python.
>>>
>>> In any event, the code should be easier to use, although perhaps not
>>> quite as efficient.
>>>
>>> Regards,
>>> Mike
>>>
>>> On Tue, Feb 9, 2010 at 3:28 PM, Steven Yi wrote:
>>>> I just took a quick look, the CsoundMYFLTArray.getPtr() returns a
>>>> SWIGTYPE_P_P_double while csound.getChannelPtr() is expecting an arg
>>>> of SWIGTYPE_P_double. Might be an difference between python and
>>>> java
>>>> bindings.
>>>>
>>>> On Tue, Feb 9, 2010 at 3:18 PM, Victor Lazzarini
>>>> wrote:
>>>>> Actually, it's possible to access "named" channels too, through
>>>>> Python. So it should be possible in Java too. Can't see what the
>>>>> fuss
>>>>> was all about then, can you?
>>>>>
>>>>> Here's the code.
>>>>> =============
>>>>> from csnd import *
>>>>> from pylab import *
>>>>>
>>>>> cs = Csound()
>>>>> res = cs.Compile("sine.csd", "-n")
>>>>> ksmps = cs.GetKsmps()
>>>>> channel = CsoundMYFLTArray(ksmps);
>>>>>
>>>>> a = []
>>>>> while(res==0):
>>>>> res = cs.PerformKsmps()
>>>>> cs.GetChannelPtr(channel.GetPtr(), "out", CSOUND_AUDIO_CHANNEL |
>>>>> CSOUND_OUTPUT_CHANNEL)
>>>>> for i in range(0, ksmps):
>>>>> a.append(channel.GetValue(i))
>>>>>
>>>>> t = arange(len(a))
>>>>>
>>>>> plot(t[0:100]/cs.GetSr(), a[0:100])
>>>>> show()
>>>>> ===============================
>>>>>
>>>>> A similar code should be possible in Java.
>>>>>
>>>>> Victor
>>>>>
>>>>>
>>>>> On 9 Feb 2010, at 19:41, Victor Lazzarini wrote:
>>>>>
>>>>>> It seems possible to get a numbered channel (rather than a named
>>>>>> one).
>>>>>> I''l prepare an example.
>>>>>>
>>>>>> Victor
>>>>>> On 9 Feb 2010, at 18:34, Michael Gogins wrote:
>>>>>>
>>>>>>> You could ready access spout from Java. Peter Brinkmann's
>>>>>>> jReality
>>>>>>> package has code for doing it that he developed with my help.
>>>>>>> But you
>>>>>>> couldn't (as far as I know) access bus channels from SWIG
>>>>>>> wrappers.
>>>>>>>
>>>>>>> However, the current code DOES have code, by me, for setting
>>>>>>> individual samples in spout, reading individual samples from
>>>>>>> spin,
>>>>>>> and
>>>>>>> accessing individual samples from numbered bus channels. This
>>>>>>> code
>>>>>>> evidently compiles on all platforms since nobody has complained
>>>>>>> about
>>>>>>> it, but it has not yet been tested (as far as I know).
>>>>>>>
>>>>>>> It might well work. Let us know what happens if you try it.
>>>>>>>
>>>>>>> Obviously, you would need a complete SWIG cleanup and rebuild to
>>>>>>> see
>>>>>>> these functions in the wrappers. You can get the API docs just by
>>>>>>> running doxygen in the Csound root directory.
>>>>>>>
>>>>>>> Regards,
>>>>>>> Mike
>>>>>>>
>>>>>>> On Tue, Feb 9, 2010 at 1:14 PM, Victor Lazzarini
>>>>>>> wrote:
>>>>>>>> But can you explain why there seem to have been a problem in
>>>>>>>> doing
>>>>>>>> this from
>>>>>>>> Java?
>>>>>>>>
>>>>>>>> Victor
>>>>>>>> On 9 Feb 2010, at 18:03, Michael Gogins wrote:
>>>>>>>>
>>>>>>>>> As a matter of fact, it is possible to access spout using the
>>>>>>>>> existing
>>>>>>>>> API, but it is not obvious or convenient.
>>>>>>>>>
>>>>>>>>> I have promised to implement convenient, obvious samplewise
>>>>>>>>> access
>>>>>>>>> to
>>>>>>>>> spin, spout, and numbered channels. I got distracted... I may
>>>>>>>>> actually
>>>>>>>>> have done this... I will check and see how far along I got, and
>>>>>>>>> finish
>>>>>>>>> the work if it needs to be finished.
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>> Mike
>>>>>>>>>
>>>>>>>>> On Tue, Feb 9, 2010 at 12:57 PM, Victor Lazzarini
>>>>>>>>> wrote:
>>>>>>>>>> Dear all,
>>>>>>>>>>
>>>>>>>>>> about half a year ago, there was some complaint that the
>>>>>>>>>> access to
>>>>>>>>>> spout/spin etc is not possible from a wrapped language. This
>>>>>>>>>> seemed
>>>>>>>>>> to
>>>>>>>>>> have been demonstrated in Java.
>>>>>>>>>>
>>>>>>>>>> Now, I am not sure about the specific case of Java, but I knew
>>>>>>>>>> this
>>>>>>>>>> was possible in Python. At the time, I did not have the
>>>>>>>>>> chance to
>>>>>>>>>> test
>>>>>>>>>> it and show how it's done. Mike Gogins offered to add API
>>>>>>>>>> functions
>>>>>>>>>> to
>>>>>>>>>> facilitate this, but I had the impression this was not needed
>>>>>>>>>> (although desirable).
>>>>>>>>>>
>>>>>>>>>> I just had some moments today to look into this question.
>>>>>>>>>> Here's a
>>>>>>>>>> script that demonstrates access to spout. I thought I'd post
>>>>>>>>>> it
>>>>>>>>>> here
>>>>>>>>>> so it can be searched if anyone wants to attempt it.
>>>>>>>>>>
>>>>>>>>>> ======
>>>>>>>>>> from csnd import *
>>>>>>>>>> from pylab import *
>>>>>>>>>>
>>>>>>>>>> cs = Csound()
>>>>>>>>>> res = cs.Compile("sine.csd", "-n")
>>>>>>>>>> spoutlen = cs.GetKsmps()*cs.GetNchnls()
>>>>>>>>>> spout = CsoundMYFLTArray();
>>>>>>>>>> spout.SetPtr(cs.GetSpout())
>>>>>>>>>>
>>>>>>>>>> a = []
>>>>>>>>>> while(res==0):
>>>>>>>>>> res = cs.PerformKsmps()
>>>>>>>>>> for i in range(0, spoutlen):
>>>>>>>>>> a.append(spout.GetValue(i))
>>>>>>>>>>
>>>>>>>>>> t = arange(len(a))
>>>>>>>>>>
>>>>>>>>>> plot(t[0:100]/cs.GetSr(), a[0:100])
>>>>>>>>>> show()
>>>>>>>>>>
>>>>>>>>>> ========
>>>>>>>>>> and we get a nice signal plot.
>>>>>>>>>>
>>>>>>>>>> Now why a similar code is not possible in Java escapes me.
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> Victor
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>>>> colocation
>>>>>>>>>> Stay online with enterprise data centers and the best network
>>>>>>>>>> in
>>>>>>>>>> the business
>>>>>>>>>> Choose flexible plans and management services without long-
>>>>>>>>>> term
>>>>>>>>>> contracts
>>>>>>>>>> Personal 24x7 support from experience hosting pros just a
>>>>>>>>>> phone
>>>>>>>>>> call away.
>>>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Csound-devel mailing list
>>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Michael Gogins
>>>>>>>>> Irreducible Productions
>>>>>>>>> http://www.michael-gogins.com
>>>>>>>>> Michael dot Gogins at gmail dot com
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>>> colocation
>>>>>>>>> Stay online with enterprise data centers and the best network
>>>>>>>>> in
>>>>>>>>> the
>>>>>>>>> business
>>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>>> contracts
>>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>>> call
>>>>>>>>> away.
>>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>>> colocation
>>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>>> the business
>>>>>>>> Choose flexible plans and management services without long-term
>>>>>>>> contracts
>>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>>> call away.
>>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Michael Gogins
>>>>>>> Irreducible Productions
>>>>>>> http://www.michael-gogins.com
>>>>>>> Michael dot Gogins at gmail dot com
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> The Planet: dedicated and managed hosting, cloud storage,
>>>>>>> colocation
>>>>>>> Stay online with enterprise data centers and the best network in
>>>>>>> the
>>>>>>> business
>>>>>>> Choose flexible plans and management services without long-term
>>>>>>> contracts
>>>>>>> Personal 24x7 support from experience hosting pros just a phone
>>>>>>> call
>>>>>>> away.
>>>>>>> http://p.sf.net/sfu/theplanet-com
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> SOLARIS 10 is the OS for Data Centers - provides features such as
>>>>>> DTrace,
>>>>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>>>>> http://p.sf.net/sfu/solaris-dev2dev
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> SOLARIS 10 is the OS for Data Centers - provides features such as
>>>>> DTrace,
>>>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>>>> http://p.sf.net/sfu/solaris-dev2dev
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> SOLARIS 10 is the OS for Data Centers - provides features such as
>>>> DTrace,
>>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>>> http://p.sf.net/sfu/solaris-dev2dev
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>>
>>> --
>>> Michael Gogins
>>> Irreducible Productions
>>> http://www.michael-gogins.com
>>> Michael dot Gogins at gmail dot com
>>>
>>> ------------------------------------------------------------------------------
>>> SOLARIS 10 is the OS for Data Centers - provides features such as
>>> DTrace,
>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>> http://p.sf.net/sfu/solaris-dev2dev
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> SOLARIS 10 is the OS for Data Centers - provides features such as
>> DTrace,
>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>> http://p.sf.net/sfu/solaris-dev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |