Csound Csound-dev Csound-tekno Search About

[Csnd] WASM setOutputChannelCallback

Date2022-11-13 15:21
FromRichard Knight
Subject[Csnd] WASM setOutputChannelCallback
Is/will the equivalent of csoundSetOutputChannelCallback be available in 
Csound WASM?
I have had a look through the documentation and a bit of a search 
through what is readable in the source/interface, but can't find 
reference to this function.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-11-17 19:01
FromRichard Knight
Subject[Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback
Hi
Does anyone here know/can help with this?
Hoping to use csoundSetOutputChannelCallback in Csound WASM but doesn't 
appear to be implemented, wondering if I may have missed something, or 
it may be planned for the future (or not possible for some reason)?

thanks
Richard


-------- Original Message --------
Subject: [Csnd] WASM setOutputChannelCallback
Date: 2022-11-13 15:21
 From: Richard Knight 
To: CSOUND@LISTSERV.HEANET.IE
Reply-To: A discussion list for users of Csound 


Is/will the equivalent of csoundSetOutputChannelCallback be available in 
Csound WASM?
I have had a look through the documentation and a bit of a search 
through what is readable in the source/interface, but can't find 
reference to this function.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-11-17 21:03
FromHlöðver Sigurðsson
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback
it's not there, the callback is called in c-land and the user would need to pass a js function. That is possible, but given that csound runs inside a worker, I don't think you can pass a function to worker threads. What use case are you missing from the outputChannelCallback?

On Thu, 17 Nov 2022 at 20:01, Richard Knight <richard@1bpm.net> wrote:
Hi
Does anyone here know/can help with this?
Hoping to use csoundSetOutputChannelCallback in Csound WASM but doesn't
appear to be implemented, wondering if I may have missed something, or
it may be planned for the future (or not possible for some reason)?

thanks
Richard


-------- Original Message --------
Subject: [Csnd] WASM setOutputChannelCallback
Date: 2022-11-13 15:21
 From: Richard Knight <richard@1BPM.NET>
To: CSOUND@LISTSERV.HEANET.IE
Reply-To: A discussion list for users of Csound
<CSOUND@LISTSERV.HEANET.IE>

Is/will the equivalent of csoundSetOutputChannelCallback be available in
Csound WASM?
I have had a look through the documentation and a bit of a search
through what is readable in the source/interface, but can't find
reference to this function.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-11-17 23:30
FromRichard Knight
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback

Ah OK, thanks.

I typically use it for a sort of callback approach often with ctcsound, usually passing a JSON formatted string from an instrument back to the host.
For example, the host invokes an instrument to perform some work/actions such as create a number of ftables and/or set global array values, and an ID is passed to the instrument. The host retains the ID and a callback function associated with it. When the instrument has completed it's work, the instrument uses outvalue() to send the ID along with results (eg ftable numbers created and array values etc) back to the host, which then executes the relevant callback function on the returned data.
Another similar case is where I have a kind of queue instrument which is fed a string with directives- the instrument waits for a trigger, then executes the directives with evalstr() and then uses outvalue() to notify the host that the actions have completed.

 

I suppose as a workaround for these, I could set a string channel and have the host periodically check if that's changed, or combine that with another k-rate channel as a trigger to inform the host that the string channel has changed / should be read (possibly may be less intensive than periodically checking if a string channel has changed).


On 2022-11-17 21:03, Hlöðver Sigurðsson wrote:

it's not there, the callback is called in c-land and the user would need to pass a js function. That is possible, but given that csound runs inside a worker, I don't think you can pass a function to worker threads. What use case are you missing from the outputChannelCallback?

On Thu, 17 Nov 2022 at 20:01, Richard Knight <richard@1bpm.net> wrote:
Hi
Does anyone here know/can help with this?
Hoping to use csoundSetOutputChannelCallback in Csound WASM but doesn't
appear to be implemented, wondering if I may have missed something, or
it may be planned for the future (or not possible for some reason)?

thanks
Richard


-------- Original Message --------
Subject: [Csnd] WASM setOutputChannelCallback
Date: 2022-11-13 15:21
 From: Richard Knight <richard@1BPM.NET>
To: CSOUND@LISTSERV.HEANET.IE
Reply-To: A discussion list for users of Csound
<CSOUND@LISTSERV.HEANET.IE>

Is/will the equivalent of csoundSetOutputChannelCallback be available in
Csound WASM?
I have had a look through the documentation and a bit of a search
through what is readable in the source/interface, but can't find
reference to this function.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-11-18 14:20
FromHlöðver Sigurðsson
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback
I could look into sending a signal from the worker to the main thread when this is called and allow the user to send a function pointer that will be called in javascript from the main thread. I just wonder if this will fit with the callback arguments passed, if any. I will take a look.

On Fri, 18 Nov 2022 at 00:30, Richard Knight <richard@1bpm.net> wrote:

Ah OK, thanks.

I typically use it for a sort of callback approach often with ctcsound, usually passing a JSON formatted string from an instrument back to the host.
For example, the host invokes an instrument to perform some work/actions such as create a number of ftables and/or set global array values, and an ID is passed to the instrument. The host retains the ID and a callback function associated with it. When the instrument has completed it's work, the instrument uses outvalue() to send the ID along with results (eg ftable numbers created and array values etc) back to the host, which then executes the relevant callback function on the returned data.
Another similar case is where I have a kind of queue instrument which is fed a string with directives- the instrument waits for a trigger, then executes the directives with evalstr() and then uses outvalue() to notify the host that the actions have completed.

 

I suppose as a workaround for these, I could set a string channel and have the host periodically check if that's changed, or combine that with another k-rate channel as a trigger to inform the host that the string channel has changed / should be read (possibly may be less intensive than periodically checking if a string channel has changed).


On 2022-11-17 21:03, Hlöðver Sigurðsson wrote:

it's not there, the callback is called in c-land and the user would need to pass a js function. That is possible, but given that csound runs inside a worker, I don't think you can pass a function to worker threads. What use case are you missing from the outputChannelCallback?

On Thu, 17 Nov 2022 at 20:01, Richard Knight <richard@1bpm.net> wrote:
Hi
Does anyone here know/can help with this?
Hoping to use csoundSetOutputChannelCallback in Csound WASM but doesn't
appear to be implemented, wondering if I may have missed something, or
it may be planned for the future (or not possible for some reason)?

thanks
Richard


-------- Original Message --------
Subject: [Csnd] WASM setOutputChannelCallback
Date: 2022-11-13 15:21
 From: Richard Knight <richard@1BPM.NET>
To: CSOUND@LISTSERV.HEANET.IE
Reply-To: A discussion list for users of Csound
<CSOUND@LISTSERV.HEANET.IE>

Is/will the equivalent of csoundSetOutputChannelCallback be available in
Csound WASM?
I have had a look through the documentation and a bit of a search
through what is readable in the source/interface, but can't find
reference to this function.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-11-19 15:08
FromRichard Knight
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback

Sounds like an good idea, I'll be interested to hear if it seems feasible. I'll see how possible the workarounds I mentioned and other approaches may be while porting my stuff from ctcsound to WASM.

 


On 2022-11-18 14:20, Hlöðver Sigurðsson wrote:

I could look into sending a signal from the worker to the main thread when this is called and allow the user to send a function pointer that will be called in javascript from the main thread. I just wonder if this will fit with the callback arguments passed, if any. I will take a look.

Date2022-11-19 23:16
FromHlöðver Sigurðsson
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback
are you thinking to port stuff to the browser or run ctcsound with a python wasm interpreter?

On Sat, 19 Nov 2022 at 16:13, Richard Knight <richard@1bpm.net> wrote:

Sounds like an good idea, I'll be interested to hear if it seems feasible. I'll see how possible the workarounds I mentioned and other approaches may be while porting my stuff from ctcsound to WASM.

 


On 2022-11-18 14:20, Hlöðver Sigurðsson wrote:

I could look into sending a signal from the worker to the main thread when this is called and allow the user to send a function pointer that will be called in javascript from the main thread. I just wonder if this will fit with the callback arguments passed, if any. I will take a look.

Date2022-11-20 13:57
FromRichard Knight
SubjectRe: [Csnd-dev] Fwd: [Csnd] WASM setOutputChannelCallback

Ah I just mean move my Csound files to the browser and try alternatives to the reliance on outvalue/setOutputChannelCallback.
Running ctcsound with a wasm interpreter didn't cross my mind, it sounds ambitious!

 


On 2022-11-19 23:16, Hlöðver Sigurðsson wrote:

are you thinking to port stuff to the browser or run ctcsound with a python wasm interpreter?

On Sat, 19 Nov 2022 at 16:13, Richard Knight <richard@1bpm.net> wrote:

Sounds like an good idea, I'll be interested to hear if it seems feasible. I'll see how possible the workarounds I mentioned and other approaches may be while porting my stuff from ctcsound to WASM.

 


On 2022-11-18 14:20, Hlöðver Sigurðsson wrote:

I could look into sending a signal from the worker to the main thread when this is called and allow the user to send a function pointer that will be called in javascript from the main thread. I just wonder if this will fit with the callback arguments passed, if any. I will take a look.