Csound Csound-dev Csound-tekno Search About

[Csnd] Feeling like a csPerfThread noob again...

Date2017-09-05 23:05
FromPeter Burgess
Subject[Csnd] Feeling like a csPerfThread noob again...
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

-- 
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 07:56
FromFrancois PINOT
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 18:42
FromPeter Burgess
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
I know, that was my main reference! I feel like what I'm doing is equivalent to what they do in the second example

On 6 Sep 2017 7:56 a.m., "Francois PINOT" <fggpinot@gmail.com> wrote:
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 18:59
FromRory Walsh
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
I know, that was my main reference! I feel like what I'm doing is equivalent to what they do in the second example

On 6 Sep 2017 7:56 a.m., "Francois PINOT" <fggpinot@gmail.com> wrote:
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 19:10
FromRory Walsh
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
Btw, I don't spot much wrong with your code. I don't know why this would cause Csound is make your GUI unresponsive. Does your GUI framework have a separate GUI thread, maybe there is an issue there? 

On 6 September 2017 at 18:59, Rory Walsh <rorywalsh@ear.ie> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
I know, that was my main reference! I feel like what I'm doing is equivalent to what they do in the second example

On 6 Sep 2017 7:56 a.m., "Francois PINOT" <fggpinot@gmail.com> wrote:
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 19:38
FromPeter Burgess
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
No, that's part of the problem. I'm running it in the gui thread in my initial code. I'm only playing short phrases each time I hit play, so it's been OK for testing, but I'd like to tidy that up now. 

I could run it in a seperation thread, but that would seem counterproductive seeing as there is a csound thread object.

Ill check out those links shortly too, thanks

On 6 Sep 2017 7:10 p.m., "Rory Walsh" <rorywalsh@ear.ie> wrote:
Btw, I don't spot much wrong with your code. I don't know why this would cause Csound is make your GUI unresponsive. Does your GUI framework have a separate GUI thread, maybe there is an issue there? 

On 6 September 2017 at 18:59, Rory Walsh <rorywalsh@ear.ie> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
I know, that was my main reference! I feel like what I'm doing is equivalent to what they do in the second example

On 6 Sep 2017 7:56 a.m., "Francois PINOT" <fggpinot@gmail.com> wrote:
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-06 19:40
FromPeter Burgess
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
Oh, unless you were talking about the perfthread version? That one doesn't freeze the system up, it just doesn't play anything

On 6 Sep 2017 7:38 p.m., "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:
No, that's part of the problem. I'm running it in the gui thread in my initial code. I'm only playing short phrases each time I hit play, so it's been OK for testing, but I'd like to tidy that up now. 

I could run it in a seperation thread, but that would seem counterproductive seeing as there is a csound thread object.

Ill check out those links shortly too, thanks

On 6 Sep 2017 7:10 p.m., "Rory Walsh" <rorywalsh@ear.ie> wrote:
Btw, I don't spot much wrong with your code. I don't know why this would cause Csound is make your GUI unresponsive. Does your GUI framework have a separate GUI thread, maybe there is an issue there? 

On 6 September 2017 at 18:59, Rory Walsh <rorywalsh@ear.ie> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
I know, that was my main reference! I feel like what I'm doing is equivalent to what they do in the second example

On 6 Sep 2017 7:56 a.m., "Francois PINOT" <fggpinot@gmail.com> wrote:
There are two examples in the "CsoundPerformanceThread: a Swiss Knife for the API" section of the chapter of the floss manual about the Csound API: http://floss.booktype.pro/csound/a-the-csound-api/

François

2017-09-06 0:05 GMT+02:00 Peter Burgess <pete.soundtechnician@gmail.com>:
Hi guys. I can't get csPerfThread to play, and I'm struggling to
figure out the problem while following the online documentation...

So I had two functions that looked like this:

void newCsd()
{
    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());
}

void performCsd()
{
    mp_csound->Start();
    mp_csound->Perform();
    mp_csound->RewindScore();
}

These are linked to GUI buttons. They play the Csd, but as you guys
well know, this hinders the rest of my app doing anything when I call
performCsd until it rewinds. So I've tried various versions of the
above functions using the csPerfThread as God intended... But I just
can't get it right! The two equivalent functions currently look
something like this:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

Is this close to how the perfThread is meant to be used? And can I do
this without creating a new perfThread each time?

And just so I understand what's going on under the surface, when does
the perfThread detach? It has a join() but no detch(). which suggests
that's called under the hood when you call Play() or something.

Cheers in advance, Pete

--
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-07 20:28
FromPeter Burgess
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
I got it working. I was missing the call to csound->start() before I
called play... now I can't get it to replay the score without
recompiling it as I did in the non perfThread version...

I've read through the examples you sent, but none of them replay the
score. Here's my new code:

void newCsd()
{
    if (mp_csoundThread)
    {
        mp_csoundThread->Stop();
        mp_csoundThread->Join();
    }

    mp_csound->Reset();
    mp_csound->CompileCsdText(csd.c_str());

    mp_csoundThread = new CsoundPerformanceThread(mp_csound);

    mp_csound->Start();
}

void performCsd()
{
    if (mp_csoundThread->GetStatus() != 0)
        mp_csound->RewindScore();

    mp_csoundThread->Play();
}

I've tried a few different things here too... but basically I want to
be able to call performCsd however many times I like and keep playing
the same score. I've tried using the values of GetStatus and isRunning
to help figure out what to do... isRunning always returns 1, so the
thread is still running... GetStatus() returns 0 before or while it's
playing it the first time, and 2 after it has played. What does this
mean? And why does it tell me there's no score in memory once it's
done? Does it dump the score when it gets to the end when running in a
perfThread?

On Wed, Sep 6, 2017 at 7:40 PM, Peter Burgess
 wrote:
> Oh, unless you were talking about the perfthread version? That one doesn't
> freeze the system up, it just doesn't play anything
>
> On 6 Sep 2017 7:38 p.m., "Peter Burgess" 
> wrote:
>>
>> No, that's part of the problem. I'm running it in the gui thread in my
>> initial code. I'm only playing short phrases each time I hit play, so it's
>> been OK for testing, but I'd like to tidy that up now.
>>
>> I could run it in a seperation thread, but that would seem
>> counterproductive seeing as there is a csound thread object.
>>
>> Ill check out those links shortly too, thanks
>>
>> On 6 Sep 2017 7:10 p.m., "Rory Walsh"  wrote:
>>>
>>> Btw, I don't spot much wrong with your code. I don't know why this would
>>> cause Csound is make your GUI unresponsive. Does your GUI framework have a
>>> separate GUI thread, maybe there is an issue there?
>>>
>>> On 6 September 2017 at 18:59, Rory Walsh  wrote:
>>>>
>>>> Have you looked at the Csound API example repo? The cpp stuff is here:
>>>> https://github.com/csound/csoundAPI_examples/tree/master/cpp
>>>>
>>>> On 6 September 2017 at 18:42, Peter Burgess
>>>>  wrote:
>>>>>
>>>>> I know, that was my main reference! I feel like what I'm doing is
>>>>> equivalent to what they do in the second example
>>>>>
>>>>> On 6 Sep 2017 7:56 a.m., "Francois PINOT"  wrote:
>>>>>>
>>>>>> There are two examples in the "CsoundPerformanceThread: a Swiss Knife
>>>>>> for the API" section of the chapter of the floss manual about the Csound
>>>>>> API: http://floss.booktype.pro/csound/a-the-csound-api/
>>>>>>
>>>>>> François
>>>>>>
>>>>>> 2017-09-06 0:05 GMT+02:00 Peter Burgess
>>>>>> :
>>>>>>>
>>>>>>> Hi guys. I can't get csPerfThread to play, and I'm struggling to
>>>>>>> figure out the problem while following the online documentation...
>>>>>>>
>>>>>>> So I had two functions that looked like this:
>>>>>>>
>>>>>>> void newCsd()
>>>>>>> {
>>>>>>>     mp_csound->Reset();
>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>> }
>>>>>>>
>>>>>>> void performCsd()
>>>>>>> {
>>>>>>>     mp_csound->Start();
>>>>>>>     mp_csound->Perform();
>>>>>>>     mp_csound->RewindScore();
>>>>>>> }
>>>>>>>
>>>>>>> These are linked to GUI buttons. They play the Csd, but as you guys
>>>>>>> well know, this hinders the rest of my app doing anything when I call
>>>>>>> performCsd until it rewinds. So I've tried various versions of the
>>>>>>> above functions using the csPerfThread as God intended... But I just
>>>>>>> can't get it right! The two equivalent functions currently look
>>>>>>> something like this:
>>>>>>>
>>>>>>> void newCsd()
>>>>>>> {
>>>>>>>     if (mp_csoundThread)
>>>>>>>     {
>>>>>>>         mp_csoundThread->Stop();
>>>>>>>         mp_csoundThread->Join();
>>>>>>>     }
>>>>>>>
>>>>>>>     mp_csound->Reset();
>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>>
>>>>>>>     mp_csoundThread = new CsoundPerformanceThread(mp_csound);
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> void performCsd()
>>>>>>> {
>>>>>>>     if (mp_csoundThread->GetStatus() != 0)
>>>>>>>         mp_csound->RewindScore();
>>>>>>>
>>>>>>>     mp_csoundThread->Play();
>>>>>>> }
>>>>>>>
>>>>>>> Is this close to how the perfThread is meant to be used? And can I do
>>>>>>> this without creating a new perfThread each time?
>>>>>>>
>>>>>>> And just so I understand what's going on under the surface, when does
>>>>>>> the perfThread detach? It has a join() but no detch(). which suggests
>>>>>>> that's called under the hood when you call Play() or something.
>>>>>>>
>>>>>>> Cheers in advance, Pete
>>>>>>>
>>>>>>> --
>>>>>>> http://algorythmradio.com
>>>>>>> https://soundcloud.com/algorythmradio
>>>>>>>
>>>>>>> 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



-- 
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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

Date2017-09-07 21:46
FromMichael Gogins
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
Attachmentscsperfthread2.cpp  
There are two performance modes in Csound. Read the comments at the
top of csound.h to understand them. They are "score mode" and "host"
or "real-time" mode. The attached program does (what I think) you want
by putting Csound into "host mode." Csound will then play indefinitely
until stopped and can send new orchestras or scores or whole csds
whenever you want. My program puts Csound into "host mode" by calling
csound.Start() BEFORE csound.CompileCsdText.

Regards,
Mike

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, Sep 7, 2017 at 3:28 PM, Peter Burgess
 wrote:
> I got it working. I was missing the call to csound->start() before I
> called play... now I can't get it to replay the score without
> recompiling it as I did in the non perfThread version...
>
> I've read through the examples you sent, but none of them replay the
> score. Here's my new code:
>
> void newCsd()
> {
>     if (mp_csoundThread)
>     {
>         mp_csoundThread->Stop();
>         mp_csoundThread->Join();
>     }
>
>     mp_csound->Reset();
>     mp_csound->CompileCsdText(csd.c_str());
>
>     mp_csoundThread = new CsoundPerformanceThread(mp_csound);
>
>     mp_csound->Start();
> }
>
> void performCsd()
> {
>     if (mp_csoundThread->GetStatus() != 0)
>         mp_csound->RewindScore();
>
>     mp_csoundThread->Play();
> }
>
> I've tried a few different things here too... but basically I want to
> be able to call performCsd however many times I like and keep playing
> the same score. I've tried using the values of GetStatus and isRunning
> to help figure out what to do... isRunning always returns 1, so the
> thread is still running... GetStatus() returns 0 before or while it's
> playing it the first time, and 2 after it has played. What does this
> mean? And why does it tell me there's no score in memory once it's
> done? Does it dump the score when it gets to the end when running in a
> perfThread?
>
> On Wed, Sep 6, 2017 at 7:40 PM, Peter Burgess
>  wrote:
>> Oh, unless you were talking about the perfthread version? That one doesn't
>> freeze the system up, it just doesn't play anything
>>
>> On 6 Sep 2017 7:38 p.m., "Peter Burgess" 
>> wrote:
>>>
>>> No, that's part of the problem. I'm running it in the gui thread in my
>>> initial code. I'm only playing short phrases each time I hit play, so it's
>>> been OK for testing, but I'd like to tidy that up now.
>>>
>>> I could run it in a seperation thread, but that would seem
>>> counterproductive seeing as there is a csound thread object.
>>>
>>> Ill check out those links shortly too, thanks
>>>
>>> On 6 Sep 2017 7:10 p.m., "Rory Walsh"  wrote:
>>>>
>>>> Btw, I don't spot much wrong with your code. I don't know why this would
>>>> cause Csound is make your GUI unresponsive. Does your GUI framework have a
>>>> separate GUI thread, maybe there is an issue there?
>>>>
>>>> On 6 September 2017 at 18:59, Rory Walsh  wrote:
>>>>>
>>>>> Have you looked at the Csound API example repo? The cpp stuff is here:
>>>>> https://github.com/csound/csoundAPI_examples/tree/master/cpp
>>>>>
>>>>> On 6 September 2017 at 18:42, Peter Burgess
>>>>>  wrote:
>>>>>>
>>>>>> I know, that was my main reference! I feel like what I'm doing is
>>>>>> equivalent to what they do in the second example
>>>>>>
>>>>>> On 6 Sep 2017 7:56 a.m., "Francois PINOT"  wrote:
>>>>>>>
>>>>>>> There are two examples in the "CsoundPerformanceThread: a Swiss Knife
>>>>>>> for the API" section of the chapter of the floss manual about the Csound
>>>>>>> API: http://floss.booktype.pro/csound/a-the-csound-api/
>>>>>>>
>>>>>>> François
>>>>>>>
>>>>>>> 2017-09-06 0:05 GMT+02:00 Peter Burgess
>>>>>>> :
>>>>>>>>
>>>>>>>> Hi guys. I can't get csPerfThread to play, and I'm struggling to
>>>>>>>> figure out the problem while following the online documentation...
>>>>>>>>
>>>>>>>> So I had two functions that looked like this:
>>>>>>>>
>>>>>>>> void newCsd()
>>>>>>>> {
>>>>>>>>     mp_csound->Reset();
>>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>>> }
>>>>>>>>
>>>>>>>> void performCsd()
>>>>>>>> {
>>>>>>>>     mp_csound->Start();
>>>>>>>>     mp_csound->Perform();
>>>>>>>>     mp_csound->RewindScore();
>>>>>>>> }
>>>>>>>>
>>>>>>>> These are linked to GUI buttons. They play the Csd, but as you guys
>>>>>>>> well know, this hinders the rest of my app doing anything when I call
>>>>>>>> performCsd until it rewinds. So I've tried various versions of the
>>>>>>>> above functions using the csPerfThread as God intended... But I just
>>>>>>>> can't get it right! The two equivalent functions currently look
>>>>>>>> something like this:
>>>>>>>>
>>>>>>>> void newCsd()
>>>>>>>> {
>>>>>>>>     if (mp_csoundThread)
>>>>>>>>     {
>>>>>>>>         mp_csoundThread->Stop();
>>>>>>>>         mp_csoundThread->Join();
>>>>>>>>     }
>>>>>>>>
>>>>>>>>     mp_csound->Reset();
>>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>>>
>>>>>>>>     mp_csoundThread = new CsoundPerformanceThread(mp_csound);
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>> void performCsd()
>>>>>>>> {
>>>>>>>>     if (mp_csoundThread->GetStatus() != 0)
>>>>>>>>         mp_csound->RewindScore();
>>>>>>>>
>>>>>>>>     mp_csoundThread->Play();
>>>>>>>> }
>>>>>>>>
>>>>>>>> Is this close to how the perfThread is meant to be used? And can I do
>>>>>>>> this without creating a new perfThread each time?
>>>>>>>>
>>>>>>>> And just so I understand what's going on under the surface, when does
>>>>>>>> the perfThread detach? It has a join() but no detch(). which suggests
>>>>>>>> that's called under the hood when you call Play() or something.
>>>>>>>>
>>>>>>>> Cheers in advance, Pete
>>>>>>>>
>>>>>>>> --
>>>>>>>> http://algorythmradio.com
>>>>>>>> https://soundcloud.com/algorythmradio
>>>>>>>>
>>>>>>>> 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
>
>
>
> --
> http://algorythmradio.com
> https://soundcloud.com/algorythmradio
>
> 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

Date2017-09-08 00:05
FromPeter Burgess
SubjectRe: [Csnd] Feeling like a csPerfThread noob again...
Nice one, I'll examine that tomorrow. Cheer man

On Thu, Sep 7, 2017 at 9:46 PM, Michael Gogins  wrote:
> There are two performance modes in Csound. Read the comments at the
> top of csound.h to understand them. They are "score mode" and "host"
> or "real-time" mode. The attached program does (what I think) you want
> by putting Csound into "host mode." Csound will then play indefinitely
> until stopped and can send new orchestras or scores or whole csds
> whenever you want. My program puts Csound into "host mode" by calling
> csound.Start() BEFORE csound.CompileCsdText.
>
> Regards,
> Mike
>
> -----------------------------------------------------
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com
>
>
> On Thu, Sep 7, 2017 at 3:28 PM, Peter Burgess
>  wrote:
>> I got it working. I was missing the call to csound->start() before I
>> called play... now I can't get it to replay the score without
>> recompiling it as I did in the non perfThread version...
>>
>> I've read through the examples you sent, but none of them replay the
>> score. Here's my new code:
>>
>> void newCsd()
>> {
>>     if (mp_csoundThread)
>>     {
>>         mp_csoundThread->Stop();
>>         mp_csoundThread->Join();
>>     }
>>
>>     mp_csound->Reset();
>>     mp_csound->CompileCsdText(csd.c_str());
>>
>>     mp_csoundThread = new CsoundPerformanceThread(mp_csound);
>>
>>     mp_csound->Start();
>> }
>>
>> void performCsd()
>> {
>>     if (mp_csoundThread->GetStatus() != 0)
>>         mp_csound->RewindScore();
>>
>>     mp_csoundThread->Play();
>> }
>>
>> I've tried a few different things here too... but basically I want to
>> be able to call performCsd however many times I like and keep playing
>> the same score. I've tried using the values of GetStatus and isRunning
>> to help figure out what to do... isRunning always returns 1, so the
>> thread is still running... GetStatus() returns 0 before or while it's
>> playing it the first time, and 2 after it has played. What does this
>> mean? And why does it tell me there's no score in memory once it's
>> done? Does it dump the score when it gets to the end when running in a
>> perfThread?
>>
>> On Wed, Sep 6, 2017 at 7:40 PM, Peter Burgess
>>  wrote:
>>> Oh, unless you were talking about the perfthread version? That one doesn't
>>> freeze the system up, it just doesn't play anything
>>>
>>> On 6 Sep 2017 7:38 p.m., "Peter Burgess" 
>>> wrote:
>>>>
>>>> No, that's part of the problem. I'm running it in the gui thread in my
>>>> initial code. I'm only playing short phrases each time I hit play, so it's
>>>> been OK for testing, but I'd like to tidy that up now.
>>>>
>>>> I could run it in a seperation thread, but that would seem
>>>> counterproductive seeing as there is a csound thread object.
>>>>
>>>> Ill check out those links shortly too, thanks
>>>>
>>>> On 6 Sep 2017 7:10 p.m., "Rory Walsh"  wrote:
>>>>>
>>>>> Btw, I don't spot much wrong with your code. I don't know why this would
>>>>> cause Csound is make your GUI unresponsive. Does your GUI framework have a
>>>>> separate GUI thread, maybe there is an issue there?
>>>>>
>>>>> On 6 September 2017 at 18:59, Rory Walsh  wrote:
>>>>>>
>>>>>> Have you looked at the Csound API example repo? The cpp stuff is here:
>>>>>> https://github.com/csound/csoundAPI_examples/tree/master/cpp
>>>>>>
>>>>>> On 6 September 2017 at 18:42, Peter Burgess
>>>>>>  wrote:
>>>>>>>
>>>>>>> I know, that was my main reference! I feel like what I'm doing is
>>>>>>> equivalent to what they do in the second example
>>>>>>>
>>>>>>> On 6 Sep 2017 7:56 a.m., "Francois PINOT"  wrote:
>>>>>>>>
>>>>>>>> There are two examples in the "CsoundPerformanceThread: a Swiss Knife
>>>>>>>> for the API" section of the chapter of the floss manual about the Csound
>>>>>>>> API: http://floss.booktype.pro/csound/a-the-csound-api/
>>>>>>>>
>>>>>>>> François
>>>>>>>>
>>>>>>>> 2017-09-06 0:05 GMT+02:00 Peter Burgess
>>>>>>>> :
>>>>>>>>>
>>>>>>>>> Hi guys. I can't get csPerfThread to play, and I'm struggling to
>>>>>>>>> figure out the problem while following the online documentation...
>>>>>>>>>
>>>>>>>>> So I had two functions that looked like this:
>>>>>>>>>
>>>>>>>>> void newCsd()
>>>>>>>>> {
>>>>>>>>>     mp_csound->Reset();
>>>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> void performCsd()
>>>>>>>>> {
>>>>>>>>>     mp_csound->Start();
>>>>>>>>>     mp_csound->Perform();
>>>>>>>>>     mp_csound->RewindScore();
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> These are linked to GUI buttons. They play the Csd, but as you guys
>>>>>>>>> well know, this hinders the rest of my app doing anything when I call
>>>>>>>>> performCsd until it rewinds. So I've tried various versions of the
>>>>>>>>> above functions using the csPerfThread as God intended... But I just
>>>>>>>>> can't get it right! The two equivalent functions currently look
>>>>>>>>> something like this:
>>>>>>>>>
>>>>>>>>> void newCsd()
>>>>>>>>> {
>>>>>>>>>     if (mp_csoundThread)
>>>>>>>>>     {
>>>>>>>>>         mp_csoundThread->Stop();
>>>>>>>>>         mp_csoundThread->Join();
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     mp_csound->Reset();
>>>>>>>>>     mp_csound->CompileCsdText(csd.c_str());
>>>>>>>>>
>>>>>>>>>     mp_csoundThread = new CsoundPerformanceThread(mp_csound);
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> void performCsd()
>>>>>>>>> {
>>>>>>>>>     if (mp_csoundThread->GetStatus() != 0)
>>>>>>>>>         mp_csound->RewindScore();
>>>>>>>>>
>>>>>>>>>     mp_csoundThread->Play();
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Is this close to how the perfThread is meant to be used? And can I do
>>>>>>>>> this without creating a new perfThread each time?
>>>>>>>>>
>>>>>>>>> And just so I understand what's going on under the surface, when does
>>>>>>>>> the perfThread detach? It has a join() but no detch(). which suggests
>>>>>>>>> that's called under the hood when you call Play() or something.
>>>>>>>>>
>>>>>>>>> Cheers in advance, Pete
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> http://algorythmradio.com
>>>>>>>>> https://soundcloud.com/algorythmradio
>>>>>>>>>
>>>>>>>>> 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
>>
>>
>>
>> --
>> http://algorythmradio.com
>> https://soundcloud.com/algorythmradio
>>
>> 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



-- 
http://algorythmradio.com
https://soundcloud.com/algorythmradio

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