another day of slow timeline type conversion

This commit is contained in:
Paul Davis 2020-10-02 21:26:17 -06:00
parent db8b054543
commit 04e8dbb342
20 changed files with 138 additions and 99 deletions

View file

@ -483,7 +483,7 @@ AudioRegionView::reset_width_dependent_items (double pixel_width)
return;
}
samplepos_t position = _region->position();
samplepos_t position = _region->position_sample();
AnalysisFeatureList::const_iterator i;
list<std::pair<samplepos_t, ArdourCanvas::Line*> >::iterator l;
@ -598,7 +598,7 @@ AudioRegionView::set_height (gdouble height)
reset_fade_shapes ();
/* Update heights for any feature lines */
samplepos_t position = _region->position();
samplepos_t position = _region->position_sample();
list<std::pair<samplepos_t, ArdourCanvas::Line*> >::iterator l;
double y1;
if (_height >= NAME_HIGHLIGHT_THRESH) {
@ -629,7 +629,7 @@ AudioRegionView::reset_fade_shapes ()
void
AudioRegionView::reset_fade_in_shape ()
{
reset_fade_in_shape_width (audio_region(), (samplecnt_t) audio_region()->fade_in()->back()->when);
reset_fade_in_shape_width (audio_region(), audio_region()->fade_in()->back()->when.samples());
}
void
@ -645,7 +645,7 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr<AudioRegion> ar, s
width = std::max ((samplecnt_t) 64, width);
/* round here to prevent little visual glitches with sub-pixel placement */
double const pwidth = floor (width / samples_per_pixel);
double const pwidth = (double) width / samples_per_pixel;
double const handle_left = pwidth;
/* Put the fade in handle so that its left side is at the end-of-fade line */
@ -662,7 +662,7 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr<AudioRegion> ar, s
entered();
}
if (pwidth < 5) {
if (pwidth < 5.f) {
hide_start_xfade();
return;
}
@ -686,12 +686,13 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr<AudioRegion> ar, s
Points::size_type pi;
boost::shared_ptr<const Evoral::ControlList> list (audio_region()->fade_in());
Evoral::ControlList::const_iterator x;
double length = list->length();
samplecnt_t length = list->length().samples();
points.assign (list->size(), Duple());
for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) {
points[pi].x = (pwidth * ((*x)->when/length));
const double p = (*x)->when.samples();
points[pi].x = (p * pwidth) / length;
points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
}
@ -708,7 +709,7 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr<AudioRegion> ar, s
void
AudioRegionView::reset_fade_out_shape ()
{
reset_fade_out_shape_width (audio_region(), (samplecnt_t) audio_region()->fade_out()->back()->when);
reset_fade_out_shape_width (audio_region(), audio_region()->fade_out()->back()->when.samples());
}
void
@ -730,8 +731,8 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr<AudioRegion> ar,
* width is zero. Hence the additional + 1.0 at the end.
*/
double const handle_right = rint(trackview.editor().sample_to_pixel (_region->length()) - pwidth);
double const trim_handle_right = rint(trackview.editor().sample_to_pixel (_region->length()));
double const handle_right = rint(trackview.editor().sample_to_pixel (_region->length_samples()) - pwidth);
double const trim_handle_right = rint(trackview.editor().sample_to_pixel (_region->length_samples()));
/* Put the fade out handle so that its right side is at the end-of-fade line;
*/
@ -772,12 +773,13 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr<AudioRegion> ar,
Points::size_type pi;
boost::shared_ptr<const Evoral::ControlList> list (audio_region()->fade_out());
Evoral::ControlList::const_iterator x;
double length = list->length();
double length = list->length().samples();
points.assign (list->size(), Duple());
for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) {
points[pi].x = _pixel_width - pwidth + (pwidth * ((*x)->when/length));
const double p = (*x)->when.samples();
points[pi].x = _pixel_width - pwidth + (pwidth * (p/length));
points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
}
@ -794,13 +796,13 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr<AudioRegion> ar,
samplepos_t
AudioRegionView::get_fade_in_shape_width ()
{
return audio_region()->fade_in()->back()->when;
return audio_region()->fade_in()->back()->when.samples();
}
samplepos_t
AudioRegionView::get_fade_out_shape_width ()
{
return audio_region()->fade_out()->back()->when;
return audio_region()->fade_out()->back()->when.samples();
}
@ -814,7 +816,7 @@ AudioRegionView::redraw_start_xfade ()
}
show_start_xfade();
reset_fade_in_shape_width (ar, ar->fade_in()->back()->when);
reset_fade_in_shape_width (ar, ar->fade_in()->back()->when.samples());
}
void
@ -878,11 +880,12 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, sampl
Evoral::ControlList::const_iterator x;
Points::size_type pi;
double length = inverse->length();
const double length = inverse->length().samples();
for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) {
ArdourCanvas::Duple& p (ipoints[pi]);
p.x = (rect_width * ((*x)->when/length));
double pos = (*x)->when.samples();
p.x = (rect_width * (pos/length));
p.y = effective_height - ((*x)->value * (effective_height));
}
}
@ -903,7 +906,7 @@ AudioRegionView::redraw_end_xfade ()
show_end_xfade();
reset_fade_out_shape_width (ar, ar->fade_out()->back()->when);
reset_fade_out_shape_width (ar, ar->fade_out()->back()->when.samples());
}
void
@ -967,15 +970,16 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, samplec
npoints = inverse->size();
ipoints.assign (npoints, Duple());
const double rend = trackview.editor().sample_to_pixel (_region->length() - width);
const double rend = trackview.editor().sample_to_pixel (_region->length_samples() - width);
Evoral::ControlList::const_iterator x;
Points::size_type pi;
double length = inverse->length();
const double length = inverse->length().samples();
for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) {
ArdourCanvas::Duple& p (ipoints[pi]);
p.x = (rect_width * ((*x)->when/length)) + rend;
const double pos = (*x)->when.samples();
p.x = (rect_width * (pos/length)) + rend;
p.y = effective_height - ((*x)->value * (effective_height));
}
}
@ -1375,12 +1379,12 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b
/* don't create points that can't be seen */
update_envelope_visibility ();
samplepos_t rpos = region ()->position ();
MusicSample snap_pos (trackview.editor().pixel_to_sample (mx) + rpos, 0);
samplepos_t rpos = region ()->position_sample();
timepos_t snap_pos = timepos_t (trackview.editor().pixel_to_sample (mx) + rpos);
trackview.editor ().snap_to_with_modifier (snap_pos, ev);
samplepos_t fx = snap_pos.sample - rpos;
samplepos_t fx = snap_pos.samples() - rpos;
if (fx > _region->length()) {
if (fx > _region->length_samples()) {
return;
}
@ -1406,7 +1410,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b
region_memento = new MementoCommand<AudioRegion>(*(audio_region().get()), &region_before, &region_after);
}
if (audio_region()->envelope()->editor_add (fx, y, with_guard_points)) {
if (audio_region()->envelope()->editor_add (timepos_t (fx), y, with_guard_points)) {
XMLNode &after = audio_region()->envelope()->get_state();
std::list<Selectable*> results;
@ -1418,7 +1422,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b
trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
gain_line->get_selectables (fx + region ()->position (), fx + region ()->position (), 0.0, 1.0, results);
gain_line->get_selectables (region ()->nt_position () + timecnt_t (fx), region ()->nt_position () + timecnt_t (fx), 0.0, 1.0, results);
trackview.editor ().get_selection ().set (results);
trackview.editor ().commit_reversible_command ();
@ -1444,7 +1448,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv)
return 0;
}
double unit_position = _region->position () / samples_per_pixel;
double unit_position = _region->position_sample () / samples_per_pixel;
AudioGhostRegion* ghost = new AudioGhostRegion (*this, tv, trackview, unit_position);
uint32_t nchans;
@ -1467,7 +1471,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv)
}
ghost->set_height ();
ghost->set_duration (_region->length() / samples_per_pixel);
ghost->set_duration (_region->length_samples() / samples_per_pixel);
ghost->set_colors();
ghosts.push_back (ghost);
@ -1682,7 +1686,7 @@ AudioRegionView::transients_changed ()
{
AnalysisFeatureList analysis_features;
_region->transients (analysis_features);
samplepos_t position = _region->position();
samplepos_t position = _region->position_sample();
samplepos_t first = _region->first_sample();
samplepos_t last = _region->last_sample();
@ -1753,7 +1757,7 @@ AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
float* pos = (float*) (*l).second->get_data ("position");
if (rint(new_pos) == rint(*pos)) {
samplepos_t position = _region->position();
samplepos_t position = _region->position_sample();
samplepos_t old_sample = (*l).first;
samplepos_t new_sample = trackview.editor().pixel_to_sample (new_pos) + position;
_region->update_transient (old_sample, new_sample);