summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-03-14 03:43:54 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-03-14 03:43:54 +0000
commitaf707897735a34ab1a82c7307dc61b12c14027a9 (patch)
treeb2a9fc621c4a5d7865a46f09eb5cafeee959a9a1 /libs
parent1a52aeb370c9fabbd2229da793aee0399f04ca2f (diff)
improvements (!) to waveform display for destructive tracks, plus a generic fix that avoid waveview attemting to read peaks before they are ready
git-svn-id: svn://localhost/trunk/ardour2@388 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audioregion.h2
-rw-r--r--libs/ardour/ardour/source.h2
-rw-r--r--libs/ardour/audioregion.cc4
-rw-r--r--libs/ardour/destructive_filesource.cc10
-rw-r--r--libs/ardour/diskstream.cc13
-rw-r--r--libs/ardour/source.cc23
6 files changed, 36 insertions, 18 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index fa6b3aeecc..c716bf9707 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -223,7 +223,7 @@ class AudioRegion : public Region
extern "C" {
int region_read_peaks_from_c (void *arg, uint32_t npeaks, uint32_t start, uint32_t length, intptr_t data, uint32_t n_chan, double samples_per_unit);
uint32_t region_length_from_c (void *arg);
- uint32_t sourcefile_length_from_c (void *arg);
+ uint32_t sourcefile_length_from_c (void *arg, double);
}
#endif /* __ardour_audio_region_h__ */
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index 9a9bccfc58..7a5e2eb23a 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -64,6 +64,8 @@ class Source : public Stateful, public sigc::trackable
return _length;
}
+ virtual jack_nframes_t available_peaks (double zoom) const;
+
virtual jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const {
return 0;
}
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 59ddd12c47..23db0a0604 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -1397,9 +1397,9 @@ uint32_t region_length_from_c (void *arg)
return ((AudioRegion *) arg)->length();
}
-uint32_t sourcefile_length_from_c (void *arg)
+uint32_t sourcefile_length_from_c (void *arg, double zoom_factor)
{
- return ( (AudioRegion *) arg)->source().length() ;
+ return ( (AudioRegion *) arg)->source().available_peaks (zoom_factor) ;
}
} /* extern "C" */
diff --git a/libs/ardour/destructive_filesource.cc b/libs/ardour/destructive_filesource.cc
index c18fedd982..1ca6b5be5a 100644
--- a/libs/ardour/destructive_filesource.cc
+++ b/libs/ardour/destructive_filesource.cc
@@ -69,6 +69,7 @@ jack_nframes_t DestructiveFileSource::xfade_frames = 64;
DestructiveFileSource::DestructiveFileSource (string path, jack_nframes_t rate, bool repair_first, SampleFormat samp_format)
: FileSource (path, rate, repair_first, samp_format)
{
+ cerr << "DESTRUCTO DISK STREAM, " << _name << endl;
if (out_coefficient == 0) {
setup_standard_crossfades (rate);
}
@@ -83,6 +84,7 @@ DestructiveFileSource::DestructiveFileSource (string path, jack_nframes_t rate,
DestructiveFileSource::DestructiveFileSource (const XMLNode& node, jack_nframes_t rate)
: FileSource (node, rate)
{
+ cerr << "from XML, DESTRUCTO DISK STREAM, " << _name << endl;
if (out_coefficient == 0) {
setup_standard_crossfades (rate);
}
@@ -259,8 +261,6 @@ DestructiveFileSource::crossfade (Sample* data, jack_nframes_t cnt, int fade_in,
jack_nframes_t
DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
{
- cerr << _name << ": write " << cnt << " to " << file_pos << " start ? " << _capture_start << " end ? " << _capture_end << endl;
-
{
LockMonitor lm (_lock, __LINE__, __FILE__);
@@ -273,8 +273,6 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
/* move to the correct location place */
file_pos = capture_start_frame;
- cerr << "First frame of capture will be at " << file_pos << " and last at: " << file_pos + cnt << endl;
-
// split cnt in half
jack_nframes_t subcnt = cnt / 2;
jack_nframes_t ofilepos = file_pos;
@@ -302,8 +300,6 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
/* move to the correct location place */
file_pos = capture_start_frame;
- cerr << "First frame of capture will be at " << file_pos << endl;
-
if (crossfade (data, cnt, 1, workbuf) != cnt) {
return 0;
}
@@ -327,8 +323,6 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
}
file_pos += cnt;
- //cerr << this << ' ' << _name << " at end of write, file_pos = " << file_pos << " length = " << ((int) &_length - (int) this) << ' ' << &_length << ' ' << _length << endl;
-
if (_build_peakfiles) {
PeakBuildRecord *pbr = 0;
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc
index 80a562ab21..78f6d13335 100644
--- a/libs/ardour/diskstream.cc
+++ b/libs/ardour/diskstream.cc
@@ -603,7 +603,7 @@ DiskStream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t
}
/* change state */
-
+
/* if per-track or global rec-enable turned on while the other was already on, we've started recording */
if ((change & track_rec_enabled) && record_enabled() && (!(change & global_rec_enabled) && can_record) ||
@@ -692,7 +692,7 @@ DiskStream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t
} else if (!record_enabled() || !can_record) {
/* stop recording */
-
+
last_recordable_frame = transport_frame + _capture_offset;
if (_alignment_style == ExistingMaterial) {
@@ -1608,8 +1608,6 @@ DiskStream::do_flush (char * workbuf, bool force_flush)
}
}
-
-
if ((!(*chan).write_source) || (*chan).write_source->write (vector.buf[0], to_write, workbuf) != to_write) {
error << string_compose(_("DiskStream %1: cannot write to disk"), _id) << endmsg;
return -1;
@@ -1963,6 +1961,9 @@ DiskStream::get_state ()
char buf[64];
LocaleGuard lg (X_("POSIX"));
+ snprintf (buf, sizeof(buf), "0x%x", _flags);
+ node->add_property ("flags", buf);
+
snprintf (buf, sizeof(buf), "%zd", channels.size());
node->add_property ("channels", buf);
@@ -2047,6 +2048,10 @@ DiskStream::set_state (const XMLNode& node)
}
}
+ if ((prop = node.property ("_flags")) != 0) {
+ _flags = atoi (prop->value().c_str());
+ }
+
if ((prop = node.property ("channels")) != 0) {
nchans = atoi (prop->value().c_str());
}
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index 2a6337d441..fb09293fd5 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -545,19 +545,21 @@ Source::read_peaks (PeakData *peaks, jack_nframes_t npeaks, jack_nframes_t start
tnp = min ((_length/frames_per_peak - current_stored_peak), (jack_nframes_t) expected_peaks);
to_read = min (chunksize, tnp);
+ off_t fend = lseek (peakfile, 0, SEEK_END);
+
if ((nread = ::pread (peakfile, staging, sizeof (PeakData) * to_read, start_byte))
!= sizeof (PeakData) * to_read) {
cerr << "Source["
<< _name
<< "]: cannot read peak data from peakfile ("
- << nread
+ << (nread / sizeof(PeakData))
<< " peaks instead of "
<< to_read
<< ") ("
<< strerror (errno)
<< ')'
<< " at start_byte = " << start_byte
- << " _length = " << _length
+ << " _length = " << _length << " versus len = " << fend
<< " expected maxpeaks = " << (_length - current_frame)/frames_per_peak
<< " npeaks was " << npeaks
<< endl;
@@ -699,7 +701,7 @@ Source::build_peaks ()
}
#ifdef DEBUG_PEAK_BUILD
- cerr << "build peaks with " << pending_peak_builds.size() << " requests pending\n";
+ cerr << "build peaks with " << copy.size() << " requests pending\n";
#endif
for (list<PeakBuildRecord *>::iterator i = copy.begin(); i != copy.end(); ++i) {
@@ -732,6 +734,7 @@ Source::build_peaks ()
}
if (pr_signal) {
+ off_t fend = lseek (peakfile, 0, SEEK_END);
PeaksReady (); /* EMIT SIGNAL */
}
}
@@ -849,3 +852,17 @@ Source::release ()
{
if (_use_cnt) --_use_cnt;
}
+
+jack_nframes_t
+Source::available_peaks (double zoom_factor) const
+{
+ if (zoom_factor < frames_per_peak) {
+ return length(); // peak data will come from the audio file
+ }
+
+ /* peak data comes from peakfile */
+
+ LockMonitor lm (_lock, __LINE__, __FILE__);
+ off_t end = lseek (peakfile, 0, SEEK_END);
+ return (end/sizeof(PeakData)) * frames_per_peak;
+}