Csound Csound-dev Csound-tekno Search About

Dynamically generated scores (Csound API)

Date2016-04-20 22:39
FromSøren Jakobsen
SubjectDynamically generated scores (Csound API)
Dear all, I had this other question, which did not seem to get through
the first time I posted (apparently I had somehow gotten unsubscribed
from the list):

I wonder what is the recommended approach with Csound (API) when you
want to have a score generated dynamically in another language (e.g.
Python) - e.g. for each 'beat' of the music, according to some user
input.

My first idea was to have one score which is updated and
rewound/replayed every time it finishes playing. However, this
(natural) approach has the problem that rewinding somehow introduces a
delay.

My current approach, somewhat more complicated, involves setting up a
callback which is called at the start of each beat (in a Csound loop)
via 'invalue' - the callback will generate a score (string) for the
coming beat of the music and pass it via SetStringChannel() back to
Csound to be played (the strings will generally be too long to be
passed back directly through invalue).

Is there a simpler method?

Best regards,
Søren

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

Date2016-04-20 22:53
FromHlöðver Sigurðsson
SubjectRe: Dynamically generated scores (Csound API)
Don't know Python, but what I did with Clojure was in a way similar. I would build a musical pattern buffer that can be changed from the beginning of a pattern until the end of it, the state of the pattern at the end of it would not be possible to change until the end of that next round. You should maybe arrange the python variables this way (maybe use k-rate iterator to calculate when a pattern begins and ends, use also a lot of modulos).

def pattern-buffer "i 1 0 10\n i 1 20 10..etc.."
def pattern "i 1 0 1\n i 1 + 1\n..etc.."

if (total-k-rate-iterator modulo pattern-length) = 0 then
assign pattern = pattern-buffer
endif

(hopefully this is somewhat language neutral).

I would recommend checking out my live-coding csound-api-app Panaeolus, but I'm actively reworking on it so I can't recommend it as of today. But that is based on the idea of fixed patterns with fast changing instruments.


2016-04-20 23:39 GMT+02:00 Søren Jakobsen <sorenkj@gmail.com>:
Dear all, I had this other question, which did not seem to get through
the first time I posted (apparently I had somehow gotten unsubscribed
from the list):

I wonder what is the recommended approach with Csound (API) when you
want to have a score generated dynamically in another language (e.g.
Python) - e.g. for each 'beat' of the music, according to some user
input.

My first idea was to have one score which is updated and
rewound/replayed every time it finishes playing. However, this
(natural) approach has the problem that rewinding somehow introduces a
delay.

My current approach, somewhat more complicated, involves setting up a
callback which is called at the start of each beat (in a Csound loop)
via 'invalue' - the callback will generate a score (string) for the
coming beat of the music and pass it via SetStringChannel() back to
Csound to be played (the strings will generally be too long to be
passed back directly through invalue).

Is there a simpler method?

Best regards,
Søren

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

Date2016-04-21 17:24
FromSøren Jakobsen
SubjectRe: Dynamically generated scores (Csound API)
That's an interesting approach, although still a bit more complicated
than just rewinding/replaying.
I'll have a look at your code:)
Thanks,
Søren

On 4/20/16, Hlöðver Sigurðsson  wrote:
> Don't know Python, but what I did with Clojure was in a way similar. I
> would build a musical pattern buffer that can be changed from the beginning
> of a pattern until the end of it, the state of the pattern at the end of it
> would not be possible to change until the end of that next round. You
> should maybe arrange the python variables this way (maybe use k-rate
> iterator to calculate when a pattern begins and ends, use also a lot of
> modulos).
>
> def pattern-buffer "i 1 0 10\n i 1 20 10..etc.."
> def pattern "i 1 0 1\n i 1 + 1\n..etc.."
>
> if (total-k-rate-iterator modulo pattern-length) = 0 then
> assign pattern = pattern-buffer
> endif
>
> (hopefully this is somewhat language neutral).
>
> I would recommend checking out my live-coding csound-api-app Panaeolus, but
> I'm actively reworking on it so I can't recommend it as of today. But that
> is based on the idea of fixed patterns with fast changing instruments.
>
>
> 2016-04-20 23:39 GMT+02:00 Søren Jakobsen :
>
>> Dear all, I had this other question, which did not seem to get through
>> the first time I posted (apparently I had somehow gotten unsubscribed
>> from the list):
>>
>> I wonder what is the recommended approach with Csound (API) when you
>> want to have a score generated dynamically in another language (e.g.
>> Python) - e.g. for each 'beat' of the music, according to some user
>> input.
>>
>> My first idea was to have one score which is updated and
>> rewound/replayed every time it finishes playing. However, this
>> (natural) approach has the problem that rewinding somehow introduces a
>> delay.
>>
>> My current approach, somewhat more complicated, involves setting up a
>> callback which is called at the start of each beat (in a Csound loop)
>> via 'invalue' - the callback will generate a score (string) for the
>> coming beat of the music and pass it via SetStringChannel() back to
>> Csound to be played (the strings will generally be too long to be
>> passed back directly through invalue).
>>
>> Is there a simpler method?
>>
>> Best regards,
>> Søren
>>
>> 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

Date2016-04-21 20:32
FromVictor Lazzarini
SubjectRe: Dynamically generated scores (Csound API)
Is there a lot of delay in rewinding?

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

> On 21 Apr 2016, at 17:24, Søren Jakobsen  wrote:
> 
> That's an interesting approach, although still a bit more complicated
> than just rewinding/replaying.
> I'll have a look at your code:)
> Thanks,
> Søren
> 
>> On 4/20/16, Hlöðver Sigurðsson  wrote:
>> Don't know Python, but what I did with Clojure was in a way similar. I
>> would build a musical pattern buffer that can be changed from the beginning
>> of a pattern until the end of it, the state of the pattern at the end of it
>> would not be possible to change until the end of that next round. You
>> should maybe arrange the python variables this way (maybe use k-rate
>> iterator to calculate when a pattern begins and ends, use also a lot of
>> modulos).
>> 
>> def pattern-buffer "i 1 0 10\n i 1 20 10..etc.."
>> def pattern "i 1 0 1\n i 1 + 1\n..etc.."
>> 
>> if (total-k-rate-iterator modulo pattern-length) = 0 then
>> assign pattern = pattern-buffer
>> endif
>> 
>> (hopefully this is somewhat language neutral).
>> 
>> I would recommend checking out my live-coding csound-api-app Panaeolus, but
>> I'm actively reworking on it so I can't recommend it as of today. But that
>> is based on the idea of fixed patterns with fast changing instruments.
>> 
>> 
>> 2016-04-20 23:39 GMT+02:00 Søren Jakobsen :
>> 
>>> Dear all, I had this other question, which did not seem to get through
>>> the first time I posted (apparently I had somehow gotten unsubscribed
>>> from the list):
>>> 
>>> I wonder what is the recommended approach with Csound (API) when you
>>> want to have a score generated dynamically in another language (e.g.
>>> Python) - e.g. for each 'beat' of the music, according to some user
>>> input.
>>> 
>>> My first idea was to have one score which is updated and
>>> rewound/replayed every time it finishes playing. However, this
>>> (natural) approach has the problem that rewinding somehow introduces a
>>> delay.
>>> 
>>> My current approach, somewhat more complicated, involves setting up a
>>> callback which is called at the start of each beat (in a Csound loop)
>>> via 'invalue' - the callback will generate a score (string) for the
>>> coming beat of the music and pass it via SetStringChannel() back to
>>> Csound to be played (the strings will generally be too long to be
>>> passed back directly through invalue).
>>> 
>>> Is there a simpler method?
>>> 
>>> Best regards,
>>> Søren
>>> 
>>> 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

Date2016-04-21 20:34
FromVictor Lazzarini
SubjectRe: Dynamically generated scores (Csound API)
you could also use recursion. See my article "scoreless csound" in the Csound Journal.

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

> On 21 Apr 2016, at 17:24, Søren Jakobsen  wrote:
> 
> That's an interesting approach, although still a bit more complicated
> than just rewinding/replaying.
> I'll have a look at your code:)
> Thanks,
> Søren
> 
>> On 4/20/16, Hlöðver Sigurðsson  wrote:
>> Don't know Python, but what I did with Clojure was in a way similar. I
>> would build a musical pattern buffer that can be changed from the beginning
>> of a pattern until the end of it, the state of the pattern at the end of it
>> would not be possible to change until the end of that next round. You
>> should maybe arrange the python variables this way (maybe use k-rate
>> iterator to calculate when a pattern begins and ends, use also a lot of
>> modulos).
>> 
>> def pattern-buffer "i 1 0 10\n i 1 20 10..etc.."
>> def pattern "i 1 0 1\n i 1 + 1\n..etc.."
>> 
>> if (total-k-rate-iterator modulo pattern-length) = 0 then
>> assign pattern = pattern-buffer
>> endif
>> 
>> (hopefully this is somewhat language neutral).
>> 
>> I would recommend checking out my live-coding csound-api-app Panaeolus, but
>> I'm actively reworking on it so I can't recommend it as of today. But that
>> is based on the idea of fixed patterns with fast changing instruments.
>> 
>> 
>> 2016-04-20 23:39 GMT+02:00 Søren Jakobsen :
>> 
>>> Dear all, I had this other question, which did not seem to get through
>>> the first time I posted (apparently I had somehow gotten unsubscribed
>>> from the list):
>>> 
>>> I wonder what is the recommended approach with Csound (API) when you
>>> want to have a score generated dynamically in another language (e.g.
>>> Python) - e.g. for each 'beat' of the music, according to some user
>>> input.
>>> 
>>> My first idea was to have one score which is updated and
>>> rewound/replayed every time it finishes playing. However, this
>>> (natural) approach has the problem that rewinding somehow introduces a
>>> delay.
>>> 
>>> My current approach, somewhat more complicated, involves setting up a
>>> callback which is called at the start of each beat (in a Csound loop)
>>> via 'invalue' - the callback will generate a score (string) for the
>>> coming beat of the music and pass it via SetStringChannel() back to
>>> Csound to be played (the strings will generally be too long to be
>>> passed back directly through invalue).
>>> 
>>> Is there a simpler method?
>>> 
>>> Best regards,
>>> Søren
>>> 
>>> 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

Date2016-04-21 21:57
FromSøren Jakobsen
SubjectRe: Dynamically generated scores (Csound API)
It is actually not a long delay, but long enough to 'destroy' the flow
of the rhythm.

Thank you for the article tip - recursion with the schedule opcode is
a good idea (I was currently using 'reinit' for the loop). Some time
ago I was also trying to do all my code within Csound, but I realized
that Csound is not really a 'general purpose language' (e.g. some
basic file handling is not supported), so my preferred approach now is
more to only use Csound for realtime 'stuff'.

On 4/21/16, Victor Lazzarini  wrote:
> you could also use recursion. See my article "scoreless csound" in the
> Csound Journal.
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
>> On 21 Apr 2016, at 17:24, Søren Jakobsen  wrote:
>>
>> That's an interesting approach, although still a bit more complicated
>> than just rewinding/replaying.
>> I'll have a look at your code:)
>> Thanks,
>> Søren
>>
>>> On 4/20/16, Hlöðver Sigurðsson  wrote:
>>> Don't know Python, but what I did with Clojure was in a way similar. I
>>> would build a musical pattern buffer that can be changed from the
>>> beginning
>>> of a pattern until the end of it, the state of the pattern at the end of
>>> it
>>> would not be possible to change until the end of that next round. You
>>> should maybe arrange the python variables this way (maybe use k-rate
>>> iterator to calculate when a pattern begins and ends, use also a lot of
>>> modulos).
>>>
>>> def pattern-buffer "i 1 0 10\n i 1 20 10..etc.."
>>> def pattern "i 1 0 1\n i 1 + 1\n..etc.."
>>>
>>> if (total-k-rate-iterator modulo pattern-length) = 0 then
>>> assign pattern = pattern-buffer
>>> endif
>>>
>>> (hopefully this is somewhat language neutral).
>>>
>>> I would recommend checking out my live-coding csound-api-app Panaeolus,
>>> but
>>> I'm actively reworking on it so I can't recommend it as of today. But
>>> that
>>> is based on the idea of fixed patterns with fast changing instruments.
>>>
>>>
>>> 2016-04-20 23:39 GMT+02:00 Søren Jakobsen :
>>>
>>>> Dear all, I had this other question, which did not seem to get through
>>>> the first time I posted (apparently I had somehow gotten unsubscribed
>>>> from the list):
>>>>
>>>> I wonder what is the recommended approach with Csound (API) when you
>>>> want to have a score generated dynamically in another language (e.g.
>>>> Python) - e.g. for each 'beat' of the music, according to some user
>>>> input.
>>>>
>>>> My first idea was to have one score which is updated and
>>>> rewound/replayed every time it finishes playing. However, this
>>>> (natural) approach has the problem that rewinding somehow introduces a
>>>> delay.
>>>>
>>>> My current approach, somewhat more complicated, involves setting up a
>>>> callback which is called at the start of each beat (in a Csound loop)
>>>> via 'invalue' - the callback will generate a score (string) for the
>>>> coming beat of the music and pass it via SetStringChannel() back to
>>>> Csound to be played (the strings will generally be too long to be
>>>> passed back directly through invalue).
>>>>
>>>> Is there a simpler method?
>>>>
>>>> Best regards,
>>>> Søren
>>>>
>>>> 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