hook up tape region views to peaks ready signal
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 21 Feb 2006 05:05:59 +0000 (05:05 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 21 Feb 2006 05:05:59 +0000 (05:05 +0000)
git-svn-id: svn://localhost/trunk/ardour2@342 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/regionview.cc
gtk2_ardour/taperegionview.cc
gtk2_ardour/taperegionview.h
libs/ardour/destructive_filesource.cc
libs/ardour/filesource.cc
libs/ardour/source.cc

index 119c4cbe58adcd3c2c2dfbee111af187a3903550..d7c87ae1c4cb2c9ad53b048e6f4165c309e077a4 100644 (file)
@@ -1067,7 +1067,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
        */
 
        if (which < nchans) {
-               tmp_waves[which] = (wave);
+               tmp_waves[which] = wave;
        } else {
                /* n-channel track, >n-channel source */
        }
@@ -1080,11 +1080,31 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
                }
        }
        
-       if (n == nwaves) {
+       cerr << "wave ready, n = " << n << " nwaves = " << nwaves << " new wave = " << wave 
+            << " tmp[" << which << "] = " << tmp_waves[which] << endl;
+       
+       if (n == nwaves && waves.empty()) {
                /* all waves are ready */
                tmp_waves.resize(nwaves);
+
+
+               for (uint32_t x = 0; x < tmp_waves.size(); ++x) {
+                       cerr << "tmp_waves[" << x << "] = " << tmp_waves[x] << endl;
+               }
+
                waves = tmp_waves;
                tmp_waves.clear ();
+
+               cerr << "all waves ready, copied over ...\n";
+
+               for (uint32_t x = 0; x < waves.size(); ++x) {
+                       cerr << "waves[" << x << "] = " << waves[x] << endl;
+               }
+               
+               for (vector<WaveView*>::iterator i = waves.begin(); i != waves.end(); ++i) {
+                       cerr << "iterator[" << distance (i, waves.begin()) << "] = " << (*i) << endl;
+               }
+               cerr << "--------\n";
                
                if (!zero_line) {
                        zero_line = new ArdourCanvas::SimpleLine (*group);
@@ -1094,6 +1114,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool direct)
                        manage_zero_line ();
                }
        }
+       cerr << "done that time\n";
 }
 
 void
index 78786be0953bbd74d7fc360ab822f129377c1e46..4fd40bcc86627d5c042c27f78c3cda7c12e7108e 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "taperegionview.h"
 #include "audio_time_axis.h"
+#include "gui_thread.h"
 
 #include "i18n.h"
 
@@ -100,12 +101,47 @@ TapeAudioRegionView::init (double amplitude_above_axis, Gdk::Color& basic_color,
        set_colors ();
 
        // ColorChanged.connect (mem_fun (*this, &AudioRegionView::color_handler));
+
+       /* every time the wave data changes and peaks are ready, redraw */
+
+       for (uint32_t n = 0; n < region.n_channels(); ++n) {
+               region.source(n).PeaksReady.connect (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
+       }
+       
 }
 
 TapeAudioRegionView::~TapeAudioRegionView()
 {
 }
 
+void
+TapeAudioRegionView::update (uint32_t n)
+{
+       /* check that all waves are build and ready */
+
+       if (!tmp_waves.empty()) {
+               return;
+       }
+
+       ENSURE_GUI_THREAD (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
+
+       cerr << "peaks ready for channel " << n << endl;
+
+       cerr << "tmp waves size = " << tmp_waves.size() << " waves size = " << waves.size() << endl;
+
+       for (uint32_t x = 0; x < waves.size(); ++x) {
+               cerr << "waves[" << x << "] = " << waves[x] << endl;
+       }
+
+       for (vector<WaveView*>::iterator i = waves.begin(); i != waves.end(); ++i) {
+               cerr << "iterator[" << distance (i, waves.begin()) << "] = " << (*i) << endl;
+       }
+
+       /* this triggers a cache invalidation and redraw in the waveview */
+
+       waves[n]->property_data_src() = &region;
+}
+
 void
 TapeAudioRegionView::set_frame_color ()
 {
index 9d4b9cec2fd9991e259acfa810616a6ef58720bf..3e23e0fc19d9a71734786ca060c23f14e8252c42 100644 (file)
@@ -39,6 +39,7 @@ class TapeAudioRegionView : public AudioRegionView
        void init (double amplitude_above_axis, Gdk::Color& base_color, bool wait_for_waves);
 
        void set_frame_color ();
+       void update (uint32_t n);
 };
 
 #endif /* __gtk_ardour_tape_audio_region_view_h__ */
index 9081fc9b381105feb0f2b0ef674063e96a4164a8..8604d5d84e7a824088cc268cf655ee5ffc9a291a 100644 (file)
@@ -264,7 +264,7 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
        {
                LockMonitor lm (_lock, __LINE__, __FILE__);
                
-               jack_nframes_t oldlen;
+               jack_nframes_t old_file_pos;
 
                if (_capture_start && _capture_end) {
                        _capture_start = false;
@@ -321,7 +321,7 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
                        }
                }
 
-               oldlen = _length;
+               old_file_pos = file_pos;
                if (file_pos + cnt > _length) {
                        _length = file_pos + cnt;
                }
@@ -336,7 +336,7 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
                                pbr = pending_peak_builds.back();
                        }
                        
-                       if (pbr && pbr->frame + pbr->cnt == oldlen) {
+                       if (pbr && pbr->frame + pbr->cnt == old_file_pos) {
                                
                                /* the last PBR extended to the start of the current write,
                                   so just extend it again.
@@ -344,15 +344,13 @@ DestructiveFileSource::write (Sample* data, jack_nframes_t cnt, char * workbuf)
 
                                pbr->cnt += cnt;
                        } else {
-                               pending_peak_builds.push_back (new PeakBuildRecord (oldlen, cnt));
+                               pending_peak_builds.push_back (new PeakBuildRecord (old_file_pos, cnt));
                        }
                        
                        _peaks_built = false;
                }
-
        }
 
-
        if (_build_peakfiles) {
                queue_for_peaks (*this);
        }
index 3451239d3b80595e0f30327324a7765a8725c7c6..7661f8f3f56ed5fa769ed275beb59aee9062c30d 100644 (file)
@@ -1020,7 +1020,7 @@ FileSource::write (Sample *data, jack_nframes_t cnt, char * workbuf)
 
                if (_build_peakfiles) {
                        PeakBuildRecord *pbr = 0;
-                       
+
                        if (pending_peak_builds.size()) {
                                pbr = pending_peak_builds.back();
                        }
index ee918375f65ac2e7578c5cec8507a4d422dcc1dd..f707dc44e51dd58a8e2ce0f70ea1aa283e0a48d2 100644 (file)
@@ -700,7 +700,6 @@ Source::build_peaks ()
                pending_peak_builds.clear ();
        }
                
-
 #ifdef DEBUG_PEAK_BUILD
        cerr << "build peaks with " << pending_peak_builds.size() << " requests pending\n";
 #endif