Csound Csound-dev Csound-tekno Search About

[Csnd] Naive question about the API

Date2023-01-11 13:39
FromDave Seidel
Subject[Csnd] Naive question about the API
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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

Date2023-01-11 13:50
FromDave Seidel
SubjectRe: [Csnd] Naive question about the API
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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

Date2023-01-11 13:57
FromGiovanni Bedetti
SubjectRe: [Csnd] Naive question about the API
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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

Date2023-01-11 14:01
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Naive question about the API
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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

Date2023-01-11 14:19
FromDave Seidel
SubjectRe: [Csnd] Naive question about the API
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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

Date2023-01-11 14:24
FromDave Seidel
SubjectRe: [Csnd] Naive question about the API
Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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

Date2023-01-11 14:49
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Naive question about the API
I think only Victor would know. I don't think it matters, if it's k-rate, I assume it will be 1 performance cycle for the new value to be picked up.

On Wed, 11 Jan 2023 at 15:25, Dave Seidel <dave.seidel@gmail.com> wrote:
Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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
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

Date2023-01-11 17:04
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Naive question about the API
Those API functions are not used to set Csound global variables, they are used to set C variables/memory in the Csound object. Csound code does not have access to them.

As Giovanni said, the only way to set global variables is via compilation, or through Csound
events (using pfields to instruments), or try chnexport 


You can also use function tables to pass data from and to a host.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Jan 2023, at 14:25, Dave Seidel <dave.seidel@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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

Date2023-01-11 17:10
FromDave Seidel
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Naive question about the API
Aha, thanks for the clarification, Victor.  And thanks Giovanni!

On Wed, Jan 11, 2023 at 12:04 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Those API functions are not used to set Csound global variables, they are used to set C variables/memory in the Csound object. Csound code does not have access to them.

As Giovanni said, the only way to set global variables is via compilation, or through Csound
events (using pfields to instruments), or try chnexport 


You can also use function tables to pass data from and to a host.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Jan 2023, at 14:25, Dave Seidel <dave.seidel@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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
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
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

Date2023-01-11 18:07
FromMichael Gogins
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Naive question about the API
My default for getting control signals into and out of Csound from host software is chnexport. In the Csound orchestra:

gk_Guitar_midi_dynamic_range chnexport "gk_Guitar_midi_dynamic_range", 3 ; 127
gk_Guitar_midi_dynamic_range init 30
gk_Guitar_level chnexport "gk_Guitar_level", 3
gk_Guitar_level init 0
gk_Guitar_space_left_to_right chnexport "gk_Guitar_space_left_to_right", 3
gk_Guitar_space_left_to_right init .5

In the instrument, I simply refer to these global variables. All variables are prefixed with type and instrument name to avoid name collisions.

In the host software (HTML5) there is a kind of generic thing that depends on the global variable, the control channel, and the HTML input element all having exactly the same name:

           $('input').on('input', async function(event) {
                var slider_value = parseFloat(event.target.value);
                if (csound) {
                    csound.SetControlChannel(event.target.id, slider_value);
                }
                var output_selector = '#' + event.target.id + '_output';
                $(output_selector).val(slider_value);
            });
 
I haven't tried sending control signals from Csound to the host software.

Regards,
Mike
-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, Jan 11, 2023 at 12:04 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Those API functions are not used to set Csound global variables, they are used to set C variables/memory in the Csound object. Csound code does not have access to them.

As Giovanni said, the only way to set global variables is via compilation, or through Csound
events (using pfields to instruments), or try chnexport 


You can also use function tables to pass data from and to a host.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Jan 2023, at 14:25, Dave Seidel <dave.seidel@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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
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
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

Date2023-01-11 18:47
FromDave Seidel
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Naive question about the API
Thanks Mike, I like that and may adapt my code to use the technique.

On Wed, Jan 11, 2023 at 1:08 PM Michael Gogins <michael.gogins@gmail.com> wrote:
My default for getting control signals into and out of Csound from host software is chnexport. In the Csound orchestra:

gk_Guitar_midi_dynamic_range chnexport "gk_Guitar_midi_dynamic_range", 3 ; 127
gk_Guitar_midi_dynamic_range init 30
gk_Guitar_level chnexport "gk_Guitar_level", 3
gk_Guitar_level init 0
gk_Guitar_space_left_to_right chnexport "gk_Guitar_space_left_to_right", 3
gk_Guitar_space_left_to_right init .5

In the instrument, I simply refer to these global variables. All variables are prefixed with type and instrument name to avoid name collisions.

In the host software (HTML5) there is a kind of generic thing that depends on the global variable, the control channel, and the HTML input element all having exactly the same name:

           $('input').on('input', async function(event) {
                var slider_value = parseFloat(event.target.value);
                if (csound) {
                    csound.SetControlChannel(event.target.id, slider_value);
                }
                var output_selector = '#' + event.target.id + '_output';
                $(output_selector).val(slider_value);
            });
 
I haven't tried sending control signals from Csound to the host software.

Regards,
Mike
-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, Jan 11, 2023 at 12:04 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Those API functions are not used to set Csound global variables, they are used to set C variables/memory in the Csound object. Csound code does not have access to them.

As Giovanni said, the only way to set global variables is via compilation, or through Csound
events (using pfields to instruments), or try chnexport 


You can also use function tables to pass data from and to a host.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 11 Jan 2023, at 14:25, Dave Seidel <dave.seidel@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

Any thoughts about the performance difference of using globals vs channels, if any?

On Wed, Jan 11, 2023 at 9:19 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks Hlöðver, that looks like exactly what I'd need.

On Wed, Jan 11, 2023 at 9:02 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
You could use either of these two functions
https://github.com/csound/csound/blob/master/include/csound.h#L2420-L2431

csoundQueryGlobalVariable and csoundQueryGlobalVariableNoCheck
I assume you can just set a new float to the pointer returned.

On Wed, 11 Jan 2023 at 14:59, Giovanni Bedetti <giovanni.bedetti@gmail.com> wrote:
I think you can use csoundCompileOrc to create globals (or add instruments, gens) on the fly.
But other instruments that use those globals should be created later otherwise you will have a runtime error.

Il giorno mer 11 gen 2023 alle ore 13:51 Dave Seidel <dave.seidel@gmail.com> ha scritto:
Rationale: I just ported one of my Nebulae customer instruments to work with docB's excellent VCV Rack Csound module. It occurred to me that the Rack module could be a great way to prototype/debug Nebulae code, because it's difficult to do this in the Nebulae environment. The Rack modules uses channels cor controls/inputs vs Nebulae which uses globals. It wou;d be cool to be able to write the same (or more similar) code for both environments.

On Wed, Jan 11, 2023 at 8:39 AM Dave Seidel <dave.seidel@gmail.com> wrote:
Is it possible to set global variables from the API as an alternative to channels? And if so, how do these methods compare in terms of performance?

- Dave

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
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
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
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
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
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
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