Ardour  9.0-pre0-582-g084a23a80d
panner_2in2out.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2012 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_panner_2in2out_h__
21 #define __ardour_panner_2in2out_h__
22 
23 #include <cassert>
24 #include <cmath>
25 #include <iostream>
26 #include <string>
27 #include <vector>
28 
29 #include "pbd/cartesian.h"
30 #include "pbd/controllable.h"
31 #include "pbd/stateful.h"
32 
33 #include "ardour/automatable.h"
35 #include "ardour/panner.h"
36 #include "ardour/types.h"
37 
38 namespace ARDOUR
39 {
40 class Panner2in2out : public Panner
41 {
42 public:
43  Panner2in2out (std::shared_ptr<Pannable>);
45 
46  ChanCount in () const
47  {
48  return ChanCount (DataType::AUDIO, 2);
49  }
50  ChanCount out () const
51  {
52  return ChanCount (DataType::AUDIO, 2);
53  }
54 
55  bool clamp_position (double&);
56  bool clamp_width (double&);
57 
58  std::pair<double, double> position_range () const;
59  std::pair<double, double> width_range () const;
60 
61  void set_position (double);
62  void set_width (double);
63 
64  double position () const;
65  double width () const;
66 
67  static Panner* factory (std::shared_ptr<Pannable>, std::shared_ptr<Speakers>);
68 
69  std::string value_as_string (std::shared_ptr<const AutomationControl>) const;
70 
71  XMLNode& get_state () const;
72 
73  void update ();
74 
75  void reset ();
76  void thaw ();
77 
78 protected:
79  float left[2];
80  float right[2];
81  float desired_left[2];
82  float desired_right[2];
83  float left_interp[2];
84  float right_interp[2];
85 
86 private:
87  bool clamp_stereo_pan (double& direction_as_lr_fract, double& width);
88 
89  void distribute_one (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which);
91  samplepos_t start, samplepos_t end, pframes_t nframes,
92  pan_t** buffers, uint32_t which);
93 };
94 
95 } // namespace ARDOUR
96 
97 #endif /* __ardour_panner_2in2out_h__ */
void distribute_one_automated(AudioBuffer &srcbuf, BufferSet &obufs, samplepos_t start, samplepos_t end, pframes_t nframes, pan_t **buffers, uint32_t which)
std::string value_as_string(std::shared_ptr< const AutomationControl >) const
std::pair< double, double > position_range() const
void set_width(double)
bool clamp_stereo_pan(double &direction_as_lr_fract, double &width)
void distribute_one(AudioBuffer &srcbuf, BufferSet &obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which)
XMLNode & get_state() const
bool clamp_width(double &)
std::pair< double, double > width_range() const
double width() const
void set_position(double)
bool clamp_position(double &)
static Panner * factory(std::shared_ptr< Pannable >, std::shared_ptr< Speakers >)
double position() const
ChanCount out() const
Panner2in2out(std::shared_ptr< Pannable >)
ChanCount in() const
Definition: xml++.h:114
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
Temporal::samplepos_t samplepos_t