Two instances of csound at once
Date | 2016-01-14 11:55 |
From | Peter Burgess |
Subject | Two instances of csound at once |
Ok, I've asked this before back when I was new to csound, but I don't entirely remember the answer, and I can't locate my original question... Is there any reason that I shouldn't run two instances of csound (in this case from the c++ API) at once on one machine? I've been running csound and a different audio player for a while, but I'd like to go back to everything being csound. However, I'm recoiling from all the the leg-work of the change over before knowing whether it will be worth the effort, lol. How that will work out when my app is running on a mobile platform is also relevant here. Pete 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 |
Date | 2016-01-14 12:08 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
If you are only using Csound for audio processing and are using your own audio IO interface then you can run as many instances as you like. But if you are using Csound's audio IO modules then it gets more complicated. I don't see why you need two instances. You can just start an instance of your sound player instrument whenever you like? On 14 January 2016 at 11:55, Peter Burgess <pete.soundtechnician@gmail.com> wrote: Ok, I've asked this before back when I was new to csound, but I don't |
Date | 2016-01-14 12:13 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
I have one instance of csound bouncing wav files, while something else is outputting audio in realtime. I want to make this something else csound if possible On Thu, Jan 14, 2016 at 12:08 PM, Rory Walsh |
Date | 2016-01-14 12:15 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Right now SDL mixer is taking care of the realtime output, but it's impossible to get the tight timing I need. On Thu, Jan 14, 2016 at 12:13 PM, Peter Burgess |
Date | 2016-01-14 12:16 |
From | jpff |
Subject | Re: Two instances of csound at once |
On Thu, 14 Jan 2016, Peter Burgess wrote: > Is there any reason that I shouldn't run two instances of csound (in > this case from the c++ API) at once on one machine? Technically no as long as acess to sondcard is OK 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 |
Date | 2016-01-14 12:17 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
Why not use Csound to output your audio instead of SDL mixer? On 14 January 2016 at 12:15, Peter Burgess <pete.soundtechnician@gmail.com> wrote: Right now SDL mixer is taking care of the realtime output, but it's |
Date | 2016-01-14 12:17 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Ok, so I'm only going to face the same problems whether I use Csound and SDL mixer, or two instances of Csound On Thu, Jan 14, 2016 at 12:16 PM, jpff |
Date | 2016-01-14 12:17 |
From | Jacques Leplat |
Subject | Re: Two instances of csound at once |
Regarding mobile platforms, I don’t think it should be a problem running two (different) apps that use the CSound API, I’ve done that with the CSD Player and my own app: on mobile platforms once an app is launched it tends to stay running, there is no way to exit and app in the Android SDK. I would expect the same applies to desktop apps. Though I am not sure what would happen if both were trying to output sound at the same time. All the best, Jacques > On 14 Jan 2016, at 11:55, Peter Burgess |
Date | 2016-01-14 12:23 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
@Rory, that's what I'm talking about ;) sorry, I've probably not been totally clear. I want to switch the realtime to Csound aswell as the wav exporting. I think back in the early days, I had some problem when I tried to run two instances of Csound at once, so I switched the realtime to SDL mixer, but I dare say the problem wasn't because I was running two Csounds. @Jacques, The two instances will be part of the same app, but I guess if it works with two different apps running at once, then it should work within one app. Although on a mobile platform, if you switch apps, will the sound continue to output from both? I would have thought only the active app will output audio On Thu, Jan 14, 2016 at 12:17 PM, Jacques Leplat |
Date | 2016-01-14 12:27 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
It's only ever in rare cases that I see the need for more than one instance of Csound. For example, I have software that treats each instance of Csound as a node in processing graph. Here is makes sense to run separate instances and collected the output of each before sending them to the sound card. But in about 99% of the cases a single instance is enough. I'd even suggest that needing 2 separate instances is more likely a design flaw than a solution for most things. What is preventing you from doing all you want with a single instance of Csound? On 14 January 2016 at 12:17, Peter Burgess <pete.soundtechnician@gmail.com> wrote: Ok, so I'm only going to face the same problems whether I use Csound |
Date | 2016-01-14 12:32 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
The need to output both realtime audio and audio files at the same time. The realtime and file output will be outputting different audio. This is a key element in my app, so I cannot change this. However, I haven't ever asked whether it is possible to do both these tasks at once in one csd. That could also be a solution, although the realtime output needs to be continuous playing, whereas the file output is regularly recompiled. On Thu, Jan 14, 2016 at 12:27 PM, Rory Walsh |
Date | 2016-01-14 12:37 |
From | Michael Gogins |
Subject | Re: Two instances of csound at once |
You should indeed be able to run two instances at the same time. We did quite a bit of work to make Csound re-entrant. But the last time I actually tested this, by running two CsoundVST plug-ins in the same host at the same time, was about 5 years ago. It may need to be re-tested. Regards, On Jan 14, 2016 7:00 AM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:
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
Ok, I've asked this before back when I was new to csound, but I don't |
Date | 2016-01-14 12:40 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
If you are writing the files in real time then you can do it all with a single instance of Csound. But if you are using Csound to quickly render audio files offline so to speak then you may well need another instance. But it wouldn't be a problem in this case because you do not need to access the audio IO modules. It's hard to say more without knowing what you are trying to achieve with your app. On 14 January 2016 at 12:32, Peter Burgess <pete.soundtechnician@gmail.com> wrote: The need to output both realtime audio and audio files at the same |
Date | 2016-01-14 12:45 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Ok, so all sounds good! Yes, it is quickly rendering audio files offline, while the realtime player is playing totally different audio. I don't want to say too much more about my app yet, as I've been keeping it a secret, but I should be unveiling it in the next couple of weeks. I'll make sure you guys are the first to know ;) Knowing my luck though, you guys will have been there and done that already :D haha On Thu, Jan 14, 2016 at 12:40 PM, Rory Walsh |
Date | 2016-01-14 12:49 |
From | Jacques Leplat |
Subject | Re: Two instances of csound at once |
Not sure what happens when the playing is in the activity, my code always purposefully stops csound when the screen goes, so you’d need to write a quick prototype to see. There is always the chance the os will decide to kill off the activity if it’s in the background though. If you have an app (like a music player) where background sound generation is required, the playing code should be pulled out into a background service, that’s the way to ensure it will run properly in the background. If you really, really want to have two instances of csound in the same app, you will need to check carefully, I noticed that some initialization code is static in csd player, not sure what happens if you run those calls once or twice, for two instances. All the best, and good luck! Jacques > On 14 Jan 2016, at 12:23, Peter Burgess |
Date | 2016-01-14 12:51 |
From | Michael Gogins |
Subject | Re: Two instances of csound at once |
Yes, I was talking about desktop Csound, not android. Regards, On Jan 14, 2016 7:49 AM, "Jacques Leplat" <jleplat@j3ltd.com> wrote:
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
Not sure what happens when the playing is in the activity, my code always purposefully stops csound when the screen goes, so you’d need to write a quick prototype to see. There is always the chance the os will decide to kill off the activity if it’s in the background though. |
Date | 2016-01-14 12:53 |
From | mskala@ANSUZ.SOOKE.BC.CA |
Subject | Re: Two instances of csound at once |
On Thu, 14 Jan 2016, Peter Burgess wrote: > @Jacques, The two instances will be part of the same app, but I guess > if it works with two different apps running at once, then it should > work within one app. That doesn't follow. It frequently happens that code internally uses static variables at fixed locations in the process's address space. Two instances of that code running at once in the same process will interfere with each other. Separate "apps" would have their own address spaces and this kind of interferance wouldn't occur between them; so it's quite possible that simultaneous instances in separate processes would be no problem but simultaneous instances in the same process would fail. The question that needs to be answered is whether Csound is re-entrant - that is, capable of running two instances in the same process and address space. Contention for access to sound hardware is a separate issue from that. I don't know the answer to this question. |
Date | 2016-01-14 12:55 |
From | Victor Lazzarini |
Subject | Re: Two instances of csound at once |
Csound is re-entrant. It has always been since version 5.00. ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 14 Jan 2016, at 12:53, mskala@ANSUZ.SOOKE.BC.CA wrote: > > On Thu, 14 Jan 2016, Peter Burgess wrote: >> @Jacques, The two instances will be part of the same app, but I guess >> if it works with two different apps running at once, then it should >> work within one app. > > That doesn't follow. It frequently happens that code internally > uses static variables at fixed locations in the process's address space. > Two instances of that code running at once in the same process will > interfere with each other. Separate "apps" would have their own address > spaces and this kind of interferance wouldn't occur between them; so it's > quite possible that simultaneous instances in separate processes would be > no problem but simultaneous instances in the same process would fail. > > The question that needs to be answered is whether Csound is re-entrant - > that is, capable of running two instances in the same process and address > space. Contention for access to sound hardware is a separate issue from > that. I don't know the answer to this question. > > -- > Matthew Skala > mskala@ansuz.sooke.bc.ca People before principles. > http://ansuz.sooke.bc.ca/ > > 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 |
Date | 2016-01-14 12:56 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Thanks! Well I guess the best thing I can do is just try it out and report back with the outcome. I haven't got round to porting my app to android yet for testing, and I reckon that'll probably be the clincher. I best keep a copy of my app from before I move realtime to Csound aswell, so when I do start porting it to android, I can test it both ways. Thank you all for your help! On Thu, Jan 14, 2016 at 12:53 PM, |
Date | 2016-01-14 13:06 |
From | Michael Gogins |
Subject | Re: Two instances of csound at once |
To clarify this, desktop Csound, the Csound API, and CsoundVST were built to be re-entrant, have in the past been tested to be re-entrant, and if they are not re-entrant now that is a bug that must be fixed. On Android, the native code is re-entrant if the desktop version is, but the Java code, i.e. the CsoundAndroid library, probably is not re-entrant unless either there are no static variables, or their initialization is synchronized. Steven? Regards, On Jan 14, 2016 7:53 AM, <mskala@ansuz.sooke.bc.ca> wrote:
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
On Thu, 14 Jan 2016, Peter Burgess wrote: |
Date | 2016-01-14 14:52 |
From | Victor Lazzarini |
Subject | Re: Two instances of csound at once |
The Csound and CsoundAndroid lib is re-entrant. Is anyone saying otherwise? ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 14 Jan 2016, at 13:06, Michael Gogins |
Date | 2016-01-14 15:03 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
so I'm good to use two csound instances at once in my app when it gets ported to android? On Thu, Jan 14, 2016 at 2:52 PM, Victor Lazzarini |
Date | 2016-01-14 15:08 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
So long as you are only outputting to the soundcard from one. On 14 January 2016 at 15:03, Peter Burgess <pete.soundtechnician@gmail.com> wrote: so I'm good to use two csound instances at once in my app when it gets |
Date | 2016-01-14 15:10 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Nice! Thanks alot guys, I will get to work on that in the coming days then. On Thu, Jan 14, 2016 at 3:08 PM, Rory Walsh |
Date | 2016-01-14 15:12 |
From | Victor Lazzarini |
Subject | Re: Two instances of csound at once |
As far as the Csound library is concerned, yes. ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 14 Jan 2016, at 15:03, Peter Burgess |
Date | 2016-01-15 09:25 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Sorry to bring this up yet again, but I have one final question regarding this whole business... SDL mixer is very basic audio player software, and Csound is obviously really advanced all round audio software that covers all bases. As such, will using Csound as a simple audio player incur any extra performance overheads compared to using software like SDL mixer which is only a simple audio player? Or will Csound only use the resources that it requires for the task it is given? I know this is probably a tricky question to answer fully, and probably requires knowledge of how the SDL mixer libraries are put together and a few benchmark tests for a true comparison, but I'd be satisfied with some guess work and conjecture here :D On Thu, Jan 14, 2016 at 3:12 PM, Victor Lazzarini |
Date | 2016-01-15 09:44 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
Csound's overhead is pretty low. Using it as a simple sound file player should not cause any problems in terms of resources. My first Csound editor has a build-in sound file player that basically launched a diskin2 instrument to play. No problems there at all, so long as there wasn't another instance of Csound outputting to the sound card. On 15 January 2016 at 09:25, Peter Burgess <pete.soundtechnician@gmail.com> wrote: Sorry to bring this up yet again, but I have one final question |
Date | 2016-01-15 10:29 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Nice! Thanks again. I started the change over last night, it's already a total headache! :D Lol. My app has got so big, SDL2 functions are now woven tightly into it's fabric. Should have done this a long time ago! On Fri, Jan 15, 2016 at 9:44 AM, Rory Walsh |
Date | 2016-01-15 10:33 |
From | Rory Walsh |
Subject | Re: Two instances of csound at once |
You're not the first developer to come to that realisation! It's happened all of us at some stage or another. On 15 January 2016 at 10:29, Peter Burgess <pete.soundtechnician@gmail.com> wrote: Nice! Thanks again. I started the change over last night, it's already |
Date | 2016-01-15 10:43 |
From | Peter Burgess |
Subject | Re: Two instances of csound at once |
Haha, I sort of knew it anyway, but making the musical part is more enticing than dicing with audio players. That's why I keep getting in these tangles :D On Fri, Jan 15, 2016 at 10:33 AM, Rory Walsh |