Building a Jack Client with the Csound API
Date | 2016-01-30 18:28 |
From | John DeBlase |
Subject | Building 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.----------------------------------------------- c = csnd6.Csound() c.CompileOrc(orc) c.ReadScore(sco) 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() ---------------------------------- 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.. |
Date | 2016-01-30 18:45 |
From | Victor Lazzarini |
Subject | Re: 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
|
Date | 2016-01-30 19:31 |
From | Tarmo Johannes |
Subject | Re: Building a Jack Client with the Csound API |
Hi, and if you want to connect straight to the physical output use parameters2016-01-30 20:45 GMT+02:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
|
Date | 2016-01-30 19:31 |
From | John DeBlase |
Subject | Re: 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. On Sat, Jan 30, 2016 at 1:45 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2016-01-30 19:34 |
From | John DeBlase |
Subject | Re: 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..On Sat, Jan 30, 2016 at 2:31 PM, Tarmo Johannes <tarmo.johannes@otsakool.edu.ee> wrote:
|
Date | 2016-01-30 19:45 |
From | Victor Lazzarini |
Subject | Re: 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.
|
Date | 2016-01-30 19:54 |
From | Victor Lazzarini |
Subject | Re: 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.
|
Date | 2016-01-30 20:35 |
From | John DeBlase |
Subject | Re: 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! j On Sat, Jan 30, 2016 at 2:54 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|