Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
24 
25 #include <cmath>
26 #include <cassert>
27 #include <vector>
28 #include <string>
29 #include <iostream>
30 
31 #include "pbd/cartesian.h"
32 #include "pbd/signals.h"
33 #include "pbd/stateful.h"
34 
36 #include "ardour/types.h"
38 #include "ardour/automatable.h"
39 
40 
41 /* This section is for actual panners to use. They will include this file,
42  * declare ARDOURPANNER_DLL_EXPORTS during compilation, and ... voila.
43  */
44 
45 #ifdef ARDOURPANNER_DLL_EXPORTS // defined if we are building a panner implementation
46  #define ARDOURPANNER_API LIBARDOUR_DLL_EXPORT
47  #else
48  #define ARDOURPANNER_API LIBARDOUR_DLL_IMPORT
49  #endif
50 #define ARDOURPANNER_LOCAL LIBARDOUR_DLL_LOCAL
51 
52 namespace ARDOUR {
53 
54 class Session;
55 class Pannable;
56 class BufferSet;
57 class AudioBuffer;
58 class Speakers;
59 
61 {
62 public:
63  Panner (std::shared_ptr<Pannable>);
64  ~Panner ();
65 
66  virtual std::shared_ptr<Speakers> get_speakers() const { return std::shared_ptr<Speakers>(); }
67 
68  virtual ChanCount in() const = 0;
69  virtual ChanCount out() const = 0;
70 
71  virtual void configure_io (ARDOUR::ChanCount /*in*/, ARDOUR::ChanCount /*out*/) {}
72 
73  /* derived implementations of these methods must indicate
74  whether it is legal for a Controllable to use the
75  value of the argument (post-call) in a call to
76  Controllable::set_value().
77 
78  they have a choice of:
79 
80  * return true, leave argument unchanged
81  * return true, modify argument
82  * return false
83  */
84 
85  virtual bool clamp_position (double&) { return true; }
86  virtual bool clamp_width (double&) { return true; }
87  virtual bool clamp_elevation (double&) { return true; }
88 
89  virtual std::pair<double, double> position_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
90  virtual std::pair<double, double> width_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
91  virtual std::pair<double, double> elevation_range () const { return std::make_pair (-DBL_MAX, DBL_MAX); }
92 
93  virtual void set_position (double) { }
94  virtual void set_width (double) { }
95  virtual void set_elevation (double) { }
96 
97  virtual double position () const { return 0.0; }
98  virtual double width () const { return 0.0; }
99  virtual double elevation () const { return 0.0; }
100 
101  virtual PBD::AngularVector signal_position (uint32_t) const { return PBD::AngularVector(); }
102 
103  virtual void reset () = 0;
104 
105  /* azimut, width or elevation updated -> recalc signal_position -> emit Changed */
107 
124  virtual void distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes);
125  virtual void distribute_automated (BufferSet& ibufs, BufferSet& obufs,
126  samplepos_t start, samplepos_t end, pframes_t nframes,
127  pan_t** buffers);
128 
129  int set_state (const XMLNode&, int version);
130  XMLNode& get_state () const;
131 
132  std::shared_ptr<Pannable> pannable() const { return _pannable; }
133 
134  virtual void freeze ();
135  virtual void thaw ();
136 
137  const std::set<Evoral::Parameter>& what_can_be_automated() const {
138  return _can_automate_list;
139  }
140 
141  virtual std::string value_as_string (std::shared_ptr<const AutomationControl>) const = 0;
142 
143 protected:
144  virtual void distribute_one (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which) = 0;
146  samplepos_t start, samplepos_t end, pframes_t nframes,
147  pan_t** buffers, uint32_t which) = 0;
148 
149  std::shared_ptr<Pannable> _pannable;
150  std::set<Evoral::Parameter> _can_automate_list;
151 
152  int32_t _frozen;
153 };
154 
155 } // namespace
156 
157 extern "C" {
159  std::string name;
160  std::string panner_uri;
161  std::string gui_uri;
162  int32_t in;
163  int32_t out;
164  uint32_t priority;
165  ARDOUR::Panner* (*factory)(std::shared_ptr<ARDOUR::Pannable>, std::shared_ptr<ARDOUR::Speakers>);
166 };
167 }
168 
virtual bool clamp_position(double &)
Definition: panner.h:85
virtual bool clamp_width(double &)
Definition: panner.h:86
virtual std::pair< double, double > width_range() const
Definition: panner.h:90
virtual void set_position(double)
Definition: panner.h:93
virtual bool clamp_elevation(double &)
Definition: panner.h:87
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:150
virtual double width() const
Definition: panner.h:98
virtual double position() const
Definition: panner.h:97
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:71
virtual void freeze()
std::shared_ptr< Pannable > pannable() const
Definition: panner.h:132
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:152
const std::set< Evoral::Parameter > & what_can_be_automated() const
Definition: panner.h:137
virtual void thaw()
int set_state(const XMLNode &, int version)
virtual double elevation() const
Definition: panner.h:99
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:89
virtual ChanCount out() const =0
XMLNode & get_state() const
virtual std::pair< double, double > elevation_range() const
Definition: panner.h:91
virtual PBD::AngularVector signal_position(uint32_t) const
Definition: panner.h:101
std::shared_ptr< Pannable > _pannable
Definition: panner.h:149
virtual std::shared_ptr< Speakers > get_speakers() const
Definition: panner.h:66
PBD::Signal< void()> SignalPositionChanged
Definition: panner.h:106
virtual std::string value_as_string(std::shared_ptr< const AutomationControl >) const =0
virtual void set_width(double)
Definition: panner.h:94
virtual void set_elevation(double)
Definition: panner.h:95
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:164
std::string gui_uri
Definition: panner.h:161
std::string name
Definition: panner.h:159
std::string panner_uri
Definition: panner.h:160