nested MERGEs

Tobias Kunze t@ulysses.Stanford.EDU
Sun, 2 Mar 1997 16:16:37 -0800


A bug in score-select (merge t) makes the scheduler initialize its timing
information correctly only when each nested merge has at least one object
starting at time 0.

If no subobject starts at 0, the elements will be selected out of order:

 : (merge merge-0 ()
 :   (merge merge-1 ()
 :     (mute mute-1 (length 2 start .1 rhythm 1))
 :     (mute mute-2 (length 2 start .2 rhythm 1)))
 :   (merge merge-2 ()
 :     (mute mute-3 (length 2 start .3 rhythm 1))
 :     (mute mute-4 (length 2 start .4 rhythm 1))))
 :
 : Stella [Top-Level]: tlist merge-0 0
 : Mute-1
 :     0.10    1. #<RHYTHMIC-ELEMENT @ #x10827952>
 : Mute-3
 :     0.30    1. #<RHYTHMIC-ELEMENT @ #x10827bca>
 : Mute-2
 :     0.20    1. #<RHYTHMIC-ELEMENT @ #x10827a5a>
 : Mute-4
 :     0.40    1. #<RHYTHMIC-ELEMENT @ #x10827c62>
 : Mute-1
 :     1.10    2. #<RHYTHMIC-ELEMENT @ #x10827952>
 : Mute-2
 :     1.20    2. #<RHYTHMIC-ELEMENT @ #x10827a5a>
 : Mute-3
 :     1.30    2. #<RHYTHMIC-ELEMENT @ #x10827bca>
 : Mute-4
 :     1.40    2. #<RHYTHMIC-ELEMENT @ #x10827c62>
 :
 : Stella [Top-Level]:

The problem does not surface in MIDI real-time output (since the
output queues sort events again), but is definitely a problem when
you output to a file.

Again, the problem is due to the fact that, when it selects `merge-0',
score-select (merge t) correctly selects the two subobjects `merge-1'
and `merge-2' right after one another (since they both start at default
time 0), not knowing that the first actual output will be not before
.1 or .3, respectively.

The easiest workaround would be to insert a rest object at start 0 in
each merge:

 : (merge merge-0 ()
 :   (merge merge-1 ()
 :     (object rest start 0)
 :     (mute mute-1 (length 2 start .1 rhythm 1))
 :     (mute mute-2 (length 2 start .2 rhythm 1)))
 :   (merge merge-2 ()
 :     (object rest start 0)
 :     (mute mute-3 (length 2 start .3 rhythm 1))
 :     (mute mute-4 (length 2 start .4 rhythm 1))))
 :
 : Stella [Top-Level]: tlist merge-0 0
 : Merge-1
 :     0.00    1. #<REST 0#x107c9ef2>
 : Merge-2
 :             1. #<REST 0#x107ca0c2>
 : Mute-1
 :     0.10    1. #<RHYTHMIC-ELEMENT @ #x107c9f8a>
 : Mute-2
 :     0.20    1. #<RHYTHMIC-ELEMENT @ #x107ca022>
 : Mute-3
 :     0.30    1. #<RHYTHMIC-ELEMENT @ #x107ca15a>
 : Mute-4
 :     0.40    1. #<RHYTHMIC-ELEMENT @ #x107ca1f2>
 : Mute-1
 :     1.10    2. #<RHYTHMIC-ELEMENT @ #x107c9f8a>
 : Mute-2
 :     1.20    2. #<RHYTHMIC-ELEMENT @ #x107ca022>
 : Mute-3
 :     1.30    2. #<RHYTHMIC-ELEMENT @ #x107ca15a>
 : Mute-4
 :     1.40    2. #<RHYTHMIC-ELEMENT @ #x107ca1f2>
 :
 : Stella [Top-Level]:


Hope that helps,

-Tobias