Ardour  8.12
panner.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
6  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_panner_h__
24 #define __ardour_panner_h__
25 
26 #include <cmath>
27 #include <cassert>
28 #include <vector>
29 #include <string>
30 #include <iostream>
31 
32 #include "pbd/cartesian.h"
33 #include "pbd/signals.h"
34 #include "pbd/stateful.h"
35 
37 #include "ardour/types.h"
39 #include "ardour/automatable.h"
40 
41 
42 /* This section is for actual panners to use. They will include this file,
43  * declare ARDOURPANNER_DLL_EXPORTS during compilation, and ... voila.
44  */
45 
46 #ifdef ARDOURPANNER_DLL_EXPORTS // defined if we are building a panner implementation
47  #define ARDOURPANNER_API LIBARDOUR_DLL_EXPORT
48  #else
49  #define ARDOURPANNER_API LIBARDOUR_DLL_IMPORT
50  #endif
51 #define ARDOURPANNER_LOCAL LIBARDOUR_DLL_LOCAL
52 
53 namespace ARDOUR {
54 
55 class Session;
56 class Pannable;
57 class BufferSet;
58 class AudioBuffer;
59 class Speakers;
60 
62 {
63 public:
64  Panner (std::shared_ptr<Pannable>);
65  ~Panner ();
66 
67  virtual std::shared_ptr<Speakers> get_speakers() const { return std::shared_ptr<Speakers>(); }
68 
69  virtual ChanCount in() const = 0;
70  virtual ChanCount out() const = 0;
71 
72  virtual void configure_io (ARDOUR::ChanCount /*in*/, ARDOUR::ChanCount /*out*/) {}
73 
74  /* derived implementations of these methods must indicate
75  whether it is legal for a Controllable to use the
76  value of the argument (post-call) in a call to
77  Controllable::set_value().
78 
79  they have a choice of:
80 
81  * return true, leave argument unchanged
82  * return true, modify argument
83  * return false
84  */
85 
86  virtual bool clamp_position (double&) { return true; }
87  virtual bool clamp_width (double&) { return true; }
88  virtual bool clamp_elevation (double&) { return true; }
89 
90  virtual std::pair<double, double> position_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
91  virtual std::pair<double, double> width_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
92  virtual std::pair<double, double> elevation_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
93 
94  virtual void set_position (double) { }
95  virtual void set_width (double) { }
96  virtual void set_elevation (double) { }
97 
98  virtual double position () const { return 0.0; }
99  virtual double width () const { return 0.0; }
100  virtual double elevation () const { return 0.0; }
101 
102  virtual PBD::AngularVector signal_position (uint32_t) const { return PBD::AngularVector(); }
103 
104  virtual void reset () = 0;
105 
106  /* azimut, width or elevation updated -> recalc signal_position -> emit Changed */
107  PBD::Signal0<void> SignalPositionChanged;
108 
125  virtual void distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes);
126  virtual void distribute_automated (BufferSet& ibufs, BufferSet& obufs,
127  samplepos_t start, samplepos_t end, pframes_t nframes,
128  pan_t** buffers);
129 
130  int set_state (const XMLNode&, int version);
131  XMLNode& get_state () const;
132 
133  std::shared_ptr<Pannable> pannable() const { return _pannable; }
134 
135  virtual void freeze ();
136  virtual void thaw ();
137 
138  const std::set<Evoral::Parameter>& what_can_be_automated() const {
139  return _can_automate_list;
140  }
141 
142  virtual std::string value_as_string (std::shared_ptr<const AutomationControl>) const = 0;
143 
144 protected:
145  virtual void distribute_one (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which) = 0;
147  samplepos_t start, samplepos_t end, pframes_t nframes,
148  pan_t** buffers, uint32_t which) = 0;
149 
150  std::shared_ptr<Pannable> _pannable;
151  std::set<Evoral::Parameter> _can_automate_list;
152 
153  int32_t _frozen;
154 };
155 
156 } // namespace
157 
158 extern "C" {
160  std::string name;
161  std::string panner_uri;
162  std::string gui_uri;
163  int32_t in;
164  int32_t out;
165  uint32_t priority;
166  ARDOUR::Panner* (*factory)(std::shared_ptr<ARDOUR::Pannable>, std::shared_ptr<ARDOUR::Speakers>);
167 };
168 }
169 
170 #endif /* __ardour_panner_h__ */
virtual bool clamp_position(double &)
Definition: panner.h:86
virtual bool clamp_width(double &)
Definition: panner.h:87
virtual std::pair< double, double > width_range() const
Definition: panner.h:91
virtual void set_position(double)
Definition: panner.h:94
virtual bool clamp_elevation(double &)
Definition: panner.h:88
virtual void distribute_automated(BufferSet &ibufs, BufferSet &obufs, samplepos_t start, samplepos_t end, pframes_t nframes, pan_t **buffers)
std::set< Evoral::Parameter > _can_automate_list
Definition: panner.h:151
virtual double width() const
Definition: panner.h:99
virtual double position() const
Definition: panner.h:98
virtual void reset()=0
virtual ChanCount in() const =0
virtual void distribute(BufferSet &ibufs, BufferSet &obufs, gain_t gain_coeff, pframes_t nframes)
virtual void configure_io(ARDOUR::ChanCount, ARDOUR::ChanCount)
Definition: panner.h:72
virtual void freeze()
std::shared_ptr< Pannable > pannable() const
Definition: panner.h:133
virtual void distribute_one(AudioBuffer &, BufferSet &obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which)=0
Panner(std::shared_ptr< Pannable >)
int32_t _frozen
Definition: panner.h:153
const std::set< Evoral::Parameter > & what_can_be_automated() const
Definition: panner.h:138
virtual void thaw()
int set_state(const XMLNode &, int version)
virtual double elevation() const
Definition: panner.h:100
virtual void distribute_one_automated(AudioBuffer &, BufferSet &obufs, samplepos_t start, samplepos_t end, pframes_t nframes, pan_t **buffers, uint32_t which)=0
virtual std::pair< double, double > position_range() const
Definition: panner.h:90
virtual ChanCount out() const =0
XMLNode & get_state() const
virtual std::pair< double, double > elevation_range() const
Definition: panner.h:92
virtual PBD::AngularVector signal_position(uint32_t) const
Definition: panner.h:102
PBD::Signal0< void > SignalPositionChanged
Definition: panner.h:107
std::shared_ptr< Pannable > _pannable
Definition: panner.h:150
virtual std::shared_ptr< Speakers > get_speakers() const
Definition: panner.h:67
virtual std::string value_as_string(std::shared_ptr< const AutomationControl >) const =0
virtual void set_width(double)
Definition: panner.h:95
virtual void set_elevation(double)
Definition: panner.h:96
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
Temporal::samplepos_t samplepos_t
uint32_t priority
Definition: panner.h:165
std::string gui_uri
Definition: panner.h:162
std::string name
Definition: panner.h:160
std::string panner_uri
Definition: panner.h:161