Previous: Sound Up: A Bestiary of Kiwi Objects Next: Task and Processor
The ScoreList reads the score file and constructs a Note for each line of the score file (Figure 5.5 shows a typical score file). Each Note holds a copy of the corresponding line of text in the score file, the starting and ending times, a pointer to the next Note in the score, and a pointer to the Sound which generates its samples.
After constructing the linked list of Notes, the ScoreList computes the maximum number of simultaneous notes. The number of simultaneous notes is a time-varying function defined over the entire duration of the piece. The naive method for computing the maximum of this function is to compute its value at each sample time and keep the biggest value. This is very expensive. Suppose instead the algorithm computes the function value at every th sample time. If then this would be 100 times faster than the naive algorithm. Unfortunately, the true maximum may lie in the untested samples. A better solution is to take advantage of the fact that the number of simultaneous notes versus time is a step function. The value of the function changes only at note boundaries (i. e., when a new note starts or an old note stops). Kiwi computes the number of simultaneous notes at each note boundary and keeps the biggest value. Since the number of notes in a piece is usually many orders of magnitude smaller than the number of samples, this technique is much more efficient than the naive algorithm.
Comments to walker@shout.net