| Hi Jacques,
There are some options. The CsoundCallbackWrapper class is generally
used by subclassing it and overriding implementations of things like
MessageCallback, then calling SetMessageCallback to get it to register
with Csound. That wrapper is found in csound6/interfaces/cs_glue.hpp
and hasn't really been touched in a very long time. We could always
add things to it if there is something missing.
That said, if you only want to read values from a channel once in a
while, you could always just use a CsoundMYFLTArray to wrap the
channel, then use GetValue method to read "the current value at this
time". If you did that from a thread that's animating some UI, it
would seem to me to be accurate enough. I don't know the exact
operation you need though or the exact accuracy you're looking for,
but the above at least would be relatively efficient and simple.
steven
On Fri, Nov 29, 2013 at 8:43 AM, Jacques Leplat wrote:
> Hello,
>
> I was wondering if someone could point me in the right direction.
>
> My goal is to implement a type of VU control in Java (Desktop JDK and Android).
>
> In the csd, I can use the max_k opcode to send the max output to a channel on a regular basis:
>
> instr outInstr
> outs gaoutL, gaoutR
> ktrig metro 1 ;refresh 1 times per second
> kvalL max_k gaoutL, ktrig, 1
> kvalR max_k gaoutR, ktrig, 1
> chnset kvalL, "masterL"
> chnset kvalR, "masterR"
> printk2 kvalL
> printk2 kvalR
> gaoutL = 0
> gaoutR = 0
> endin
>
> In the java code, my feeling is it would be more efficient if I were to implement a callback, rather than use performKsmps() in a loop to get the channel values on every iteration: I do not expected to need the max amplitude values more than every 0.25 seconds.
>
> The CsoundCallbackWrapper class has a callback method to override, which looks like the one I need to override to catch channel messages public void OutputValueCallback(String chnName, double value)
>
> I can’t find any way of setting the callback wrapper in Csound. The CsoundCallbackWrapper has several callback wrapper setters (SetMidiOutputCallback(), SetMidiInputCallback(), SetYieldCallback(), SetMessageCallback) but none seem to be there for setting channel callbacks.
>
> Any advice on how I should proceed is more than welcome: how can I register a channel callback wrapper with Csound? Alternatively, should I not worry about polling in a performKsmps() loop?
>
> All the best,
>
> Jacques
>
>
>
>
>
> Send bugs reports to the Sourceforge bug trackers
> csound6:
> https://sourceforge.net/p/csound/tickets/
> csound5:
> https://sourceforge.net/p/csound/bugs/
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>
|