From a435d4d18e69cde83f60ac726232e3a587354173 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sun, 13 Mar 2022 10:59:39 -0500 Subject: [PATCH] Auditioner: round-up midi region length to seconds, at least 2 seconds long --- libs/ardour/auditioner.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 98073704c0..23ece75802 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -412,6 +412,14 @@ Auditioner::audition_region (boost::shared_ptr region, bool loop) midi_region = (boost::dynamic_pointer_cast (RegionFactory::create (region, false))); midi_region->set_position (_import_position); + /* avoid truncated notes: round up the length of midi regions to seconds, at least 2 seconds long */ + /* TODO: maybe round up to the nearest bar like it's done in import.cc write_midi_data_to_new_files */ + samplecnt_t smpl = midi_region->length_samples(); + double seconds = smpl/_session.sample_rate(); + seconds = min (2.0, ceil(seconds)); + timecnt_t new_len( seconds * _session.sample_rate() ); + midi_region->set_length(new_len); + _disk_reader->audio_playlist()->drop_regions(); _disk_reader->midi_playlist()->drop_regions ();