Csound Csound-dev Csound-tekno Search About

[Cs-dev] Multiple Csound API performances running in parallel

Date2015-08-11 18:04
FromPeter Burgess
Subject[Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  
Hi there, I am trying to get two instances of Csound to perform at the same time, using the C++ API. So far, I am using two performance threads, one for each Csound instance, and "pressing play" on each of them. As I expected might happpen, the results are messy. Not totally out of whack, but a bit jumpy. I'm not convinced the performance threads are actually designed for this task anyway, but it's the only function I can find that sounds like it fits the bill. My code (minus the score gens) looks something like this:

    //create multiple instances of Csound
    Csound* csound = new Csound();
    Csound* csoundBass = new Csound();

    //compile csd
    csound->Compile("CSD/test.csd");
    csoundBass->Compile("CSD/bass.csd");

    //set up CsoundPerfThread object
    CsoundPerformanceThread* perfThread = new CsoundPerformanceThread(csound);
    CsoundPerformanceThread* perfThreadBass = new CsoundPerformanceThread(csoundBass);

    //start Csound performance
    perfThread->Play();
    perfThreadBass->Play();

    csound->Perform();
    csoundBass->Perform();

    //free Csound and thread objects
    delete csound, perfThread;
    delete csoundBass, perfThreadBass;

    return 0;

I have a few different options to explore to achieve what I want from this (ie, there are ways of doing what I want without performing multiple Csounds instances at once) but I want to explore all possibilities to decide which works best.

Any ideas how best to achieve this? Cheers in advance!

Pete



Date2015-08-11 18:36
FromMichael Gogins
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

Did I miss part of this? Why do you need two performance threads?

Regards,
Mike

On Aug 11, 2015 1:05 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:
Hi there, I am trying to get two instances of Csound to perform at the same time, using the C++ API. So far, I am using two performance threads, one for each Csound instance, and "pressing play" on each of them. As I expected might happpen, the results are messy. Not totally out of whack, but a bit jumpy. I'm not convinced the performance threads are actually designed for this task anyway, but it's the only function I can find that sounds like it fits the bill. My code (minus the score gens) looks something like this:

    //create multiple instances of Csound
    Csound* csound = new Csound();
    Csound* csoundBass = new Csound();

    //compile csd
    csound->Compile("CSD/test.csd");
    csoundBass->Compile("CSD/bass.csd");

    //set up CsoundPerfThread object
    CsoundPerformanceThread* perfThread = new CsoundPerformanceThread(csound);
    CsoundPerformanceThread* perfThreadBass = new CsoundPerformanceThread(csoundBass);

    //start Csound performance
    perfThread->Play();
    perfThreadBass->Play();

    csound->Perform();
    csoundBass->Perform();

    //free Csound and thread objects
    delete csound, perfThread;
    delete csoundBass, perfThreadBass;

    return 0;

I have a few different options to explore to achieve what I want from this (ie, there are ways of doing what I want without performing multiple Csounds instances at once) but I want to explore all possibilities to decide which works best.

Any ideas how best to achieve this? Cheers in advance!

Pete



------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-11 18:43
FromPeter Burgess
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

It's possible I don't. I tried just playing 2 instances of csound without any performance threads and only 1 seemed to play, so I added in the performance threads and both played, but with slight jitter. I'm not sure I actually want performance threads to do this as I'm not trying to control any parameters, but I'm not sure what to use instead


Date2015-08-11 18:48
FromMichael Gogins
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

Sorry wrong question. Why do you need two instances of csound running in the same process at the same time?

Regards,
Mile

On Aug 11, 2015 1:44 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

It's possible I don't. I tried just playing 2 instances of csound without any performance threads and only 1 seemed to play, so I added in the performance threads and both played, but with slight jitter. I'm not sure I actually want performance threads to do this as I'm not trying to control any parameters, but I'm not sure what to use instead


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-11 18:54
FromPeter Burgess
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  
I want access to a great many instruments, more than the allowed 99 per orchestra. I am therefore going to have multiple .csd files, possible containing different types of instruments or something, and I'm trying to work out the best way of utilizing this. One of my ideas to get around this is to play multiple instances of csound at once, though that's probably not ideal for tight syncronisity and might be heavier on the cpu than I would ideally like

On Tue, Aug 11, 2015 at 6:48 PM, Michael Gogins <michael.gogins@gmail.com> wrote:

Sorry wrong question. Why do you need two instances of csound running in the same process at the same time?

Regards,
Mile

On Aug 11, 2015 1:44 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

It's possible I don't. I tried just playing 2 instances of csound without any performance threads and only 1 seemed to play, so I added in the performance threads and both played, but with slight jitter. I'm not sure I actually want performance threads to do this as I'm not trying to control any parameters, but I'm not sure what to use instead


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel



Date2015-08-11 19:08
FromMichael Gogins
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

More than 99 all playing at the same time? Or just a bank of many that the user can select for performance?

Regards,
Mike

On Aug 11, 2015 1:55 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:
I want access to a great many instruments, more than the allowed 99 per orchestra. I am therefore going to have multiple .csd files, possible containing different types of instruments or something, and I'm trying to work out the best way of utilizing this. One of my ideas to get around this is to play multiple instances of csound at once, though that's probably not ideal for tight syncronisity and might be heavier on the cpu than I would ideally like

On Tue, Aug 11, 2015 at 6:48 PM, Michael Gogins <michael.gogins@gmail.com> wrote:

Sorry wrong question. Why do you need two instances of csound running in the same process at the same time?

Regards,
Mile

On Aug 11, 2015 1:44 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

It's possible I don't. I tried just playing 2 instances of csound without any performance threads and only 1 seemed to play, so I added in the performance threads and both played, but with slight jitter. I'm not sure I actually want performance threads to do this as I'm not trying to control any parameters, but I'm not sure what to use instead


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel



------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-11 19:11
FromPeter Burgess
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

A bank of many.


Date2015-08-11 19:11
FromOeyvind Brandtsegg
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

Oh, is there a limit? No?

11. aug. 2015 19.55 skrev "Peter Burgess" <pete.soundtechnician@gmail.com>:
I want access to a great many instruments, more than the allowed 99 per orchestra. I am therefore going to have multiple .csd files, possible containing different types of instruments or something, and I'm trying to work out the best way of utilizing this. One of my ideas to get around this is to play multiple instances of csound at once, though that's probably not ideal for tight syncronisity and might be heavier on the cpu than I would ideally like

On Tue, Aug 11, 2015 at 6:48 PM, Michael Gogins <michael.gogins@gmail.com> wrote:

Sorry wrong question. Why do you need two instances of csound running in the same process at the same time?

Regards,
Mile

On Aug 11, 2015 1:44 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

It's possible I don't. I tried just playing 2 instances of csound without any performance threads and only 1 seemed to play, so I added in the performance threads and both played, but with slight jitter. I'm not sure I actually want performance threads to do this as I'm not trying to control any parameters, but I'm not sure what to use instead


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel



------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-11 19:20
FromPeter Burgess
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

Is there not? I thought I remembered reading that you could only go up to 99. On experimentation, its clear that it's not limited, or at least not to 99. I think I might of got that idea when reading through reverb examples a while back, cos instr 99 was used as the reverb channel I think, so I guess I jumped to conclusions.

All the same, is there a correct way to play two csound performances together without jitter?


Date2015-08-11 19:22
Fromjpff
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
I thought the limit was memory based.  Number or instruments expands as 
reqyired -- or at least it issupposed to.
==John ff

On Tue, 11 Aug 2015, Oeyvind Brandtsegg wrote:

> 
> Oh, is there a limit? No?
> 
> 11. aug. 2015 19.55 skrev "Peter Burgess" :
>       I want access to a great many instruments, more than the allowed
>       99 per orchestra. I am therefore going to have multiple .csd
>       files, possible containing different types of instruments or
>       something, and I'm trying to work out the best way of utilizing
>       this. One of my ideas to get around this is to play multiple
>       instances of csound at once, though that's probably not ideal for
>       tight syncronisity and might be heavier on the cpu than I would
>       ideally like
> 
> On Tue, Aug 11, 2015 at 6:48 PM, Michael Gogins
>  wrote:
>
>       Sorry wrong question. Why do you need two instances of
>       csound running in the same process at the same time?
>
>       Regards,
>       Mile
>
>       On Aug 11, 2015 1:44 PM, "Peter Burgess"
>        wrote:
>
>             It's possible I don't. I tried just playing 2
>             instances of csound without any performance
>             threads and only 1 seemed to play, so I added in
>             the performance threads and both played, but
>             with slight jitter. I'm not sure I actually want
>             performance threads to do this as I'm not trying
>             to control any parameters, but I'm not sure what
>             to use instead
> 
> 
> -----------------------------------------------------------------------------
>             -
>
>             _______________________________________________
>             Csound-devel mailing list
>             Csound-devel@lists.sourceforge.net
>             https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> -----------------------------------------------------------------------------
> -
> 
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> 
> -----------------------------------------------------------------------------
> -
> 
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-08-11 19:30
FromMichael Gogins
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  

Yes, if you set up a barrier for each thread at the end of each buffer or kperiod. This is what Csound does internally when you run Csound  with more than one thread (-j option).

You can store your bank in std::map <std::string, std::string> keyed by instr name. Then you can look up the instr definition by name and pass it to csoundCompileOrc during performance. You could also key the map by number.

Regards,
Mike

On Aug 11, 2015 2:21 PM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:

Is there not? I thought I remembered reading that you could only go up to 99. On experimentation, its clear that it's not limited, or at least not to 99. I think I might of got that idea when reading through reverb examples a while back, cos instr 99 was used as the reverb channel I think, so I guess I jumped to conclusions.

All the same, is there a correct way to play two csound performances together without jitter?


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-11 19:33
Fromjpff
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
if you have multiple processors then does not -j give you what you need? 
Otherwise it might be better to use kperf on each instance in a loop but I 
doubt it will give much.  But what dio I know?  Te insides of amodern 
processor are beyond me.

==John ff

On Tue, 11 Aug 2015, Peter Burgess wrote:

> 
> All the same, is there a correct way to play two csound performances together
> without jitter?
> 
> 
>

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-08-11 20:07
FromVictor Lazzarini
SubjectRe: [Cs-dev] Multiple Csound API performances running in parallel
AttachmentsNone  None  
There is no software limit. The hard limit might be memory-related, but I doubt it would be easy to reach it.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 11 Aug 2015, at 19:20, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

Is there not? I thought I remembered reading that you could only go up to 99. On experimentation, its clear that it's not limited, or at least not to 99. I think I might of got that idea when reading through reverb examples a while back, cos instr 99 was used as the reverb channel I think, so I guess I jumped to conclusions.

All the same, is there a correct way to play two csound performances together without jitter?

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel