Csound Csound-dev Csound-tekno Search About

[Csnd] Csound API question

Date2026-10-08 14:00
From"Jeanette C." <000015cdd0ffa6cd-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] Csound API question
Hey hey,
I'd like to run Csound inside a c++ application using its API. Csound should 
communicate only through the host, not directly connecting to any outside 
audio/MIDI I/O. Sample buffer size will be dictated by a host set frame size.

In audio this is possible, on e can pass in sample buffers and read them. But 
how about control channel access? I see that the C function:
csoundSetControlChannel
takes a single value
and
csoundGetControlChannel
returns a single value.

Is there a way to read/write control data at the speed of the control rate in 
such a setup? We can assume that I set the control rate to work well with the 
frame buffer size of the audio.

Or is there another approach, when automating Csound k-rate values when 
running in such a way?

As an example, you can take JACK process callback function, which will process 
a fixed given number of audio samples per call and audio channel.

Any help is very much appreciated.

Best wishes,

Jeanette

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

Date2026-10-08 14:27
FromMichael Gogins
SubjectRe: [Csnd] Csound API question
In Csound 7, CsoundPerformanceThread provides a thread-safe, asynchronous FIFO queue for incoming control commands. The performance thread processes a batch of queued commands before calling csoundPerformKsmps() for each control period. Commands arriving after the current batch has been detached are generally processed in the next cycle. Applications that manage their own performance threads can implement equivalent queues in C++. For outgoing control data, the host can either poll Csound's named channels or else register an output-channel callback to receive values emitted by the outvalue opcode.

Best,
Mike

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


On Thu, Oct 8, 2026 at 2:59 PM Jeanette C. <000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:
Hey hey,
I'd like to run Csound inside a c++ application using its API. Csound should
communicate only through the host, not directly connecting to any outside
audio/MIDI I/O. Sample buffer size will be dictated by a host set frame size.

In audio this is possible, on e can pass in sample buffers and read them. But
how about control channel access? I see that the C function:
csoundSetControlChannel
takes a single value
and
csoundGetControlChannel
returns a single value.

Is there a way to read/write control data at the speed of the control rate in
such a setup? We can assume that I set the control rate to work well with the
frame buffer size of the audio.

Or is there another approach, when automating Csound k-rate values when
running in such a way?

As an example, you can take JACK process callback function, which will process
a fixed given number of audio samples per call and audio channel.

Any help is very much appreciated.

Best wishes,

Jeanette

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

Date2026-10-08 14:34
From"Jeanette C." <000015cdd0ffa6cd-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Csound API question
Thank you Michael! This is helpful. So I might look at the Csound7 API.

Just to be sure though: with Csound6 and that type of setup, I best send one 
control value per host processing callback.

Best wishes,

Jeanette

Michael Gogins, Oct 8 2026:

> In Csound 7, CsoundPerformanceThread provides a thread-safe, asynchronous
> FIFO queue for incoming control commands. The performance thread processes
> a batch of queued commands before calling csoundPerformKsmps() for each
> control period. Commands arriving after the current batch has been detached
> are generally processed in the next cycle. Applications that manage their
> own performance threads can implement equivalent queues in C++. For
> outgoing control data, the host can either poll Csound's named channels or
> else register an output-channel callback to receive values emitted by the
> outvalue opcode.
>
> Best,
> Mike
>
> -----------------------------------------------------
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com
>
>
> On Thu, Oct 8, 2026 at 2:59 PM Jeanette C. <
> 000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:
>
>> Hey hey,
>> I'd like to run Csound inside a c++ application using its API. Csound
>> should
>> communicate only through the host, not directly connecting to any outside
>> audio/MIDI I/O. Sample buffer size will be dictated by a host set frame
>> size.
>>
>> In audio this is possible, on e can pass in sample buffers and read them.
>> But
>> how about control channel access? I see that the C function:
>> csoundSetControlChannel
>> takes a single value
>> and
>> csoundGetControlChannel
>> returns a single value.
>>
>> Is there a way to read/write control data at the speed of the control rate
>> in
>> such a setup? We can assume that I set the control rate to work well with
>> the
>> frame buffer size of the audio.
>>
>> Or is there another approach, when automating Csound k-rate values when
>> running in such a way?
>>
>> As an example, you can take JACK process callback function, which will
>> process
>> a fixed given number of audio samples per call and audio channel.
>>
>> Any help is very much appreciated.
>>
>> Best wishes,
>>
>> Jeanette
>>
>> --
>>   * PeerTube: https://makertube.net/@jeanette_c
>>   * GitHub: https://github.com/jeanette-c
>>   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>>
>> 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
>

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

Date2026-10-08 15:32
FromMichael Gogins
SubjectRe: [Csnd] Csound API question
No, you also use CsoundPerfirmanceThread with Csound 6, but it's in a separate library. Now it's in the main Csound library. 

Best, Mike


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

On Thu, Oct 8, 2026, 15:33 Jeanette C. <000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:
Thank you Michael! This is helpful. So I might look at the Csound7 API.

Just to be sure though: with Csound6 and that type of setup, I best send one
control value per host processing callback.

Best wishes,

Jeanette

Michael Gogins, Oct 8 2026:

> In Csound 7, CsoundPerformanceThread provides a thread-safe, asynchronous
> FIFO queue for incoming control commands. The performance thread processes
> a batch of queued commands before calling csoundPerformKsmps() for each
> control period. Commands arriving after the current batch has been detached
> are generally processed in the next cycle. Applications that manage their
> own performance threads can implement equivalent queues in C++. For
> outgoing control data, the host can either poll Csound's named channels or
> else register an output-channel callback to receive values emitted by the
> outvalue opcode.
>
> Best,
> Mike
>
> -----------------------------------------------------
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com
>
>
> On Thu, Oct 8, 2026 at 2:59 PM Jeanette C. <
> 000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:
>
>> Hey hey,
>> I'd like to run Csound inside a c++ application using its API. Csound
>> should
>> communicate only through the host, not directly connecting to any outside
>> audio/MIDI I/O. Sample buffer size will be dictated by a host set frame
>> size.
>>
>> In audio this is possible, on e can pass in sample buffers and read them.
>> But
>> how about control channel access? I see that the C function:
>> csoundSetControlChannel
>> takes a single value
>> and
>> csoundGetControlChannel
>> returns a single value.
>>
>> Is there a way to read/write control data at the speed of the control rate
>> in
>> such a setup? We can assume that I set the control rate to work well with
>> the
>> frame buffer size of the audio.
>>
>> Or is there another approach, when automating Csound k-rate values when
>> running in such a way?
>>
>> As an example, you can take JACK process callback function, which will
>> process
>> a fixed given number of audio samples per call and audio channel.
>>
>> Any help is very much appreciated.
>>
>> Best wishes,
>>
>> Jeanette
>>
>> --
>>   * PeerTube: https://makertube.net/@jeanette_c
>>   * GitHub: https://github.com/jeanette-c
>>   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>>
>> 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
>

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

Date2026-10-08 16:43
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Csound API question
First step is to study the C++ examples in the repo


they will give you a good idea of what you need to do for various use cases.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 8 Oct 2026, at 14:00, Jeanette C. <000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:

Hey hey,
I'd like to run Csound inside a c++ application using its API. Csound should communicate only through the host, not directly connecting to any outside audio/MIDI I/O. Sample buffer size will be dictated by a host set frame size.

In audio this is possible, on e can pass in sample buffers and read them. But how about control channel access? I see that the C function:
csoundSetControlChannel
takes a single value
and
csoundGetControlChannel
returns a single value.

Is there a way to read/write control data at the speed of the control rate in such a setup? We can assume that I set the control rate to work well with the frame buffer size of the audio.

Or is there another approach, when automating Csound k-rate values when running in such a way?

As an example, you can take JACK process callback function, which will process a fixed given number of audio samples per call and audio channel.

Any help is very much appreciated.

Best wishes,

Jeanette

--
* PeerTube: https://makertube.net/@jeanette_c
* GitHub: https://github.com/jeanette-c
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

The information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.

Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.

Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.

Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.

Registered charity number 20037130

 


Date2026-10-09 18:02
FromIain Duncan
SubjectRe: [Csnd] Csound API question
If you want another example, you might find the code for the Csound6~ object in Max useful. It's a port of Victor's PD object with a bunch of extra bells and whistles, including control channel IO with Max. It's all done in plain C. I plan to update it when Csound7 is fully released.


iain




On Thu, Oct 8, 2026 at 8:43 AM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
First step is to study the C++ examples in the repo


they will give you a good idea of what you need to do for various use cases.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 8 Oct 2026, at 14:00, Jeanette C. <000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:

Hey hey,
I'd like to run Csound inside a c++ application using its API. Csound should communicate only through the host, not directly connecting to any outside audio/MIDI I/O. Sample buffer size will be dictated by a host set frame size.

In audio this is possible, on e can pass in sample buffers and read them. But how about control channel access? I see that the C function:
csoundSetControlChannel
takes a single value
and
csoundGetControlChannel
returns a single value.

Is there a way to read/write control data at the speed of the control rate in such a setup? We can assume that I set the control rate to work well with the frame buffer size of the audio.

Or is there another approach, when automating Csound k-rate values when running in such a way?

As an example, you can take JACK process callback function, which will process a fixed given number of audio samples per call and audio channel.

Any help is very much appreciated.

Best wishes,

Jeanette

--
* PeerTube: https://makertube.net/@jeanette_c
* GitHub: https://github.com/jeanette-c
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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

The information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.

Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.

Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.

Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.

Registered charity number 20037130

 

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


--
Iain Duncan
Interdisciplinary PhD Candidate, Computer Science & Music
University of Victoria, Canada
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

Date2026-10-09 22:26
From"Jeanette C." <000015cdd0ffa6cd-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Csound API question
Hello Iain,
thank you for that suggestion. I downloaded the sources and am looking at 
them. I think this might prove helpful in my undertaking. It will become 
clearer in time.

Best wishes,

Jeanette

Iain Duncan, Oct 9 2026:

> If you want another example, you might find the code for the Csound6~
> object in Max useful. It's a port of Victor's PD object with a bunch of
> extra bells and whistles, including control channel IO with Max. It's all
> done in plain C. I plan to update it when Csound7 is fully released.
>
> https://github.com/iainctduncan/csound_max
>
> iain
>
>
>
>
> On Thu, Oct 8, 2026 at 8:43 AM Victor Lazzarini <
> 000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
>
>> First step is to study the C++ examples in the repo
>>
>> https://github.com/csound/csoundAPI_examples
>>
>> they will give you a good idea of what you need to do for various use
>> cases.
>>
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>>
>> On 8 Oct 2026, at 14:00, Jeanette C. <
>> 000015cdd0ffa6cd-dmarc-request@listserv.heanet.ie> wrote:
>>
>> Hey hey,
>> I'd like to run Csound inside a c++ application using its API. Csound
>> should communicate only through the host, not directly connecting to any
>> outside audio/MIDI I/O. Sample buffer size will be dictated by a host set
>> frame size.
>>
>> In audio this is possible, on e can pass in sample buffers and read them.
>> But how about control channel access? I see that the C function:
>> csoundSetControlChannel
>> takes a single value
>> and
>> csoundGetControlChannel
>> returns a single value.
>>
>> Is there a way to read/write control data at the speed of the control rate
>> in such a setup? We can assume that I set the control rate to work well
>> with the frame buffer size of the audio.
>>
>> Or is there another approach, when automating Csound k-rate values when
>> running in such a way?
>>
>> As an example, you can take JACK process callback function, which will
>> process a fixed given number of audio samples per call and audio channel.
>>
>> Any help is very much appreciated.
>>
>> Best wishes,
>>
>> Jeanette
>>
>> --
>> * PeerTube: https://makertube.net/@jeanette_c
>> * GitHub: https://github.com/jeanette-c
>> * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>>
>> 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
>>
>> The information contained in this email may be confidential and
>> privileged. It is intended only for the addressee(s) stated above. If you
>> are not an addressee any use, dissemination, distribution, publication or
>> copying of the information contained in this email is strictly prohibited.
>> If you have received this email in error, please immediately notify us by
>> email at dataprotection@mu.ie and delete this email from your system.
>>
>> Please note that Maynooth University is subject to Freedom of Information
>> and Data Protection laws. We may be required to disclose the content of
>> emails under the* FOI Act 2014*, the* Data Protection Act 2018* or *GDPR*.
>>
>> Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo.
>> D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura
>> seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a
>> scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an
>> ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí
>> ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost
>> seo ó do chóras.
>>
>> Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um
>> Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith
>> orainn ábhar ríomhphoist a nochtadh faoin *Acht um Shaoráil Faisnéise
>> 2014*, faoin *Acht um Chosaint Sonraí 2018* nó faoi *GDPR*.
>>
>> Registered charity number 20037130
>>
>>
>> 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
>
>
>
> -- 
> Iain Duncan
> Interdisciplinary PhD Candidate, Computer Science & Music
> University of Victoria, Canada
>
> 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
>

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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