From 4fe1fec54e85322d2bf7d9caa6c13047903bd362 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Nov 2021 14:38:52 -0700 Subject: [PATCH] when setting a default audio region envelope, coerce the endpoint to AudioTime Comment in code explains more --- libs/ardour/audioregion.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index db52df4839..d84c3eabef 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1280,7 +1280,18 @@ AudioRegion::set_default_envelope () _envelope->freeze (); _envelope->clear (); _envelope->fast_simple_add (timepos_t (Temporal::AudioTime), GAIN_COEFF_UNITY); - _envelope->fast_simple_add (timepos_t (_length), GAIN_COEFF_UNITY); + + /* Force length into audio time domain. If we don't do this, the + * envelope (which uses the AudioTime domain) will have problems when + * we call its fast_simple_add() mechanism and it discovers that the + * time is not AudioTime. + * + * XXX this needs some thought + */ + + timepos_t alen (length().samples()); + + _envelope->fast_simple_add (alen, GAIN_COEFF_UNITY); _envelope->thaw (); }