... except Audacity.h; and in no others.
Do so even if Experimental.h gets multiply included, as in both the .h and
.cpp files.
This makes it easier to do a text scan to be sure there are no unintended quiet
changes of meaning because of omission of Experimental.h when the flag is
an enabled one.
Also move inclusions of Experimental.h earlier.
Also don't require Experimental.h to be preceded by Audacity.h to define
EXPERIMENTAL_MIDI_OUT correctly.
... Assuming that large unsigned magnitudes with high order bit set are not
the problem, but signed negatives of small magnitude may be:
1) Always cast the unsigned to signed in comparisons, not the other way.
Also:
2) Cast unsigned TERM to signed by itself, before subtracting. Don't cast
the result.
3) Rewrite some comparisons by moving subtracted term to other side.
See commits
d2fe7b1757d77d93d82d53685a118517a4d2e996
f463eda36c059236ecc168919c745eb687170c95
- Dead code from experiments in SelectionBar removed.
- Many warnings about unused parameters fixed with WXUNUSED()
- Many warnings about signed / unsigned comparisons cleaned up.
- Several 'local variable declared but not used' warnings fixed.
... whereas before, some incorrect disconituities could remain near the start
of the selection.
To find reproducible cases before this commit might involve varying the left
edge of the selection by small amounts, because this problem depended on
little roundoff errors.
... Which went wrong in some examples of an effect applied to part of an
envelope that contains only one point; the correct result should have
a level 1 in the selection and unchanged levels left and right of it, no
matter whether the sole point was before, in, or after the selection.
Simplification may still remove that sole point yet still leave the levels
outside the selection correct.
... Simplify. Don't assume e->mOffset is zero. Check consistency afterward.
Do not leave responsibility for simplification of discontinuities to higher
level code.
Allow real discontinuities at the end of the insertion; no more readjustment of
times of points.
... Comment in it says that it does not check for discontinuities if it
replaces!
This will not matter in the uses of it internal to the Envelope class, which
will in fact always be proper insertions, having checked first for the presence
of a point.
... And more generally, Envelope::CollapseRegion, should it be reused more
widely, is responsible for removing the points; WaveTrack code is relieved of
that.
... The function defined by the envelope is evaluated exactly at the times of
samples, but not between samples -- instead there is a simple interpolation.
Therefore the curve might not go through the control points when they are not at
sample times.
The exact value of the function defined by the envelope has no influence on
rendering of the sound in between samples. So this can make it clear that
the middle point has no influence at all in case three points are very close.
Drawing of other envelopes (Time track, Equalization curves) is not changed.
... So that even if the time is "slightly" (less than 1/2 sample interval) left
of the discontinuity, the right-hand limit is always used.
Thus this compensates for some roundoff errors when pasting one clip with
an envelope into another.
This overcomes the objections that were in a comment in Envelope::Paste
to making control points with exactly equal times.
And therefore Paste can be rewritten to do so, but that has not happened yet.
Envelope points at exactly equal time coordinates can already be made by
dragging points in the envelope editor.
... Formerly this was done correctly only for cut and delete from WaveTrack,
paste into WaveTrack, and sync-lock adjustment of WaveTrack (either lengthening
or shortening).
Now also properly done for TimeTrack cut and paste, and also for:
Split cut
Split delete
Trim
... To be very sure we can avoid roundoff errors from adding mOffset and
subtracting it again; so that evaluation exactly at a control point time gives
the exact value of that point.
... rather than some of them being relative to the Envelope's offset.
In case of the envelopes used in TimeTrack or Equalization, offset was
always zero, so this doesn't matter, except to make the contract of the
Envelope class more explicit and sensible in isolation.
In case of InsertSpace at least, this does fix an obscure bug, which could
only happen when you have a clip, with an envelope, that starts before zero,
and you select a region overlapping that clip and some other clip, with a void
between, and you use the Join command.
Aren't you relieved that's fixed now?