mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
NO-OP: whitespace
This commit is contained in:
parent
91a213427e
commit
2377927fc1
1 changed files with 438 additions and 478 deletions
|
|
@ -26,14 +26,14 @@
|
||||||
#include "evoral/Range.h"
|
#include "evoral/Range.h"
|
||||||
|
|
||||||
#include "ardour/amp.h"
|
#include "ardour/amp.h"
|
||||||
|
#include "ardour/audio_buffer.h"
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
#include "ardour/audioplaylist.h"
|
#include "ardour/audioplaylist.h"
|
||||||
#include "ardour/audio_buffer.h"
|
|
||||||
#include "ardour/butler.h"
|
#include "ardour/butler.h"
|
||||||
#include "ardour/debug.h"
|
#include "ardour/debug.h"
|
||||||
#include "ardour/disk_reader.h"
|
#include "ardour/disk_reader.h"
|
||||||
#include "ardour/midi_ring_buffer.h"
|
|
||||||
#include "ardour/midi_playlist.h"
|
#include "ardour/midi_playlist.h"
|
||||||
|
#include "ardour/midi_ring_buffer.h"
|
||||||
#include "ardour/midi_track.h"
|
#include "ardour/midi_track.h"
|
||||||
#include "ardour/pannable.h"
|
#include "ardour/pannable.h"
|
||||||
#include "ardour/playlist.h"
|
#include "ardour/playlist.h"
|
||||||
|
|
@ -77,7 +77,8 @@ DiskReader::~DiskReader ()
|
||||||
void
|
void
|
||||||
DiskReader::ReaderChannelInfo::resize (samplecnt_t bufsize)
|
DiskReader::ReaderChannelInfo::resize (samplecnt_t bufsize)
|
||||||
{
|
{
|
||||||
delete rbuf; rbuf = 0;
|
delete rbuf;
|
||||||
|
rbuf = 0;
|
||||||
|
|
||||||
rbuf = new PlaybackBuffer<Sample> (bufsize);
|
rbuf = new PlaybackBuffer<Sample> (bufsize);
|
||||||
/* touch memory to lock it */
|
/* touch memory to lock it */
|
||||||
|
|
@ -196,13 +197,13 @@ float
|
||||||
DiskReader::buffer_load () const
|
DiskReader::buffer_load () const
|
||||||
{
|
{
|
||||||
/* Note: for MIDI it's not trivial to differentiate the following two cases:
|
/* Note: for MIDI it's not trivial to differentiate the following two cases:
|
||||||
|
*
|
||||||
1. The playback buffer is empty because the system has run out of time to fill it.
|
* 1. The playback buffer is empty because the system has run out of time to fill it.
|
||||||
2. The playback buffer is empty because there is no more data on the playlist.
|
* 2. The playback buffer is empty because there is no more data on the playlist.
|
||||||
|
*
|
||||||
If we use a simple buffer load computation, we will report that the MIDI diskstream
|
* If we use a simple buffer load computation, we will report that the MIDI diskstream
|
||||||
cannot keep up when #2 happens, when in fact it can. Since MIDI data rates
|
* cannot keep up when #2 happens, when in fact it can. Since MIDI data rates
|
||||||
are so low compared to audio, just use the audio value here.
|
* are so low compared to audio, just use the audio value here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boost::shared_ptr<ChannelList> c = channels.reader ();
|
boost::shared_ptr<ChannelList> c = channels.reader ();
|
||||||
|
|
@ -282,18 +283,15 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
bool declick_out = (_declick_amp.gain () != target_gain) && target_gain == 0.0;
|
bool declick_out = (_declick_amp.gain () != target_gain) && target_gain == 0.0;
|
||||||
|
|
||||||
if (!_session.cfg ()->get_use_transport_fades () || (_session.exporting () && !_session.realtime_export ())) {
|
if (!_session.cfg ()->get_use_transport_fades () || (_session.exporting () && !_session.realtime_export ())) {
|
||||||
|
|
||||||
/* no transport fades or exporting - no declick out logic */
|
/* no transport fades or exporting - no declick out logic */
|
||||||
|
|
||||||
_declick_amp.set_gain (target_gain);
|
_declick_amp.set_gain (target_gain);
|
||||||
declick_out = false;
|
declick_out = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* using transport fades and not exporting - declick login in effect */
|
/* using transport fades and not exporting - declick login in effect */
|
||||||
|
|
||||||
if (ms == MonitoringDisk) {
|
if (ms == MonitoringDisk) {
|
||||||
|
|
||||||
/* Only monitoring from disk, so if we've finished a
|
/* Only monitoring from disk, so if we've finished a
|
||||||
* declick (for stop/locate), do not accidentally pass
|
* declick (for stop/locate), do not accidentally pass
|
||||||
* any data from disk to our outputs.
|
* any data from disk to our outputs.
|
||||||
|
|
@ -301,8 +299,7 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
|
|
||||||
if ((target_gain == 0.0) && (_declick_amp.gain () == target_gain)) {
|
if ((target_gain == 0.0) && (_declick_amp.gain () == target_gain)) {
|
||||||
/* we were heading for zero (declick out for
|
/* we were heading for zero (declick out for
|
||||||
stop), and we've reached there. Done.
|
* stop), and we've reached there. Done. */
|
||||||
*/
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -337,7 +334,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating || _no_disk_output) {
|
if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating || _no_disk_output) {
|
||||||
|
|
||||||
/* no need for actual disk data, just advance read pointer */
|
/* no need for actual disk data, just advance read pointer */
|
||||||
|
|
||||||
if (!still_locating || _no_disk_output) {
|
if (!still_locating || _no_disk_output) {
|
||||||
|
|
@ -354,7 +350,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* we need audio data from disk */
|
/* we need audio data from disk */
|
||||||
|
|
||||||
size_t n_buffers = bufs.count ().n_audio ();
|
size_t n_buffers = bufs.count ().n_audio ();
|
||||||
|
|
@ -371,7 +366,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
const sampleoffset_t declick_offs = _declick_offs;
|
const sampleoffset_t declick_offs = _declick_offs;
|
||||||
|
|
||||||
for (n = 0, chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
for (n = 0, chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
||||||
|
|
||||||
ChannelInfo* chaninfo (*chan);
|
ChannelInfo* chaninfo (*chan);
|
||||||
AudioBuffer& output (bufs.get_audio (n % n_buffers));
|
AudioBuffer& output (bufs.get_audio (n % n_buffers));
|
||||||
|
|
||||||
|
|
@ -395,7 +389,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
_declick_amp.set_gain (initial_declick_gain);
|
_declick_amp.set_gain (initial_declick_gain);
|
||||||
|
|
||||||
if (!declick_out) {
|
if (!declick_out) {
|
||||||
|
|
||||||
const samplecnt_t available = chaninfo->rbuf->read (disk_buf.data (), disk_samples_to_consume);
|
const samplecnt_t available = chaninfo->rbuf->read (disk_buf.data (), disk_samples_to_consume);
|
||||||
|
|
||||||
if (disk_samples_to_consume > available) {
|
if (disk_samples_to_consume > available) {
|
||||||
|
|
@ -406,16 +399,15 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (_declick_amp.gain () != target_gain) {
|
} else if (_declick_amp.gain () != target_gain) {
|
||||||
|
|
||||||
assert (target_gain == 0);
|
assert (target_gain == 0);
|
||||||
|
|
||||||
/* note that this is a non-committing read: it
|
/* note that this is a non-committing read: it
|
||||||
retrieves data from the ringbuffer but does not
|
* retrieves data from the ringbuffer but does not
|
||||||
advance the read pointer. As a result,
|
* advance the read pointer. As a result,
|
||||||
subsequent calls (as we declick) need to
|
* subsequent calls (as we declick) need to
|
||||||
pass in an offset describing where to read
|
* pass in an offset describing where to read
|
||||||
from. We maintain _declick_offs across calls
|
* from. We maintain _declick_offs across calls
|
||||||
to ::run()
|
* to ::run()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const samplecnt_t total = chaninfo->rbuf->read (disk_buf.data (), nframes, false, declick_offs);
|
const samplecnt_t total = chaninfo->rbuf->read (disk_buf.data (), nframes, false, declick_offs);
|
||||||
|
|
@ -427,9 +419,7 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
|
|
||||||
_declick_amp.apply_gain (disk_buf, nframes, target_gain);
|
_declick_amp.apply_gain (disk_buf, nframes, target_gain);
|
||||||
|
|
||||||
/* _declick_amp is now left with the correct gain after
|
/* _declick_amp is now left with the correct gain after processing nframes */
|
||||||
* processing nframes
|
|
||||||
*/
|
|
||||||
|
|
||||||
Amp::apply_simple_gain (disk_buf, nframes, scaling);
|
Amp::apply_simple_gain (disk_buf, nframes, scaling);
|
||||||
|
|
||||||
|
|
@ -440,7 +430,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
midi:
|
midi:
|
||||||
|
|
||||||
/* MIDI data handling */
|
/* MIDI data handling */
|
||||||
|
|
@ -448,7 +437,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
const bool no_playlist_modification_pending = !(pending_overwrite () & PlaylistModified);
|
const bool no_playlist_modification_pending = !(pending_overwrite () & PlaylistModified);
|
||||||
|
|
||||||
if (bufs.count ().n_midi ()) {
|
if (bufs.count ().n_midi ()) {
|
||||||
|
|
||||||
MidiBuffer& dst (bufs.get_midi (0));
|
MidiBuffer& dst (bufs.get_midi (0));
|
||||||
|
|
||||||
if (run_must_resolve) {
|
if (run_must_resolve) {
|
||||||
|
|
@ -464,7 +452,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
/* decide if we need the butler */
|
/* decide if we need the butler */
|
||||||
|
|
||||||
if (!still_locating && no_playlist_modification_pending) {
|
if (!still_locating && no_playlist_modification_pending) {
|
||||||
|
|
||||||
bool butler_required = false;
|
bool butler_required = false;
|
||||||
|
|
||||||
if (speed < 0.0) {
|
if (speed < 0.0) {
|
||||||
|
|
@ -531,7 +518,6 @@ DiskReader::set_pending_overwrite (OverwriteReason why)
|
||||||
/* called from audio thread, so we can use the read ptr and playback sample as we wish */
|
/* called from audio thread, so we can use the read ptr and playback sample as we wish */
|
||||||
|
|
||||||
if (!c->empty ()) {
|
if (!c->empty ()) {
|
||||||
|
|
||||||
const samplecnt_t reserved_size = c->front ()->rbuf->reserved_size ();
|
const samplecnt_t reserved_size = c->front ()->rbuf->reserved_size ();
|
||||||
const samplecnt_t bufsize = c->front ()->rbuf->bufsize ();
|
const samplecnt_t bufsize = c->front ()->rbuf->bufsize ();
|
||||||
|
|
||||||
|
|
@ -540,27 +526,25 @@ DiskReader::set_pending_overwrite (OverwriteReason why)
|
||||||
overwrite_offset = c->front ()->rbuf->read_ptr ();
|
overwrite_offset = c->front ()->rbuf->read_ptr ();
|
||||||
|
|
||||||
if (overwrite_offset > reserved_size) {
|
if (overwrite_offset > reserved_size) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|----------------------------------------------------------------------|
|
* |----------------------------------------------------------------------|
|
||||||
^ ^
|
* ^ ^
|
||||||
RRRRRRRRRRRRRRRRoverwrite_offset (old read_ptr)
|
* RRRRRRRRRRRRRRRRoverwrite_offset (old read_ptr)
|
||||||
|<- second ->|<------------------ first chunk ------------------------>|
|
* |<- second ->|<------------------ first chunk ------------------------>|
|
||||||
|
*
|
||||||
Fill the the end of the buffer ("first chunk"), above
|
* Fill the the end of the buffer ("first chunk"), above
|
||||||
*/
|
*/
|
||||||
|
|
||||||
overwrite_offset -= reserved_size;
|
overwrite_offset -= reserved_size;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|----------------------------------------------------------------------|
|
* |----------------------------------------------------------------------|
|
||||||
RRRRRRRRE^ RRRRRRRRR
|
* RRRRRRRRE^ RRRRRRRRR
|
||||||
overwrite_offset (old read_ptr)
|
* overwrite_offset (old read_ptr)
|
||||||
|< second chunk >|<first>|
|
* |< second chunk >|<first>|
|
||||||
|
*
|
||||||
Fill the end of the buffer ("R1R1R1" aka "first" above)
|
* Fill the end of the buffer ("R1R1R1" aka "first" above)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
overwrite_offset = bufsize - (reserved_size - overwrite_offset);
|
overwrite_offset = bufsize - (reserved_size - overwrite_offset);
|
||||||
|
|
@ -578,7 +562,6 @@ DiskReader::set_pending_overwrite (OverwriteReason why)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -638,7 +621,6 @@ DiskReader::overwrite_existing_audio ()
|
||||||
* simply replace the contents of the buffer.
|
* simply replace the contents of the buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<ChannelList> c = channels.reader ();
|
boost::shared_ptr<ChannelList> c = channels.reader ();
|
||||||
|
|
||||||
if (c->empty ()) {
|
if (c->empty ()) {
|
||||||
|
|
@ -672,7 +654,6 @@ DiskReader::overwrite_existing_audio ()
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan, ++n) {
|
||||||
|
|
||||||
samplepos_t start = overwrite_sample;
|
samplepos_t start = overwrite_sample;
|
||||||
|
|
||||||
Sample* buf = (*chan)->rbuf->buffer ();
|
Sample* buf = (*chan)->rbuf->buffer ();
|
||||||
|
|
@ -751,6 +732,7 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
|
||||||
/* called via non_realtime_locate() from butler thread */
|
/* called via non_realtime_locate() from butler thread */
|
||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
const bool read_reversed = !_session.transport_will_roll_forwards ();
|
const bool read_reversed = !_session.transport_will_roll_forwards ();
|
||||||
const bool read_loop = (bool)_loop_location;
|
const bool read_loop = (bool)_loop_location;
|
||||||
|
|
||||||
|
|
@ -769,7 +751,6 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((_last_read_reversed.value_or (read_reversed) == read_reversed) && (_last_read_loop.value_or (read_loop) == read_loop)) {
|
if ((_last_read_reversed.value_or (read_reversed) == read_reversed) && (_last_read_loop.value_or (read_loop) == read_loop)) {
|
||||||
|
|
||||||
if (sample == playback_sample && !complete_refill) {
|
if (sample == playback_sample && !complete_refill) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -796,10 +777,10 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move the intended read target, so that after the refill is done,
|
/* move the intended read target, so that after the refill is done,
|
||||||
the intended read target is "reservation" from the start of the
|
* the intended read target is "reservation" from the start of the
|
||||||
playback buffer. Then increment the read ptr, so that we can
|
* playback buffer. Then increment the read ptr, so that we can
|
||||||
potentially do an internal seek backwards of up "reservation"
|
* potentially do an internal seek backwards of up "reservation"
|
||||||
samples.
|
* samples.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
samplecnt_t shift = sample > c->front ()->rbuf->reservation_size () ? c->front ()->rbuf->reservation_size () : sample;
|
samplecnt_t shift = sample > c->front ()->rbuf->reservation_size () ? c->front ()->rbuf->reservation_size () : sample;
|
||||||
|
|
@ -808,8 +789,7 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
|
||||||
|
|
||||||
if (read_reversed) {
|
if (read_reversed) {
|
||||||
/* reading in reverse, so start at a later sample, and read
|
/* reading in reverse, so start at a later sample, and read
|
||||||
"backwards" from there.
|
* "backwards" from there. */
|
||||||
*/
|
|
||||||
shift = -shift;
|
shift = -shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -823,18 +803,15 @@ DiskReader::seek (samplepos_t sample, bool complete_refill)
|
||||||
|
|
||||||
if (complete_refill) {
|
if (complete_refill) {
|
||||||
/* call _do_refill() to refill the entire buffer, using
|
/* call _do_refill() to refill the entire buffer, using
|
||||||
the largest reads possible.
|
* the largest reads possible. */
|
||||||
*/
|
while ((ret = do_refill_with_alloc (false, read_reversed)) > 0)
|
||||||
while ((ret = do_refill_with_alloc (false, read_reversed)) > 0) ;
|
;
|
||||||
} else {
|
} else {
|
||||||
/* call _do_refill() to refill just one chunk, and then
|
/* call _do_refill() to refill just one chunk, and then return. */
|
||||||
return.
|
|
||||||
*/
|
|
||||||
ret = do_refill_with_alloc (true, read_reversed);
|
ret = do_refill_with_alloc (true, read_reversed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shift) {
|
if (shift) {
|
||||||
|
|
||||||
/* now tell everyone where we really are, leaving the
|
/* now tell everyone where we really are, leaving the
|
||||||
* "reserved" data represented by "shift" available in the
|
* "reserved" data represented by "shift" available in the
|
||||||
* buffer for backwards-internal-seek
|
* buffer for backwards-internal-seek
|
||||||
|
|
@ -898,8 +875,8 @@ DiskReader::internal_playback_seek (sampleoffset_t distance)
|
||||||
playback_sample += off;
|
playback_sample += off;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
void swap_by_ptr (Sample *first, Sample *last)
|
swap_by_ptr (Sample* first, Sample* last)
|
||||||
{
|
{
|
||||||
while (first < last) {
|
while (first < last) {
|
||||||
Sample tmp = *first;
|
Sample tmp = *first;
|
||||||
|
|
@ -935,7 +912,6 @@ DiskReader::audio_read (Sample* sum_buffer,
|
||||||
/* XXX we don't currently play loops in reverse. not sure why */
|
/* XXX we don't currently play loops in reverse. not sure why */
|
||||||
|
|
||||||
if (!reversed) {
|
if (!reversed) {
|
||||||
|
|
||||||
samplecnt_t loop_length = 0;
|
samplecnt_t loop_length = 0;
|
||||||
|
|
||||||
/* Make the use of a Location atomic for this read operation.
|
/* Make the use of a Location atomic for this read operation.
|
||||||
|
|
@ -952,14 +928,13 @@ DiskReader::audio_read (Sample* sum_buffer,
|
||||||
loop_length = loop_end - loop_start;
|
loop_length = loop_end - loop_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we are looping, ensure that the first sample we read is at the correct
|
/* if we are looping, ensure that the first sample we read is at the
|
||||||
position within the loop.
|
* correct position within the loop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (loc && start >= loop_end) {
|
if (loc && start >= loop_end) {
|
||||||
start = loop_start + ((start - loop_start) % loop_length);
|
start = loop_start + ((start - loop_start) % loop_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reversed) {
|
if (reversed) {
|
||||||
|
|
@ -967,11 +942,9 @@ DiskReader::audio_read (Sample* sum_buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need this while loop in case we hit a loop boundary, in which case our read from
|
/* We need this while loop in case we hit a loop boundary, in which case our read from
|
||||||
the playlist must be split into more than one section.
|
* the playlist must be split into more than one section. */
|
||||||
*/
|
|
||||||
|
|
||||||
while (cnt) {
|
while (cnt) {
|
||||||
|
|
||||||
/* take any loop into account. we can't read past the end of the loop. */
|
/* take any loop into account. we can't read past the end of the loop. */
|
||||||
|
|
||||||
if (loc && (loop_end - start < cnt)) {
|
if (loc && (loop_end - start < cnt)) {
|
||||||
|
|
@ -999,7 +972,6 @@ DiskReader::audio_read (Sample* sum_buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc) {
|
if (loc) {
|
||||||
|
|
||||||
/* Looping: do something (maybe) about the loop boundaries */
|
/* Looping: do something (maybe) about the loop boundaries */
|
||||||
|
|
||||||
switch (Config->get_loop_fade_choice ()) {
|
switch (Config->get_loop_fade_choice ()) {
|
||||||
|
|
@ -1019,11 +991,9 @@ DiskReader::audio_read (Sample* sum_buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reversed) {
|
if (reversed) {
|
||||||
|
|
||||||
swap_by_ptr (sum_buffer, sum_buffer + this_read - 1);
|
swap_by_ptr (sum_buffer, sum_buffer + this_read - 1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* if we read to the end of the loop, go back to the beginning */
|
/* if we read to the end of the loop, go back to the beginning */
|
||||||
|
|
||||||
if (reloop) {
|
if (reloop) {
|
||||||
|
|
@ -1054,9 +1024,9 @@ int
|
||||||
DiskReader::do_refill_with_alloc (bool partial_fill, bool reversed)
|
DiskReader::do_refill_with_alloc (bool partial_fill, bool reversed)
|
||||||
{
|
{
|
||||||
/* We limit disk reads to at most 4MB chunks, which with floating point
|
/* We limit disk reads to at most 4MB chunks, which with floating point
|
||||||
samples would be 1M samples. But we might use 16 or 14 bit samples,
|
* samples would be 1M samples. But we might use 16 or 14 bit samples,
|
||||||
in which case 4MB is more samples than that. Therefore size this for
|
* in which case 4MB is more samples than that. Therefore size this for
|
||||||
the smallest sample value .. 4MB = 2M samples (16 bit).
|
* the smallest sample value .. 4MB = 2M samples (16 bit).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boost::scoped_array<Sample> sum_buf (new Sample[2 * 1048576]);
|
boost::scoped_array<Sample> sum_buf (new Sample[2 * 1048576]);
|
||||||
|
|
@ -1070,7 +1040,7 @@ int
|
||||||
DiskReader::refill (Sample* sum_buffer, Sample* mixdown_buffer, float* gain_buffer, samplecnt_t fill_level, bool reversed)
|
DiskReader::refill (Sample* sum_buffer, Sample* mixdown_buffer, float* gain_buffer, samplecnt_t fill_level, bool reversed)
|
||||||
{
|
{
|
||||||
/* NOTE: Audio refill MUST come first so that in contexts where ONLY it
|
/* NOTE: Audio refill MUST come first so that in contexts where ONLY it
|
||||||
is called, _last_read_reversed is set correctly.
|
* is called, _last_read_reversed is set correctly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (refill_audio (sum_buffer, mixdown_buffer, gain_buffer, fill_level, reversed)) {
|
if (refill_audio (sum_buffer, mixdown_buffer, gain_buffer, fill_level, reversed)) {
|
||||||
|
|
@ -1084,7 +1054,6 @@ DiskReader::refill (Sample* sum_buffer, Sample* mixdown_buffer, float* gain_buff
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get some more data from disk and put it in our channels' bufs,
|
/** Get some more data from disk and put it in our channels' bufs,
|
||||||
* if there is suitable space in them.
|
* if there is suitable space in them.
|
||||||
*
|
*
|
||||||
|
|
@ -1138,14 +1107,14 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we're running close to normal speed and there isn't enough
|
/* if we're running close to normal speed and there isn't enough
|
||||||
space to do disk_read_chunk_samples of I/O, then don't bother.
|
* space to do disk_read_chunk_samples of I/O, then don't bother.
|
||||||
|
*
|
||||||
at higher speeds, just do it because the sync between butler
|
* at higher speeds, just do it because the sync between butler
|
||||||
and audio thread may not be good enough.
|
* and audio thread may not be good enough.
|
||||||
|
*
|
||||||
Note: it is a design assumption that disk_read_chunk_samples is smaller
|
* Note: it is a design assumption that disk_read_chunk_samples is smaller
|
||||||
than the playback buffer size, so this check should never trip when
|
* than the playback buffer size, so this check should never trip when
|
||||||
the playback buffer is empty.
|
* the playback buffer is empty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: space to refill %2 vs. chunk %3 (speed = %4)\n", name (), total_space, _chunk_samples, _session.transport_speed ()));
|
DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: space to refill %2 vs. chunk %3 (speed = %4)\n", name (), total_space, _chunk_samples, _session.transport_speed ()));
|
||||||
|
|
@ -1154,8 +1123,8 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when slaved, don't try to get too close to the read pointer. this
|
/* when slaved, don't try to get too close to the read pointer. this
|
||||||
leaves space for the buffer reversal to have something useful to
|
* leaves space for the buffer reversal to have something useful to
|
||||||
work with.
|
* work with.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (_slaved && total_space < (samplecnt_t) (c->front ()->rbuf->bufsize () / 2)) {
|
if (_slaved && total_space < (samplecnt_t) (c->front ()->rbuf->bufsize () / 2)) {
|
||||||
|
|
@ -1166,7 +1135,6 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
samplepos_t fsa = file_sample[DataType::AUDIO];
|
samplepos_t fsa = file_sample[DataType::AUDIO];
|
||||||
|
|
||||||
if (reversed) {
|
if (reversed) {
|
||||||
|
|
||||||
if (fsa == 0) {
|
if (fsa == 0) {
|
||||||
/* at start: nothing to do but fill with silence */
|
/* at start: nothing to do but fill with silence */
|
||||||
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
||||||
|
|
@ -1185,7 +1153,6 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (fsa == max_samplepos) {
|
if (fsa == max_samplepos) {
|
||||||
/* at end: nothing to do but fill with silence */
|
/* at end: nothing to do but fill with silence */
|
||||||
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
||||||
|
|
@ -1223,11 +1190,12 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
|
|
||||||
samplepos_t file_sample_tmp = fsa;
|
samplepos_t file_sample_tmp = fsa;
|
||||||
|
|
||||||
// int64_t before = g_get_monotonic_time ();
|
#if 0
|
||||||
// int64_t elapsed;
|
int64_t before = g_get_monotonic_time ();
|
||||||
|
int64_t elapsed;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
for (chan_n = 0, i = c->begin (); i != c->end (); ++i, ++chan_n) {
|
||||||
|
|
||||||
ChannelInfo* chan (*i);
|
ChannelInfo* chan (*i);
|
||||||
|
|
||||||
/* we want all channels to read from the same position, but
|
/* we want all channels to read from the same position, but
|
||||||
|
|
@ -1249,11 +1217,9 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
samplecnt_t nread;
|
samplecnt_t nread;
|
||||||
|
|
||||||
if (!_playlists[DataType::AUDIO]) {
|
if (!_playlists[DataType::AUDIO]) {
|
||||||
|
|
||||||
chan->rbuf->write_zero (to_read);
|
chan->rbuf->write_zero (to_read);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ((nread = audio_read (sum_buffer, mixdown_buffer, gain_buffer, file_sample_tmp, to_read, rci, chan_n, reversed)) != to_read) {
|
if ((nread = audio_read (sum_buffer, mixdown_buffer, gain_buffer, file_sample_tmp, to_read, rci, chan_n, reversed)) != to_read) {
|
||||||
error << string_compose (_("DiskReader %1: when refilling, cannot read %2 from playlist at sample %3"), name (), to_read, fsa) << endmsg;
|
error << string_compose (_("DiskReader %1: when refilling, cannot read %2 from playlist at sample %3"), name (), to_read, fsa) << endmsg;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
@ -1275,8 +1241,10 @@ DiskReader::refill_audio (Sample* sum_buffer, Sample* mixdown_buffer, float* gai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// elapsed = g_get_monotonic_time () - before;
|
#if 0
|
||||||
// cerr << '\t' << name() << ": bandwidth = " << (byte_size_for_read / 1048576.0) / (elapsed/1000000.0) << "MB/sec\n";
|
elapsed = g_get_monotonic_time () - before;
|
||||||
|
cerr << '\t' << name() << ": bandwidth = " << (byte_size_for_read / 1048576.0) / (elapsed/1000000.0) << "MB/sec\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
file_sample[DataType::AUDIO] = file_sample_tmp;
|
file_sample[DataType::AUDIO] = file_sample_tmp;
|
||||||
assert (file_sample[DataType::AUDIO] >= 0);
|
assert (file_sample[DataType::AUDIO] >= 0);
|
||||||
|
|
@ -1312,7 +1280,6 @@ DiskReader::playlist_ranges_moved (list< Evoral::RangeMove<samplepos_t> > const
|
||||||
for (list<Evoral::RangeMove<samplepos_t>>::const_iterator i = movements_samples.begin ();
|
for (list<Evoral::RangeMove<samplepos_t>>::const_iterator i = movements_samples.begin ();
|
||||||
i != movements_samples.end ();
|
i != movements_samples.end ();
|
||||||
++i) {
|
++i) {
|
||||||
|
|
||||||
movements.push_back (Evoral::RangeMove<double> (i->from, i->length, i->to));
|
movements.push_back (Evoral::RangeMove<double> (i->from, i->length, i->to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1365,9 +1332,7 @@ DiskReader::move_processor_automation (boost::weak_ptr<Processor> p, list< Evora
|
||||||
if (things_moved) {
|
if (things_moved) {
|
||||||
_session.add_command (
|
_session.add_command (
|
||||||
new MementoCommand<AutomationList> (
|
new MementoCommand<AutomationList> (
|
||||||
*al.get(), &before, &al->get_state ()
|
*al.get (), &before, &al->get_state ()));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1401,10 +1366,10 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
|
||||||
|
|
||||||
if (ms & MonitoringInput) {
|
if (ms & MonitoringInput) {
|
||||||
/* data from disk needs to be *merged* not written into the
|
/* data from disk needs to be *merged* not written into the
|
||||||
dst, because it may contain input data that we want to
|
* dst, because it may contain input data that we want to
|
||||||
monitor. Since RTMidiBuffer currently (Oct 2019) has no
|
* monitor. Since RTMidiBuffer currently (Oct 2019) has no
|
||||||
suitable method, put the disk data into a scratch buffer and
|
* suitable method, put the disk data into a scratch buffer and
|
||||||
then merge later.
|
* then merge later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
target = &scratch_bufs.get_midi (0);
|
target = &scratch_bufs.get_midi (0);
|
||||||
|
|
@ -1417,13 +1382,10 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_no_disk_output) {
|
if (!_no_disk_output) {
|
||||||
|
|
||||||
const samplecnt_t nframes = abs (end_sample - start_sample);
|
const samplecnt_t nframes = abs (end_sample - start_sample);
|
||||||
|
|
||||||
if (ms & MonitoringDisk) {
|
if (ms & MonitoringDisk) {
|
||||||
|
/* disk data needed */
|
||||||
/* disk data needed
|
|
||||||
*/
|
|
||||||
|
|
||||||
Location* loc = _loop_location;
|
Location* loc = _loop_location;
|
||||||
|
|
||||||
|
|
@ -1437,7 +1399,6 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
|
||||||
DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("LOOP read, loop is %1..%2 range is %3..%4 nf %5\n", loc->start (), loc->end (), start_sample, end_sample, nframes));
|
DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("LOOP read, loop is %1..%2 range is %3..%4 nf %5\n", loc->start (), loc->end (), start_sample, end_sample, nframes));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
samplepos_t effective_end;
|
samplepos_t effective_end;
|
||||||
|
|
||||||
effective_start = loop_range.squish (effective_start);
|
effective_start = loop_range.squish (effective_start);
|
||||||
|
|
@ -1474,8 +1435,8 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
|
||||||
|
|
||||||
if (ms & MonitoringInput) {
|
if (ms & MonitoringInput) {
|
||||||
/* merges data from disk (in "target", which is a scratch
|
/* merges data from disk (in "target", which is a scratch
|
||||||
buffer in this case) into the actual destination buffer
|
* buffer in this case) into the actual destination buffer
|
||||||
(which holds existing input data).
|
* (which holds existing input data).
|
||||||
*/
|
*/
|
||||||
dst.merge_from (*target, nframes);
|
dst.merge_from (*target, nframes);
|
||||||
}
|
}
|
||||||
|
|
@ -1506,9 +1467,9 @@ void
|
||||||
DiskReader::dec_no_disk_output ()
|
DiskReader::dec_no_disk_output ()
|
||||||
{
|
{
|
||||||
/* this is called unconditionally when things happen that ought to end
|
/* this is called unconditionally when things happen that ought to end
|
||||||
a period of "no disk output". It's OK for that to happen when there
|
* a period of "no disk output". It's OK for that to happen when there
|
||||||
was no corresponding call to ::inc_no_disk_output(), but we must
|
* was no corresponding call to ::inc_no_disk_output(), but we must
|
||||||
stop the value from becoming negative.
|
* stop the value from becoming negative.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
@ -1647,7 +1608,6 @@ DiskReader::Declicker::reset (samplepos_t loop_start, samplepos_t loop_end, bool
|
||||||
fade_start = loop_end - fade_length;
|
fade_start = loop_end - fade_length;
|
||||||
fade_end = loop_end;
|
fade_end = loop_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1661,12 +1621,13 @@ DiskReader::Declicker::run (Sample* buf, samplepos_t read_start, samplepos_t rea
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine how the read range overlaps with the fade range, so we can determine which part of the fade gain vector
|
/* Determine how the read range overlaps with the fade range, so we can determine
|
||||||
to apply to which part of the buffer.
|
* which part of the fade gain vector to apply to which part of the buffer.
|
||||||
|
*
|
||||||
|
* see also DiskReader::maybe_xfade_loop()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (Evoral::coverage (fade_start, fade_end, read_start, read_end)) {
|
switch (Evoral::coverage (fade_start, fade_end, read_start, read_end)) {
|
||||||
|
|
||||||
case Evoral::OverlapInternal:
|
case Evoral::OverlapInternal:
|
||||||
/* note: start and end points cannot coincide (see evoral/Range.h)
|
/* note: start and end points cannot coincide (see evoral/Range.h)
|
||||||
*
|
*
|
||||||
|
|
@ -1739,12 +1700,13 @@ DiskReader::maybe_xfade_loop (Sample* buf, samplepos_t read_start, samplepos_t r
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine how the read range overlaps with the fade range, so we can determine which part of the fade gain vector
|
/* Determine how the read range overlaps with the fade range, so we can determine
|
||||||
to apply to which part of the buffer.
|
* which part of the fade gain vector to apply to which part of the buffer.
|
||||||
|
*
|
||||||
|
* see also DiskReader::Declicker::run()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (Evoral::coverage (fade_start, fade_end, read_start, read_end)) {
|
switch (Evoral::coverage (fade_start, fade_end, read_start, read_end)) {
|
||||||
|
|
||||||
case Evoral::OverlapInternal:
|
case Evoral::OverlapInternal:
|
||||||
/* note: start and end points cannot coincide (see evoral/Range.h)
|
/* note: start and end points cannot coincide (see evoral/Range.h)
|
||||||
*
|
*
|
||||||
|
|
@ -1878,7 +1840,6 @@ DiskReader::reload_loop ()
|
||||||
uint32_t channel = 0;
|
uint32_t channel = 0;
|
||||||
|
|
||||||
for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan, ++channel) {
|
for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan, ++channel) {
|
||||||
|
|
||||||
ReaderChannelInfo* rci = dynamic_cast<ReaderChannelInfo*> (*chan);
|
ReaderChannelInfo* rci = dynamic_cast<ReaderChannelInfo*> (*chan);
|
||||||
|
|
||||||
rci->resize_preloop (loop_fade_length);
|
rci->resize_preloop (loop_fade_length);
|
||||||
|
|
@ -1888,6 +1849,5 @@ DiskReader::reload_loop ()
|
||||||
} else {
|
} else {
|
||||||
memset (rci->pre_loop_buffer, 0, sizeof (Sample) * loop_fade_length);
|
memset (rci->pre_loop_buffer, 0, sizeof (Sample) * loop_fade_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue