summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorJesse Chappell <jesse@essej.net>2006-10-24 20:08:23 +0000
committerJesse Chappell <jesse@essej.net>2006-10-24 20:08:23 +0000
commit1b39adc4ce8566fd731cf433094b1faf4fe63205 (patch)
tree4ae795e7e527368b18fb1bc9e115c0dc137e9eb2 /libs
parentf9812be639d8935aa14b43359fb09bc8dff35749 (diff)
fixed gross inefficiency with tempo map most noticable when using the click at large frame positions. also fixed minor memory leak in click code.
git-svn-id: svn://localhost/ardour2/trunk@1006 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session_click.cc2
-rw-r--r--libs/ardour/tempo.cc28
2 files changed, 26 insertions, 4 deletions
diff --git a/libs/ardour/session_click.cc b/libs/ardour/session_click.cc
index 72ce4e25f6..7f9b142679 100644
--- a/libs/ardour/session_click.cc
+++ b/libs/ardour/session_click.cc
@@ -85,6 +85,8 @@ Session::click (nframes_t start, nframes_t nframes, nframes_t offset)
}
}
+ delete points;
+
run_clicks:
memset (buf, 0, sizeof (Sample) * nframes);
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 3cc5420c67..913218c91c 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1071,6 +1071,9 @@ TempoMap::get_points (nframes_t lower, nframes_t upper) const
double beat_frame;
double beat_frames;
double frames_per_bar;
+ double delta_bars;
+ double delta_beats;
+ double dummy;
nframes_t limit;
meter = &first_meter ();
@@ -1100,6 +1103,10 @@ TempoMap::get_points (nframes_t lower, nframes_t upper) const
Now start generating points.
*/
+ beats_per_bar = meter->beats_per_bar ();
+ frames_per_bar = meter->frames_per_bar (*tempo, _frame_rate);
+ beat_frames = tempo->frames_per_beat (_frame_rate);
+
if (meter->frame() > tempo->frame()) {
bar = meter->start().bars;
beat = meter->start().beats;
@@ -1110,12 +1117,21 @@ TempoMap::get_points (nframes_t lower, nframes_t upper) const
current = tempo->frame();
}
+ /* initialize current to point to the bar/beat just prior to the
+ lower frame bound passed in. assumes that current is initialized
+ above to be on a beat.
+ */
+
+ delta_bars = (lower-current) / frames_per_bar;
+ delta_beats = modf(delta_bars, &dummy) * beats_per_bar;
+ current += (floor(delta_bars) * frames_per_bar) + (floor(delta_beats) * beat_frames);
+
+ // adjust bars and beats too
+ bar += (uint32_t) (floor(delta_bars));
+ beat += (uint32_t) (floor(delta_beats));
+
points = new BBTPointList;
- beats_per_bar = meter->beats_per_bar ();
- frames_per_bar = meter->frames_per_bar (*tempo, _frame_rate);
- beat_frames = tempo->frames_per_beat (_frame_rate);
-
do {
if (i == metrics->end()) {
@@ -1197,6 +1213,10 @@ TempoMap::get_points (nframes_t lower, nframes_t upper) const
beat = 1;
}
+ beats_per_bar = meter->beats_per_bar ();
+ frames_per_bar = meter->frames_per_bar (*tempo, _frame_rate);
+ beat_frames = tempo->frames_per_beat (_frame_rate);
+
++i;
}