The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
	# start_tempo: beats per minute
	# end_tempo: beats per minute
	# nth: beat whose position we want
	# beats: total beats in ramp interval

	return 0 if $nth == 1;
	Audio::Nama::throw("$nth: zero or missing nth beat"), return if ! $nth;

	# To determine the start of a beat we accumlate
	# time through the end of the previous beat.

	# we will change time by a constant delta

	# delta = total change / number of steps (n)

	# increment first note length by 0 delta
	# increment second note by 1 delta
	# increment (nth) note by (n-1) delta
	
	# we only increment (no. of steps - 1) times, since the measure
	# following the ramp will presumably continue with the tempo
	# at ramp end. 

	# example: For 4 measures of 4/4, the delta is total change in beat length/16, 
	# we then increment length of subsequent beats from beat 2 to beat 16 by
	# delta. The first note of the next measure will be at the intended tempo

	my $t1 = bpm_to_length($start_bpm);
	my $tn = bpm_to_length($end_bpm);

	my $pos = $m * ($t1 + ($tn - $t1) / $n * ($m - 1) / 2);
    
	# Consider this ramp. The initial time interval 
    # 
    # t0  = 60 s / 100 bpm = 0.6 s.  
    # 
    # The final time interval after 16 beats is 
    # 
    # t16 = 60 s / 120 bpm = 0.5 s.
    # 
    # There are two ways I can think of for the time interval between beats to
    # change.  One is when the time interval changes linearly with the number of
    # beats; the other is that the time interval changes by a constant ratio with
    # each beat.
    # 
    # Let's consider the linear change first.  For your case, the time change
    # with each beat delta ("d") is given by
    # 
    # d = (tn - t1) / n  Where n is the number of notes in the chunk
    # 
    # The time Tm when the mth note ends is
    # Tm =  t1 + ...+ tm
    #     = t1 + (t1 + d) + (t1 + 2 d) + ,,, (t0 + (m-1)d )
    #     = m t1  +  (1 + ... m - 1) d
    # 
    # There are m - 1 terms in the sum (1 + 2 + ... m - 1), and
    # the average term is  (m / 2)  
    # 
    # sum = (m - 1)(m / 2)
    # 
    # Plugging into T,
    # 
    # Tm = m t1 +  d (m-1) m / 2
    # 
    # substitute d to get
    # 
    # Tm = m t1 +  (tn - t1) / n * (m - 1) * m  / 2
    # Tm = m (t1 + (tn - t1) / n * (m - 1) / 2 )

1 POD Error

The following errors were encountered while parsing the POD:

Around line 135:

Unknown directive: =comment