[Csnd] Naive question about the API
Date | 2023-01-11 13:39 |
From | Dave 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 |
Date | 2023-01-11 13:50 |
From | Dave Seidel |
Subject | Re: [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:
|
Date | 2023-01-11 13:57 |
From | Giovanni Bedetti |
Subject | Re: [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:
|
Date | 2023-01-11 14:01 |
From | Hlöðver Sigurðsson |
Subject | Re: [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:
|
Date | 2023-01-11 14:19 |
From | Dave Seidel |
Subject | Re: [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:
|
Date | 2023-01-11 14:24 |
From | Dave Seidel |
Subject | Re: [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:
|
Date | 2023-01-11 14:49 |
From | Hlöðver Sigurðsson |
Subject | Re: [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:
|
Date | 2023-01-11 17:04 |
From | Victor Lazzarini |
Subject | Re: [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:
|
Date | 2023-01-11 17:10 |
From | Dave Seidel |
Subject | Re: [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:
|
Date | 2023-01-11 18:07 |
From | Michael Gogins |
Subject | Re: [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 GoginsIrreducible 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:
|
Date | 2023-01-11 18:47 |
From | Dave Seidel |
Subject | Re: [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:
|