Csound Csound-dev Csound-tekno Search About

[Csnd] Get playtime before rendering

Date2010-03-09 22:30
FromSeiya Matsumiya
Subject[Csnd] Get playtime before rendering
Hello all,

I'm currently working on a C code that writes Terry Riley's "In C". 

Right now I have three instruments as prototype insts that play the melodic
patterns. Each melodic pattern is repeated a random number of times for each
instrument. 

I'm now adding another instrument that plays an 8th note pulse in the note C
throughout the entire piece. In my attempt to write a code block that
automatically writes the note-list for the "pulse" instrument, I've realized
that I need to know how long (in seconds) the other three instruments play
for, or how long the longest of the three play for (the duration of the
three melody-playing instruments vary as each melodic pattern is repeated
randomly), so that in my C code I can write a code block that only writes
the pulse up to that point, or a few notes after it. 

I was wondering if anyone knew of a way to get the play time of a note-list
before it is rendered, or of a particular csd file without rendering it. 

I realize that this may be more of a C question than a CSound question. For
that, I apologize in advance. 

Thank you in advance for whomever that may provide me with an answer. 

Seiya Matsumiya

Date2010-03-10 00:02
FromTobiah
Subject[Csnd] Re: Get playtime before rendering
> I'm currently working on a C code that writes Terry Riley's "In C".

I'll have to guess that you chose the language so that you could write In C. :)
In my book, C is for writing tools that generate and manipulate scores rather
than being a suitable choice for managing the job by itself.  Then again the
thorny cscore is available.

> I was wondering if anyone knew of a way to get the play time of a note-list
> before it is rendered, or of a particular csd file without rendering it.

Since you are writing the score with your program, the program will
have access to the length.  Keep all of the data in memory before
writing it out.  Then you can just examine the various parts to determine
the length.

Another related way, would be to trap all events as they are generated
or as they go out to disk.  Just keep a record of the longest p2+p3 value
that goes out, and there you have your total length.

Another way to approach this would be to write the eighth note octave
part first, determining the length of the piece.  Armed with this knowledge,
the other parts can adjust themselves appropriately.  I'm not terribly familiar
with the piece, but if all of the parts play from x time to the end of the
piece, then you only have to subtract their start time from the already
established piece length to determine their length, resulting in the desired
piece length.

http://tinyurl.com/kw99x3

Tobiah


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-03-10 00:29
FromMichael Gogins
Subject[Csnd] Re: Re: Get playtime before rendering

C is fine for this, but C++ with CsoundAC is a better choice, or Python.

MKG from cell phone

On Mar 9, 2010 7:02 PM, "Tobiah" <foobuddha@gmail.com> wrote:

> I'm currently working on a C code that writes Terry Riley's "In C".

I'll have to guess that you chose the language so that you could write In C. :)
In my book, C is for writing tools that generate and manipulate scores rather
than being a suitable choice for managing the job by itself.  Then again the
thorny cscore is available.


> I was wondering if anyone knew of a way to get the play time of a note-list
> before it is render...

Since you are writing the score with your program, the program will
have access to the length.  Keep all of the data in memory before
writing it out.  Then you can just examine the various parts to determine
the length.

Another related way, would be to trap all events as they are generated
or as they go out to disk.  Just keep a record of the longest p2+p3 value
that goes out, and there you have your total length.

Another way to approach this would be to write the eighth note octave
part first, determining the length of the piece.  Armed with this knowledge,
the other parts can adjust themselves appropriately.  I'm not terribly familiar
with the piece, but if all of the parts play from x time to the end of the
piece, then you only have to subtract their start time from the already
established piece length to determine their length, resulting in the desired
piece length.

http://tinyurl.com/kw99x3

Tobiah



Send bugs reports to the Sourceforge bug tracker
https://sourceforge.net/tracker/?grou...


Date2010-03-10 00:35
FromMatsumiya Seiya
Subject[Csnd] Re: Re: Get playtime before rendering
Tobiah,

Thank you for a quick response. 

I'm using "+" and "." to carry both the start time and the duration for each note, so I can't store the p2 & p3 anywhere. I didn't include this in my original email so there was no way for you to know this,
but what you said makes perfect sense and it would work if there were specific start time for each note that can be easily extracted. 

I actually had an idea literally right after I sent out the email. Each melodic pattern looks similar to this:

First, each of the three proto-insts start out with the first pattern in the actual score of the piece. This is written automatically and is not a part of the randomizing algorithm:

i1	0 .125 8.00 5000
i. + .875 8.04 .
i. . .125 8.00 .
i. . .875 8.04 .
i. . .125	8.00 .
i. . .875 8.04 .

Then the rest of the note-list is written like this:

i1 . .125 8.00 5000
i. . .875 8.04 .
i. . .125 8.00 .
i. . .875 8.04 .
i. . .125 8.00 .
i. . .875 8.04 .

This pattern is repeated x number of times, the second pattern x' number of times, and so on.

The idea that I had is that since there is a specific duration for each melodic pattern that can be easily  calculated just by adding the duration of each note and rest, I can do that offline and create a float array that contains the data for each pattern.

Each time a pattern is generated x number of times, the corresponding length of that pattern can be multiplied by that same number to give a length of that whole section of repeating patterns.
This process will be repeated for each pattern, and each instrument. After the note-list for all instruments are written, I can then compare them and find the instrument with the longest note-list. 

Once that is found, then it's just a matter of writing the pulse instrument up to that point, and a little bit more for the ending. I'm pretty sure this will work.

But thank you nonetheless for your response. I'm sure I will use your ideas in the future for other purposes. 

Seiya

p.s. I'm new to C programming, and I'm always trying to find new things I can do in the language just to learn it. This whole project started simply because I thought it would be fun and funny to say I wrote "In C" in C. =)


On Mar 9, 2010, at 7:02 PM, Tobiah wrote:

>> I'm currently working on a C code that writes Terry Riley's "In C".
> 
> I'll have to guess that you chose the language so that you could write In C. :)
> In my book, C is for writing tools that generate and manipulate scores rather
> than being a suitable choice for managing the job by itself.  Then again the
> thorny cscore is available.
> 
>> I was wondering if anyone knew of a way to get the play time of a note-list
>> before it is rendered, or of a particular csd file without rendering it.
> 
> Since you are writing the score with your program, the program will
> have access to the length.  Keep all of the data in memory before
> writing it out.  Then you can just examine the various parts to determine
> the length.
> 
> Another related way, would be to trap all events as they are generated
> or as they go out to disk.  Just keep a record of the longest p2+p3 value
> that goes out, and there you have your total length.
> 
> Another way to approach this would be to write the eighth note octave
> part first, determining the length of the piece.  Armed with this knowledge,
> the other parts can adjust themselves appropriately.  I'm not terribly familiar
> with the piece, but if all of the parts play from x time to the end of the
> piece, then you only have to subtract their start time from the already
> established piece length to determine their length, resulting in the desired
> piece length.
> 
> http://tinyurl.com/kw99x3
> 
> Tobiah
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-03-10 00:50
FromTobiah
Subject[Csnd] Re: Re: Re: Get playtime before rendering
> I'm using "+" and "." to carry both the start time and the duration for each note, so I can't store the p2 & p3 anywhere.

My advice would be to drop any of the preprocessing features of the csound score
when you are generating the score from a program.  It is easier, and
as this case
demonstrates, more flexible to just let your program handle these
concepts within
its control structures and data stores.

Score preprocessing was invented for people that either hand edit or at best
use a spreadsheet program to create scores.  I wouldn't consider crafting any
score longer than three events by hand.  Try allowing the control to shift
toward your score generation program and limit yourself to feeding csound
only raw events.

I apologize that I have most likely not met your level of courtesy and humility.
It's not as common where I live :)

Tobiah


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"