Ardour  9.0-pre0-582-g084a23a80d
solo_control.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #pragma once
20 
21 #include <memory>
22 #include <string>
23 
26 
27 namespace ARDOUR {
28 
29 class Session;
30 class Soloable;
31 class Muteable;
32 
34 {
35  public:
36  SoloControl (Session& session, std::string const & name, Soloable& soloable, Muteable& m, Temporal::TimeDomainProvider const &);
37 
38  double get_value () const;
39  double get_save_value() const { return self_soloed(); }
40 
41  bool can_solo() const;
42 
43  /* Export additional API so that objects that only get access
44  * to a Controllable/AutomationControl can do more fine-grained
45  * operations with respect to solo. Obviously, they would need
46  * to dynamic_cast<SoloControl> first.
47  *
48  * Solo state is not representable by a single scalar value,
49  * so set_value() and get_value() is not enough.
50  *
51  * This means that the Controllable is technically
52  * asymmetric. It is possible to call ::set_value (0.0) to
53  * disable (self)solo, and then call ::get_value() and get a
54  * return of 1.0 because the control is soloed by
55  * upstream/downstream or a master.
56  */
57 
58  void mod_solo_by_others_upstream (int32_t delta);
59  void mod_solo_by_others_downstream (int32_t delta);
60 
61  /* API to check different aspects of solo substate
62  */
63 
64  bool self_soloed () const {
65  return _self_solo;
66  }
67  bool soloed_by_masters () const {
68  return get_masters_value();
69  }
70  bool soloed_by_self_or_masters () const {
71  return self_soloed() || get_masters_value ();
72  }
73  bool soloed_by_others () const {
74  return _soloed_by_others_downstream || _soloed_by_others_upstream || get_masters_value ();
75  }
76  uint32_t soloed_by_others_upstream () const {
77  return _soloed_by_others_upstream;
78  }
79  uint32_t soloed_by_others_downstream () const {
80  return _soloed_by_others_downstream;
81  }
82  bool soloed() const { return self_soloed() || soloed_by_others(); }
83 
84  /* The session object needs to respond to solo
85  changes, but to do so accurately it needs to know if we transition
86  into or out of solo. The normal Changed signal doesn't make that
87  possible.
88  */
89 
90  int32_t transitioned_into_solo () const { return _transition_into_solo; }
91 
93 
94  int set_state (XMLNode const&, int);
95  XMLNode& get_state () const;
96 
97  protected:
99  void master_changed (bool from_self, GroupControlDisposition, std::weak_ptr<AutomationControl> m);
100  void pre_remove_master (std::shared_ptr<AutomationControl>);
101  void post_add_master (std::shared_ptr<AutomationControl>);
102 
103  private:
110 
111  void set_self_solo (bool yn);
113 };
114 
115 } /* namespace */
116 
bool soloed() const
Definition: solo_control.h:82
void post_add_master(std::shared_ptr< AutomationControl >)
double get_value() const
uint32_t soloed_by_others_downstream() const
Definition: solo_control.h:79
Muteable & _muteable
Definition: solo_control.h:105
void mod_solo_by_others_upstream(int32_t delta)
Soloable & _soloable
Definition: solo_control.h:104
int set_state(XMLNode const &, int)
XMLNode & get_state() const
void master_changed(bool from_self, GroupControlDisposition, std::weak_ptr< AutomationControl > m)
bool can_solo() const
uint32_t soloed_by_others_upstream() const
Definition: solo_control.h:76
uint32_t _soloed_by_others_downstream
Definition: solo_control.h:108
double get_save_value() const
Definition: solo_control.h:39
void pre_remove_master(std::shared_ptr< AutomationControl >)
bool soloed_by_self_or_masters() const
Definition: solo_control.h:70
bool soloed_by_masters() const
Definition: solo_control.h:67
void actually_set_value(double, PBD::Controllable::GroupControlDisposition group_override)
SoloControl(Session &session, std::string const &name, Soloable &soloable, Muteable &m, Temporal::TimeDomainProvider const &)
bool soloed_by_others() const
Definition: solo_control.h:73
int32_t _transition_into_solo
Definition: solo_control.h:109
void mod_solo_by_others_downstream(int32_t delta)
void set_self_solo(bool yn)
uint32_t _soloed_by_others_upstream
Definition: solo_control.h:107
int32_t transitioned_into_solo() const
Definition: solo_control.h:90
bool self_soloed() const
Definition: solo_control.h:64
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
void session(lua_State *L)