[Csnd] Csound API stopping and starting
Date | 2018-06-11 22:02 |
From | Peter Burgess |
Subject | [Csnd] Csound API stopping and starting |
Hi, I'm struggling with the API. It's something I almost never fiddle with, I just get it working and don't touch it for years so I never remember exactly how to use it... Anyway, I wish to stop my performance thread, and then be able to compile a new orchestra and play again. I can compile and play my CSD fine like this: mp_csound->CompileCsdText(csd.c_str()); mp_csound->Start(); mp_csoundThread->Play(); ...and I stop it with this: mp_csoundThread->Stop(); However, I can't compile and play another csd straight after that as it says this: WARNING: system constants can only be set once Csound is already started, call csoundReset() before starting again. So as it suggests, I call mp_csoundThread->Stop(); mp_csound->Reset(); And now, while it appears to try to do what I want when I compile and perform again, I don't get any audio. It seems to hang. What is the correct way of doing this without reinitialising Csound and CsoundPerfThread? Pete -- http://algorythmradio.com https://soundcloud.com/algorythmradio |
Date | 2018-06-11 22:11 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Csound API stopping and starting |
I’d suggest looking at the examples in this repo
Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|
Date | 2018-06-11 22:17 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
Sadly none of these examples show that. They mostly just play a performance and stop and delete csound. I've been referencing those, the floss manual and the API docs. I'm still none the wiser as to what is wrong On Mon, Jun 11, 2018 at 10:11 PM, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
-- |
Date | 2018-06-11 22:49 |
From | Steven Yi |
Subject | Re: [Csnd] Csound API stopping and starting |
Hi Pete, When does this hang, when you call Reset() or after calling Reset() and trying to compile and play a new performance? Also, what version of Csound are you using? One thing to also try is to call mp_csoundThread->Join() after calling Stop() but before calling Reset(). Usually you need to wait for the thread to complete before doing anything else. If adding Join() doesn't do it, I'd suggest removing plugin libraries from OPCODE6DIR64 and seeing if it works; if so, then try adding back in libraries until it stops working. (Sometimes opcode libraries can make Csound hang/crash, particularly when resetting Csound.) Beyond that, a minimal example with both C++ and csound code would be handy. On Mon, Jun 11, 2018 at 2:17 PM Peter Burgess |
Date | 2018-06-11 23:47 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
After calling Join(), do I need to check on the status of mp_csoundThread before I call Reset()? Where it hangs is here: STARTING FILE Creating options Creating orchestra closing tag Creating score rtaudio: ALSA module enabled rtmidi: ALSA Raw MIDI module enabled displays suppressed 0dBFS level = 1.0 orch now loaded audio buffered in 1024 sample-frame blocks ALSA output: total buffer size: 4096, period size: 1024 writing 2048 sample blks of 64-bit floats to dac SECTION 1: If checking the status is not the problem, I will make a minimal example tomorrow. Also I'm running Csound 6.10, I haven't gotten round to upgrading to 6.11 yet. Cheers, Pete On Mon, Jun 11, 2018 at 10:49 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Pete, -- |
Date | 2018-06-12 00:06 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
Interesting if I just do this and nothing else: mp_csound = new Csound; mp_csoundThread = new CsoundPerformanceThread(mp_csound); my mp_csoundThread status starts is already 0, even though csPerfThread.hpp states: /** * Returns the current status, zero if still playing, positive if * the end of score was reached or performance was stopped, and * negative if an error occured. */ And once I've called: mp_csound->CompileCsdText(csd.c_str()); mp_csound->Start(); mp_csoundThread->Play(); mp_csoundThread->Stop(); mp_csoundThread->Join(); mp_csound->Reset(); It returns a status of 1... Am I missing something or is that backwards? haha Pete On Mon, Jun 11, 2018 at 11:47 PM, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
-- |
Date | 2018-06-12 01:55 |
From | Michael Gogins |
Subject | Re: [Csnd] Csound API stopping and starting |
Attachments | csound_threaded.cpp |
The attached file does what you want without complications. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jun 11, 2018 at 7:06 PM Peter Burgess |
Date | 2018-06-12 09:35 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
Thank you. Is csound_threaded a new class that already combines csound and a performance thread? This file only performs once though, it doesn't then try to combine a new CSD and perform again after stopping and resetting. On Tue, 12 Jun 2018, 01:56 Michael Gogins, <michael.gogins@gmail.com> wrote: The attached file does what you want without complications. |
Date | 2018-06-12 12:43 |
From | Michael Gogins |
Subject | Re: [Csnd] Csound API stopping and starting |
Yes. Not that new. The class is CsoundThreaded.hpp, the attachment is a program that uses CsoundThreaded. The program embeds the CSD as text, intantiates CsoundThreaded just once, then loops to compile, perform, and reset three times. Obviously a different CSD could have been used each time. CsoundThreaded is a header file only class, you don't need to link with any extra library. Regards, Mike On Tue, Jun 12, 2018, 04:36 Peter Burgess <pete.soundtechnician@gmail.com> wrote:
|
Date | 2018-06-12 12:45 |
From | Michael Gogins |
Subject | Re: [Csnd] Csound API stopping and starting |
Btw the file performs 3 times. On Tue, Jun 12, 2018, 04:36 Peter Burgess <pete.soundtechnician@gmail.com> wrote:
|
Date | 2018-06-12 15:00 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Csound API stopping and starting |
I can’t locate the included .hpp file. Any advice? Can you attach it also? Sent from my iPhone
|
Date | 2018-06-12 15:25 |
From | Michael Gogins |
Subject | Re: [Csnd] Csound API stopping and starting |
Attachments | csound_threaded.hpp |
It's in the Csound GitHub repository include directory. I have also attached the file. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Tue, Jun 12, 2018 at 10:00 AM Dr. Richard Boulanger |
Date | 2018-06-12 15:27 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
Michael: sorry you're right, I missed the for loop when I looked at it this morning. Cheers for that, I'll give this class a try On Tue, 12 Jun 2018, 15:26 Michael Gogins, <michael.gogins@gmail.com> wrote: It's in the Csound GitHub repository include directory. I have also |
Date | 2018-06-12 15:28 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Csound API stopping and starting |
thanks _____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ President of Boulanger Labs - http://boulangerlabs.com Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book Author & Editor of The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book ______________________________________________ about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ ______________________________________________ email: rboulanger@berklee.edu facebook: https://www.facebook.com/richard.boulanger.58 On Tue, Jun 12, 2018 at 10:25 AM, Michael Gogins <michael.gogins@gmail.com> wrote: It's in the Csound GitHub repository include directory. I have also |
Date | 2018-06-12 15:36 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Csound API stopping and starting |
Here’s a program doing what you want using CsoundPerformanceThread. In this particular case, the perf thread object needs to be recreated for each performance after a Csound reset. int main() { Csound csound; string csdText = R"csd( |
Date | 2018-06-12 15:39 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Csound API stopping and starting |
On MacOS this is installed along all the other headers in CsoundLib64.framework/Headers ======================== Prof. 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 12 Jun 2018, at 15:28, Dr. Richard Boulanger |
Date | 2018-06-12 15:56 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Csound API stopping and starting |
Note that you don’t necessarily need to use the heap, you can also re-create it on the stack std::array |
Date | 2018-06-12 16:46 |
From | Richard Boulanger |
Subject | Re: [Csnd] Csound API stopping and starting |
Thanks Sent from my iPad > On Jun 12, 2018, at 10:39 AM, Victor Lazzarini |
Date | 2018-06-12 19:15 |
From | Peter Burgess |
Subject | Re: [Csnd] Csound API stopping and starting |
Hi there, I gave CsoundThreaded a go, perfect! :D Thanks for that. It's missing the TogglePause control, but if it hasn't already been added in Csound 6.11, I might try and add that myself. Cheers for your help guys! On Tue, 12 Jun 2018, 16:47 Richard Boulanger, <rboulanger@berklee.edu> wrote: Thanks |