Analysis of Audacity Revision 10680

Roger B. Dannenberg

November 2010

Background

Revision 10680 contains a lot of changes to support:
  1. Score Alignment (enabled by EXPERIMENTAL_SCOREALIGN)
  2. Midi Output (enabled by EXPERIMENTAL_MIDI_OUT)
  3. Note Track Display, Zooming, and Stretching (under USE_MIDI, which also enables/disables Note tracks altogether).
  4. Minor fix for Nyquist plugins. (not under any compile-time switches)
There are mistakes in r10680, especially regarding the use of compile-time switches. Some code is not enabled by compile-time switches, and some is enabled by the wrong compile-timei switch.

This webpage and the files it links to are an attempt to carefully analyze changes in r10680 in order to find and correct any remaining bugs. The main goal is to describe what I did, what the changes look like, and to preserve the work for later reference if needed.

The main idea for analysis was to run the preprocessor on sources to identify differences. In practice, differences show up because the preprocessor inserts source file names, line numbers, and other things that are irrelevant to the analysis. I wrote some scripts to replace line numbers with "NNNN" and do other text manipulation to make the preprocessed files comparable.

USE_MIDI

Nearly every change in 10680 is controlled by USE_MIDI (if USE_MIDI is not defined, then EXPERIMENTAL_SCOREALIGN and EXPERIMENTAL_MIDI_OUT are not defined either), so in principle, if USE_MIDI is undefined, r10680 should match r10679. If true, this can be demonstrated by preprocessing the source files (.cpp and .c) and comparing the outputs.

This was done, and as expected, there were significant mismatches between the preprocessed files. I commented on all the changes, and modified a working copy of r10680 in order to eliminate the mismatches. The original differences, more-or-less what you would find if you diff'ed r10679 and r10680, is here.

Unfortunately for this analysis, there were many intentional changes toddd the source code to make it easier to extend to support new features. For example, if MixerBoard.cpp was written using Tracks instead of WaveTracks, it would be more extensible to handle Midi output. Similarly, if ASliders were extended to support a Velocity slider in addition to the existing Gain and Pan sliders, it would make Midi output support much easier.

On the other hand, unless these changes are under USE_MIDI, a comparison of r10679 to r10680 will turn up these many intensional changes and parhaps obscure some accidental changes. Putting all these intensional changes under conditional compilation requires many more changes, but at least one can then verify that the changes are correct (in that they lead to identical code after preprocessing when USE_MIDI is undefined).

After modifying a working copy of r10680 to match r10679 when USE_MIDI is undefined, we can make a diff of the original r10680 to the working copy of r10680. These changes can be applied to the latest version, and after resolving conflicts, should yield a version that is essentially equivalent to r10679 when USE_MIDI is undefined. The set of changes is here (these changes have NOT yet been applied to the latest revision.)

EXPERIMENTAL_MIDI_OUT

I tried to do the same preprocessor trick with USE_MIDI on and EXPERIMENTAL_MIDI_OUT undefined. The differences between r10679 and r10680 in this case should be limited to Note track drawing and interaction. Unfortunately, because of additional include files, the diff in this case is quite large. It is here.

Another way to "verify" the correctness of changes in r10680 is to compare r10680 without EXPERIMENTAL_MIDI_OUT to r10680 with EXPERIMENTAL_MIDI_OUT. The differences should be limited to things that implement midi output. To make this work, I had to eliminate the preprocessing of include files and play some other tricks, but the result really does help to see what changes are controlled by the EXPERIMENTAL_MIDI_OUT flag. A commented set of differences is here.

EXPERIMENTAL_SCOREALIGN

Similary, you can do the same thing with EXPERIMENTAL_SCOREALIGN -- these changes should only be ones that implement the "synchronize midi to audio" function on the Tracks menu. A list of changes that are controlled by EXPERIMENTAL_SCOREALIGN is here.

Results

As I examined changes, I made corrections to a working copy of r10680 and recomputed the changes until the changes looked right. Finally, we can diff r10680 with the working copy to see what corrections were needed. These are then the "mistakes" that need to be applied to the latest version. The changes are here.

These changes have not yet been applied to the head of Audacity, but many of these changes have already been made in revisions subsequent to r10680.