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

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

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

Francois PINOT
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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
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" <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

rorywalsh
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <[hidden email]> 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" <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

rorywalsh
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 <[hidden email]> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <[hidden email]> 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" <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
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" <[hidden email]> 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 <[hidden email]> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <[hidden email]> 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" <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
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" <[hidden email]> 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" <[hidden email]> 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 <[hidden email]> wrote:
Have you looked at the Csound API example repo? The cpp stuff is here:

On 6 September 2017 at 18:42, Peter Burgess <[hidden email]> 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" <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
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 [hidden email] 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 [hidden email] 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 [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
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
<[hidden email]> 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" <[hidden email]>
> 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" <[hidden email]> 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 <[hidden email]> 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
>>>> <[hidden email]> 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" <[hidden email]> 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
>>>>>> <[hidden email]>:
>>>>>>>
>>>>>>> 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
>>>>>>> [hidden email]
>>>>>>> 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 [hidden email]
>>>>>> 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 [hidden email]
>>>>> 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 [hidden email]
>>> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

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

Michael Gogins-2
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
<[hidden email]> 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
> <[hidden email]> 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" <[hidden email]>
>> 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" <[hidden email]> 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 <[hidden email]> 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
>>>>> <[hidden email]> 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" <[hidden email]> 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
>>>>>>> <[hidden email]>:
>>>>>>>>
>>>>>>>> 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
>>>>>>>> [hidden email]
>>>>>>>> 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 [hidden email]
>>>>>>> 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 [hidden email]
>>>>>> 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 [hidden email]
>>>> 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
> [hidden email]
> 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
[hidden email]
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

csperfthread2.cpp (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

iron_attorney
Nice one, I'll examine that tomorrow. Cheer man

On Thu, Sep 7, 2017 at 9:46 PM, Michael Gogins <[hidden email]> 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
> <[hidden email]> 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
>> <[hidden email]> 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" <[hidden email]>
>>> 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" <[hidden email]> 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 <[hidden email]> 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
>>>>>> <[hidden email]> 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" <[hidden email]> 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
>>>>>>>> <[hidden email]>:
>>>>>>>>>
>>>>>>>>> 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
>>>>>>>>> [hidden email]
>>>>>>>>> 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 [hidden email]
>>>>>>>> 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 [hidden email]
>>>>>>> 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 [hidden email]
>>>>> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
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