diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index 3297e0b2c1..4895d8f13e 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -34,7 +34,7 @@ public: int flush_header () { return 0; } float sample_rate () const { return _sample_rate; } - void set_length (samplecnt_t len) { _length = len; } + void set_length (samplecnt_t len) { _length = timecnt_t (len); } void flush () {} bool can_be_analysed() const { return false; } @@ -50,7 +50,7 @@ protected: , AudioFileSource (s, x, false) , _sample_rate(srate) { - _length = len; + _length = timecnt_t (len); } samplecnt_t read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const { diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 9ce317f33a..39383d431d 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -38,6 +38,10 @@ using namespace ARDOUR; using namespace std; using namespace PBD; +#include "ardour/audioengine.h" +#define S2SC(s) Temporal::samples_to_superclock (s, AudioEngine::instance()->sample_rate()) +#define SC2S(s) Temporal::superclock_to_samples (s, AudioEngine::instance()->sample_rate()) + AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden) : Playlist (session, node, DataType::AUDIO, hidden) { diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 6af04e0a7a..337f96cfdb 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -64,6 +64,10 @@ using namespace std; using namespace ARDOUR; using namespace PBD; +#include "ardour/audioengine.h" +#define S2SC(s) Temporal::samples_to_superclock (s, AudioEngine::instance()->sample_rate()) +#define SC2S(s) Temporal::superclock_to_samples (s, AudioEngine::instance()->sample_rate()) + namespace ARDOUR { namespace Properties { PBD::PropertyDescriptor envelope_active; @@ -706,6 +710,7 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, /* MIX OR COPY THE REGION BODY FROM mixdown_buffer INTO buf */ samplecnt_t const N = to_read - fade_in_limit - fade_out_limit; + if (N > 0) { if (is_opaque) { DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("Region %1 memcpy into buf @ %2 + %3, from mixdown buffer @ %4 + %5, len = %6 cnt was %7\n", @@ -735,6 +740,7 @@ samplecnt_t AudioRegion::read_from_sources (SourceList const & srcs, samplecnt_t limit, Sample* buf, samplepos_t position, samplecnt_t cnt, uint32_t chan_n) const { sampleoffset_t const internal_offset = position - _position.val().samples(); + if (internal_offset >= limit) { return 0; } @@ -747,6 +753,7 @@ AudioRegion::read_from_sources (SourceList const & srcs, samplecnt_t limit, Samp if (chan_n < n_channels()) { boost::shared_ptr src = boost::dynamic_pointer_cast (srcs[chan_n]); + if (src->read (buf, _start.val().samples() + internal_offset, to_read) != to_read) { return 0; /* "read nothing" */ } diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index f0837b9b3b..f08a63f825 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -1295,8 +1295,6 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai to_read = min (to_read, samples_to_read); assert (to_read >= 0); - // cerr << owner()->name() << " to-read: " << to_read << endl; - if (to_read) { ReaderChannelInfo* rci = dynamic_cast (chan); diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index cd62fb8cff..fe4575a484 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -224,7 +224,7 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, if (position < _position) { /* we are starting the read from before the start of the region */ - internal_offset = 0; + internal_offset = timecnt_t (Temporal::BeatTime);; dur -= position.distance (_position); } else { /* we are starting the read from after the start of the region */ @@ -300,7 +300,7 @@ MidiRegion::render (Evoral::EventSink& dst, if (!_position.val().zero()) { /* we are starting the read from before the start of the region */ - internal_offset = 0; + internal_offset = timecnt_t (Temporal::BeatTime); } else { /* we are starting the read from after the start of the region */ internal_offset = timecnt_t (-_position.val()); diff --git a/libs/ardour/mp3filesource.cc b/libs/ardour/mp3filesource.cc index 7b90e93f3d..d814cccd73 100644 --- a/libs/ardour/mp3filesource.cc +++ b/libs/ardour/mp3filesource.cc @@ -37,7 +37,7 @@ Mp3FileSource::Mp3FileSource (Session& s, const string& path, int chn, Flag flag , _mp3 (path) , _channel (chn) { - _length = _mp3.length (); + _length = timecnt_t (_mp3.length ()); if (_channel >= (int) _mp3.channels ()) { error << string_compose("Mp3FileSource: file only contains %1 channels; %2 is invalid as a channel number (%3)", _mp3.channels (), _channel, name()) << endmsg; diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index da24c00872..6f2273c30a 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -818,7 +818,7 @@ Region::move_start (timecnt_t const & distance) } else { if (_start < -distance) { - new_start = 0; + new_start = timecnt_t (_start.val().time_domain()); } else { new_start = start() + distance; } @@ -964,7 +964,7 @@ Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) } else if (start_shift.negative()) { if (start() < -start_shift && !can_trim_start_before_source_start ()) { - new_start = 0; + new_start = timecnt_t (start().time_domain()); } else { new_start = start() + start_shift; } diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index fb5d2e541f..e8bc5d33ae 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -381,7 +381,8 @@ SndFileSource::open () return -1; } - _length = _info.frames; + + _length = timecnt_t (_info.frames); #ifdef HAVE_RF64_RIFF if (_file_is_new && _length == 0 && writable()) {