ardour
tape_region_view.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include <cmath>
21 #include <algorithm>
22 
23 #include <gtkmm.h>
24 
25 #include <gtkmm2ext/gtk_ui.h>
26 
27 #include "ardour/audioregion.h"
28 #include "ardour/audiosource.h"
29 
30 #include "tape_region_view.h"
31 #include "audio_time_axis.h"
32 #include "gui_thread.h"
33 
34 #include "i18n.h"
35 
36 using namespace ARDOUR;
37 using namespace PBD;
38 using namespace Editing;
39 using namespace ArdourCanvas;
40 
48 
49 TapeAudioRegionView::TapeAudioRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv,
51  double spu,
52  uint32_t basic_color)
53 
54  : AudioRegionView (parent, tv, r, spu, basic_color, false,
55  TimeAxisViewItem::Visibility ((r->position() != 0) ? default_tape_visibility :
56  TimeAxisViewItem::Visibility (default_tape_visibility|TimeAxisViewItem::HideFrameLeft)))
57 {
58 }
59 
60 void
62 {
63  /* never wait for data: always just create the waves, connect once and then
64  we'll update whenever we need to.
65  */
66 
67  AudioRegionView::init (false);
68 
69  /* every time the wave data changes and peaks are ready, redraw */
70 
71  for (uint32_t n = 0; n < audio_region()->n_channels(); ++n) {
72  audio_region()->audio_source(n)->PeaksReady.connect (*this, invalidator (*this), boost::bind (&TapeAudioRegionView::update, this, n), gui_context());
73  }
74 
75 }
76 
78 {
79 }
80 
81 void
83 {
84  /* check that all waves are build and ready */
85  if (!tmp_waves.empty()) {
86  return;
87  }
88 
90  // CAIROCANVAS
91 
92  /* this is a quick hack to draw something (abuse gain_changed to force
93  * an image-cache invalidation.
94  *
95  * TODO: ArdourCanvas::WaveView needs an API to look up the specific channel "n"
96  * and a special case to not only invalidate the cache but re-expose the
97  * waveform. e.g.
98  *
99  * waves[m]->rebuild(); // where 'm' corresponds to channel 'n'.
100  */
101  for (uint32_t i = 0; i < waves.size(); ++i) {
102  waves[i]->gain_changed ();
103  }
104 }
void init(bool wait_for_waves)
void init(bool wait_for_data)
boost::shared_ptr< ARDOUR::AudioRegion > audio_region() const
#define ENSURE_GUI_THREAD(obj, method,...)
Definition: gui_thread.h:34
#define invalidator(x)
Definition: gui_thread.h:40
void update(uint32_t n)
std::vector< ArdourCanvas::WaveView * > tmp_waves
see ::create_waves()
Definition: amp.h:29
boost::shared_ptr< AudioSource > audio_source(uint32_t n=0) const
#define gui_context()
Definition: gui_thread.h:36
std::vector< ArdourCanvas::WaveView * > waves
uint32_t n_channels() const
Definition: region.h:259
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
Definition: region.cc:65
Definition: debug.h:30
TapeAudioRegionView(ArdourCanvas::Container *, RouteTimeAxisView &, boost::shared_ptr< ARDOUR::AudioRegion >, double initial_samples_per_pixel, uint32_t base_color)
static const TimeAxisViewItem::Visibility default_tape_visibility