Csound Csound-dev Csound-tekno Search About

Building a Jack Client with the Csound API

Date2016-01-30 18:28
FromJohn DeBlase
SubjectBuilding a Jack Client with the Csound API
Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 18:45
FromVictor Lazzarini
SubjectRe: Building a Jack Client with the Csound API
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 19:31
FromTarmo Johannes
SubjectRe: Building a Jack Client with the Csound API
Hi,

and if you want to connect straight to the physical output use parameters
-odac:system:playback_ -+rtadudio=jack

or you were doing something completely else...

best!
tarmo

2016-01-30 20:45 GMT+02:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 19:31
FromJohn DeBlase
SubjectRe: Building a Jack Client with the Csound API
Hi Victor, thanks for the quick response... using the -+rtaudio=jack flag has been the main way I've been using Csound and is certainly something I'm willing to do with front ends I want to build if I using Python.

However, if I were to use a different language like C++ that's better suited for realtime processing, what would be the way forward in terms of designing the jack client host app in the way I originally outlined? I'm sort of imagining the app being like some kind of Csound server where the client could invoke multiple instances with the outputs being processed/mixed in the host down to a single output buffer which is sent to the jack client...

I'm more or less interested in the technique of how to build something like this and make it work... if it's not in Python than so be it, but I'd like to understand how to get the Csound output and jack output buffer to sync up correctly if it's a possibility.

thanks!
j
 

On Sat, Jan 30, 2016 at 1:45 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 19:34
FromJohn DeBlase
SubjectRe: Building a Jack Client with the Csound API
sorry the above reply I meant "single output buffer to the jack server"... I'm getting my jargon mixed up :)

Tarmo, yes that's exactly how I've been using jack on the Csound side using those flags..

-j

On Sat, Jan 30, 2016 at 2:31 PM, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

and if you want to connect straight to the physical output use parameters
-odac:system:playback_ -+rtadudio=jack

or you were doing something completely else...

best!
tarmo

2016-01-30 20:45 GMT+02:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 19:45
FromVictor Lazzarini
SubjectRe: Building a Jack Client with the Csound API
Multiple instances of Csound can each access jack separately. Unless there is a particular problem with the jack backend that Csound provides, you shouldn't try to reimplement it in your program.

On 30 Jan 2016, at 19:31, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi Victor, thanks for the quick response... using the -+rtaudio=jack flag has been the main way I've been using Csound and is certainly something I'm willing to do with front ends I want to build if I using Python.

However, if I were to use a different language like C++ that's better suited for realtime processing, what would be the way forward in terms of designing the jack client host app in the way I originally outlined? I'm sort of imagining the app being like some kind of Csound server where the client could invoke multiple instances with the outputs being processed/mixed in the host down to a single output buffer which is sent to the jack client...

I'm more or less interested in the technique of how to build something like this and make it work... if it's not in Python than so be it, but I'd like to understand how to get the Csound output and jack output buffer to sync up correctly if it's a possibility.

thanks!
j
 

On Sat, Jan 30, 2016 at 1:45 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 19:54
FromVictor Lazzarini
SubjectRe: Building a Jack Client with the Csound API
I am not sure of the advantage of mixing into a single stream into jack,
but if you want to do this, then you could still use one of the Csound instances as your mixer into jack.

In C++, you have the choice of picking up Csound's output from spout (GetSpout() will give you the pointer to this buffer), which holds ksmps frames, or the output buffer,
whose size is set by -b (GetOutputBuffer()). Spout is filled every time you call PerformKsmps(),
whereas to fill one buffer full of frames, PerformBuffer() is your friend.

Once you get one of these buffer pointers, you can acess the audio samples and send them
anywhere you want. 

On 30 Jan 2016, at 19:34, John DeBlase <bsnacks000@GMAIL.COM> wrote:

sorry the above reply I meant "single output buffer to the jack server"... I'm getting my jargon mixed up :)

Tarmo, yes that's exactly how I've been using jack on the Csound side using those flags..

-j

On Sat, Jan 30, 2016 at 2:31 PM, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

and if you want to connect straight to the physical output use parameters
-odac:system:playback_ -+rtadudio=jack

or you were doing something completely else...

best!
tarmo

2016-01-30 20:45 GMT+02:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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

Date2016-01-30 20:35
FromJohn DeBlase
SubjectRe: Building a Jack Client with the Csound API
Based on what you've described, it sounds like its not advantageous at all... :)

I'll most likely end up using jack on the Csound side like you've said.. I suppose I've been just curious as to how the output buffers really work.. What you've described with the pointers and OutputBuffer makes alot of sense and cleared up some confusion. I'll spend some time experimenting.

Thanks for your help!




On Sat, Jan 30, 2016 at 2:54 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
I am not sure of the advantage of mixing into a single stream into jack,
but if you want to do this, then you could still use one of the Csound instances as your mixer into jack.

In C++, you have the choice of picking up Csound's output from spout (GetSpout() will give you the pointer to this buffer), which holds ksmps frames, or the output buffer,
whose size is set by -b (GetOutputBuffer()). Spout is filled every time you call PerformKsmps(),
whereas to fill one buffer full of frames, PerformBuffer() is your friend.

Once you get one of these buffer pointers, you can acess the audio samples and send them
anywhere you want. 

On 30 Jan 2016, at 19:34, John DeBlase <bsnacks000@GMAIL.COM> wrote:

sorry the above reply I meant "single output buffer to the jack server"... I'm getting my jargon mixed up :)

Tarmo, yes that's exactly how I've been using jack on the Csound side using those flags..

-j

On Sat, Jan 30, 2016 at 2:31 PM, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
Hi,

and if you want to connect straight to the physical output use parameters
-odac:system:playback_ -+rtadudio=jack

or you were doing something completely else...

best!
tarmo

2016-01-30 20:45 GMT+02:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
In my opinion, Python is not well suited to process samples this way.
It is too slow. You'd better off letting Csound put the audio directly to Jack  through its rtjack backend. Then it will be smooth. 

Have a look at the collection of python API examples in github. They
will give you an idea. To plug into jack  all you need is to use -+rtaudio=jack
as an option to Csound

On 30 Jan 2016, at 18:28, John DeBlase <bsnacks000@GMAIL.COM> wrote:

Hi all,

I'm trying to figure out how to send audio output from the API directly to a host jack client application that will playback the audio in realtime. Based on what I read in the API documentation I am assuming that GetSpoutSample() is the method I need since the host app will be a GUI with controls that need to be updated at k-rate.

After some experimenting I've been able to fill two buffers with samples... the Python code I have looks like this.. (note: I didn't include the orc and sco strings)
-----------------------------------------------
c = csnd6.Csound()
c.CompileOrc(orc)
c.ReadScore(sco)

c.Start()
left = []
right = []

while (c.PerformKsmps() == 0):
    for i in range(32):                  # copy all 32 audio samples per k-cycle into buffs
        l.append(c.GetSpoutSample(i,1))
        r.append(c.GetSpoutSample(i,2))

c.Stop()
----------------------------------

So this code fills both buffers with 44100 samples floats for a one second sound (yay!)

The problem is I don't know how to stream or sync these sample buffers to the jack process code correctly. In the PyJack example clients I've seen, the process method is always being read from a buffer of a size that's already been calculated (non-realtime). So in these cases it's trivial... the jack.process() steps through the audio buffer using the jack server's buff size.

But to do this in realtime the left and right buffers are growing like crazy. I'm guessing I would need to implement some kind of ring buffer and just somehow have the jack client read through that? I can't wrap my head around how to make something that syncs up so that samples aren't dropped.

Or maybe I need to get the Csound's output in a different way? Like using the GetOutputBuffer set of methods?

I've also read that maybe in Python this sort of realtime setup would not work because of the thread locking situation... not sure..

Any guidance on how to proceed would be most helpful..

thanks!
john



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