Csound Csound-dev Csound-tekno Search About

tempo ramp by integration - help needed

Date2007-09-07 11:13
FromTim Mortimer
Subjecttempo ramp by integration - help needed
http://www.nabble.com/file/p12552632/integratethis.jpg integratethis.jpg 

greets,

The attached jpeg attempts to illustrate how i intend to use integration to
calculate how much "absolute" time passes in a score when a tempo ramp of a
certain duration becomes active for that period of the score.

in the case of this example, the tempo decreases from 120BPM to 30BPM over a
period of "4 beats"/ 4 "score seconds".

My maths is pretty rusty (i did a year 12 bridging course a couple of years
ago - at the time because i had just started using Max, & was desparately
trying to find out what a Markov chain was, but anyway.. the Calculus & Trig
have proven pretty useful along the way......)

But I'm having trouble trying to integrate the formula in the attached jpeg.

Can anyone assist? Once I have seen it done once, I should be able to apply
the integrated function universally (more or less) to all my tempo ramping
requirements.

i do know the basics of integration (eg integrate x^2 = x^3/3 for example..)

but im stumped by the additional scalars & denominators in my formula, &
hence by what my desired "ramp time" formula looks like (but i'm pretty sure
it's along the lines of what i'm proposing - see the diagram)

I suppose what makes my approach "a bit fancy" (beyond the method, which
some may feel excessive) is that i like to think that the perception of
tempo - like that of pitch, is an exponential / power of 2 type
relationship: i.e the perception of "speeding up" & "slowing down" is more
meaningful in terms of "twice as fast" / "half as fast", & hence i want to
use a power of 2 curve to impose this "perception" onto my tempo ramping -
rather than simply a linear increase / decrease in BPM value...

Ok, so i realise this may not be the  "normal" way to go about
"accumulating" time vis a vis changes in score tempo, however doing it by
the way I am attempting has some benefits (for me at least, in this
instance) that i see...

1) it's ultimately more accurate

2) it will fit into my "python score paradigm" tempo system with a minimum
of fuss (trust me - it has no accumulated score time - just a timeline
"function" to which it makes reference to determine current absolute time
for the scored event..)

3) u then only need to apply any tempo based calculations to significant
score events, which is someways is surely computationally more efficient
than accumulating ammassed time on each & every control rate clock - when on
99% of these "clock ticks" no event is actually taking place anyway

so, err, any help from the maths brains out there on this one appreciated...

kind regards

Tim
-- 
View this message in context: http://www.nabble.com/tempo-ramp-by-integration---help-needed-tf4400537.html#a12552632
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-09-07 11:45
From"ugur guney"
SubjectRe: tempo ramp by integration - help needed
AttachmentsNone  None  

Date2007-09-07 12:01
FromTim Mortimer
SubjectRe: tempo ramp by integration - help needed
well hey, if it ain't broke, don't f(x) it! ; )

thanks for the assistance... looks like i have enough here to get started
with this then very soon.

i think i knew that about the constants et al, but was uncertain about
making them "fit back in" to the picture in terms of getting a final
result.... actually, I thought maybe the constants might get an x appended
to them? (aware they "get discarded" when finding derivitives....)

anyway, not looking for a maths lecture - & i'm sure someone will sing out
if there's an error in here somewhere....

Thank you Ugur....


# I think what you are saying about the perception of tempo is very
interesting.
# You want to integrate f(x) = (x*sqrt(1.5)/4)^2 right?
# This is not more involved than f(x)=x^2 because constants (the additional
scalars & denominators) does not affect the integration. I mean, if the
integral of f(x) is F(x) then the integral of c*f(x) is c*F(x). In your case

Integral[ x^2*(sqrt(1.5)/4)^2 ] = (sqrt(1.5)/4)*Integral[ x^2 ]
= 1.5/16 Integral [ x^2 ] = 3/32 * [ 1/3 * x^3] = x^3/32
# But I didn't understand where you get f(x) :-)
# See you!
-ugur guney-



-- 
View this message in context: http://www.nabble.com/tempo-ramp-by-integration---help-needed-tf4400537.html#a12553101
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-09-07 12:18
From"ugur guney"
SubjectRe: tempo ramp by integration - help needed
AttachmentsNone  None  

Date2007-09-07 16:04
From"Steven Yi"
SubjectRe: tempo ramp by integration - help needed
AttachmentsNone  

Date2007-09-07 16:12
From"Steven Yi"
SubjectRe: tempo ramp by integration - help needed
AttachmentsNone  

Date2007-09-07 21:19
Fromjoachim heintz
SubjectRe: tempo ramp by integration - help needed
thanks for this link, steven. istvan's formulas are very clear, even for non-mathematicians like me ...

i made a little instrument for rendering one segment:

instr 1; gives time in seconds for changing tempo segment

ibeat0 = p4; time in beats at beginning of segment 
ibeat1 = p5; time in beats at end of segment 
itime0 = p6; time in seconds at beginning of segment 
itempo0 = p7; tempo in beats per minute at beginning of segment
itempo1 = p8; tempo in beats per minute at end of segment

ibtime0 = 60 / itempo0; seconds per beat at beginning of segment 
ibtime1 = 60 / itempo1; seconds per beat at end of segment 

ibeat = ibeat1 - ibeat0 
itime = itime0 + (ibtime0 * ibeat) + (0.5 * (ibtime1 - ibtime0) * ibeat * ibeat / (ibeat1 - ibeat0)) ;Istvan's formula

prints "%nbeat0 = %f%nbeat1 = %f%ntime0 = %f%ntempo0 = %f%ntempo1 = %f%n%ntime = %f%n%n", ibeat0, ibeat1, itime0, itempo0, itempo1, itime

endin

so tim's case: 
>in the case of this example, the tempo decreases from 120BPM to 30BPM over a
period of "4 beats"/ 4 "score seconds".<

would result in the score:

;i1 0 .1 beat0 beat1 time0 tempo0 tempo1
i1 0 .1 0 4 0 120 30

and gives the output:

beat0 = 0.000000
beat1 = 4.000000
time0 = 0.000000
tempo0 = 120.000000
tempo1 = 30.000000

time = 5.000000


hope this is correct ...

joachim



Am 07.09.2007 um 17:04 schrieb Steven Yi:

Hi Tim,

Blue has a TempoMapper class that does beatsToSeconds and
secondsToBeats with a given Csound style timewarp string
(t-statement).  This is used by blue's TimeWarp noteProcessor,
allowable on a per-soundObject basis, as well as used by blue when
following a render if a t-statement is used globally so that
accelerando's and such are followed correctly.

The math and code for all of this was worked out on this list April
2006 and the Java code I have not is based on python code that Istvan
Varga posted.  The Java class I use can be seen here:


The thread for that is availble here:


I'll reiterate at this point that I'm indebted to Istvan for his help
on this.  The thread is also an interesting read I think about how
this all works.

Hope that helps!
steven


On 9/7/07, Tim Mortimer <timmortimer@d2.net.au> wrote:


greets,

The attached jpeg attempts to illustrate how i intend to use integration to
calculate how much "absolute" time passes in a score when a tempo ramp of a
certain duration becomes active for that period of the score.

in the case of this example, the tempo decreases from 120BPM to 30BPM over a
period of "4 beats"/ 4 "score seconds".

My maths is pretty rusty (i did a year 12 bridging course a couple of years
ago - at the time because i had just started using Max, & was desparately
trying to find out what a Markov chain was, but anyway.. the Calculus & Trig
have proven pretty useful along the way......)

But I'm having trouble trying to integrate the formula in the attached jpeg.

Can anyone assist? Once I have seen it done once, I should be able to apply
the integrated function universally (more or less) to all my tempo ramping
requirements.

i do know the basics of integration (eg integrate x^2 = x^3/3 for example..)

but im stumped by the additional scalars & denominators in my formula, &
hence by what my desired "ramp time" formula looks like (but i'm pretty sure
it's along the lines of what i'm proposing - see the diagram)

I suppose what makes my approach "a bit fancy" (beyond the method, which
some may feel excessive) is that i like to think that the perception of
tempo - like that of pitch, is an exponential / power of 2 type
relationship: i.e the perception of "speeding up" & "slowing down" is more
meaningful in terms of "twice as fast" / "half as fast", & hence i want to
use a power of 2 curve to impose this "perception" onto my tempo ramping -
rather than simply a linear increase / decrease in BPM value...

Ok, so i realise this may not be the  "normal" way to go about
"accumulating" time vis a vis changes in score tempo, however doing it by
the way I am attempting has some benefits (for me at least, in this
instance) that i see...

1) it's ultimately more accurate

2) it will fit into my "python score paradigm" tempo system with a minimum
of fuss (trust me - it has no accumulated score time - just a timeline
"function" to which it makes reference to determine current absolute time
for the scored event..)

3) u then only need to apply any tempo based calculations to significant
score events, which is someways is surely computationally more efficient
than accumulating ammassed time on each & every control rate clock - when on
99% of these "clock ticks" no event is actually taking place anyway

so, err, any help from the maths brains out there on this one appreciated...

kind regards

Tim
--
Sent from the Csound - General mailing list archive at Nabble.com.

--
Send bugs reports to this list.
To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk

-- 
Send bugs reports to this list.
To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk


Date2007-09-08 01:31
FromTim Mortimer
SubjectRe: tempo ramp by integration - help needed
great stuff steven, istvan, joachim

I have been plugging my values (manually/ with a calculator) into your
formulae, but i keep getting different answers! ; ) Ditto with Ugur's
example .... I'll sit down with this in a day or 2 & work through it
properly.

I'd just re iterate however in my approach, the "realtime" required to ramp
from 120BPM to 60BPM (half original speed) will be the same amount of "real
time" that is required to then go on & ramp from 60BPM to 30BPM (half speed
again) - this will make the whole thing (hopefully) sound more like
"unwinding" rather than just the result of some linear adjustment of BPM
value - 

i draw an analogy with grain density & pitch - in that the sense of "how
different from previous" is not to do with simply the comparison of the
number of the elements involved (grains, cycles per second), but more
dependent on a percieved "ratio of relationship" between startvalue &
endvalue - & this transition can be weighted accordingly by using a power of
2 (just as portamento for example probably sounds "more linear" when it is
implemented by linear scaling of pitch value, rather than of frequency... &
BPM (& grain cloud density for that matter) is in essence just another
"frequency" - right?)

I haven't quite got my head around how this all fits together just yet - I'm
wondering then if someone feels inclined to want to take my observations on
board & create a power of 2 version of the istvan formula?

I will get to a solution of my own eventually however i'm sure..... & whilst
i'm definately barking in the right direction, i'm not sure how many cracks
of the whip it's going to take me to hit the bullseye exactly....

can we have a power of 2 tempo ramp option then? does this sound like
something blue could also utilise steven?

thanks everyone for helping to drive this forward.....


-- 
View this message in context: http://www.nabble.com/tempo-ramp-by-integration---help-needed-tf4400537.html#a12565436
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-09-08 03:17
FromTim Mortimer
SubjectRe: tempo ramp by integration - help needed
I think my integrated formula is the source of any lingering problems

example:
x = 4 beats
y0 = 0.5 (temposcalar of 120BPM)
y1 = 2 (temposcalar of 30BPM)
yrange = 1.5

f(x) = ((sqrt(1.5)*x)/4)^2 - is that the same as what i wrote originally? to
be honest, my maths fundamentals are so bad i don't really even know (i can
do year 12 calculus, but my year 10 algebra unfortunately is still a gaping
black hole! ; )

example for immediately above:

if x = 4

f(x) = ((sqrt(1.5)*4)/4)^2

f(x) = 1.5 correct.

so is the integration of ((sqrt(1.5)*x)/4)^2

as Ugur suggested...

Integral[ x^2*(sqrt(1.5)/4)^2 ] = (sqrt(1.5)/4)*Integral[ x^2 ]
= 1.5/16 Integral [ x^2 ] = 3/32 * [ 1/3 * x^3] = x^3/32

or have i found the error...?? was there an "algebraic formatting" error in
my original proposed f(x)?

integration of the CORRECT formula is...

??? 

anyway im pretty sure this is it. I can definately obtain 5 seconds as the
solution to my example if there is a linear tempo ramp from 120bpm to 30bpm
no problems (the extra 3 seconds of time being equal to area of the triangle
of the extra time... = (4sec x yrange 1.5)/2 = 6/2 = 3seconds...)


-- 
View this message in context: http://www.nabble.com/tempo-ramp-by-integration---help-needed-tf4400537.html#a12566095
Sent from the Csound - General mailing list archive at Nabble.com.