2 Copyright (C) 2000-2002 Paul Davis
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.
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.
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.
20 #define __STDC_FORMAT_MACROS
25 #include <sigc++/bind.h>
27 #include <pbd/error.h>
28 #include <pbd/enumwriter.h>
30 #include <ardour/route_group.h>
31 #include <ardour/audio_track.h>
32 #include <ardour/audio_diskstream.h>
33 #include <ardour/configuration.h>
35 using namespace ARDOUR;
39 RouteGroup::RouteGroup (Session& s, const string &n, Flag f)
40 : _session (s), _name (n), _flags (f)
45 RouteGroup::set_name (string str)
48 _session.set_dirty ();
49 FlagsChanged (0); /* EMIT SIGNAL */
53 RouteGroup::add (Route *r)
56 r->GoingAway.connect (sigc::bind (mem_fun (*this, &RouteGroup::remove_when_going_away), r));
57 _session.set_dirty ();
58 changed (); /* EMIT SIGNAL */
63 RouteGroup::remove_when_going_away (Route *r)
69 RouteGroup::remove (Route *r)
71 list<Route *>::iterator i;
73 if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
75 _session.set_dirty ();
76 changed (); /* EMIT SIGNAL */
84 RouteGroup::get_min_factor(gain_t factor)
88 for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
91 if ( (g+g*factor) >= 0.0f)
94 if ( g <= 0.0000003f )
97 factor = 0.0000003f/g - 1.0f;
103 RouteGroup::get_max_factor(gain_t factor)
107 for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
110 // if the current factor woulnd't raise this route above maximum
111 if ( (g+g*factor) <= 1.99526231f)
114 // if route gain is already at peak, return 0.0f factor
118 // factor is calculated so that it would raise current route to max
119 factor = 1.99526231f/g - 1.0f;
126 RouteGroup::get_state (void)
128 XMLNode *node = new XMLNode ("RouteGroup");
129 node->add_property ("name", _name);
130 node->add_property ("flags", enum_2_string (_flags));
135 RouteGroup::set_state (const XMLNode& node)
137 const XMLProperty *prop;
139 if ((prop = node.property ("name")) != 0) {
140 _name = prop->value();
143 if ((prop = node.property ("flags")) != 0) {
144 _flags = Flag (string_2_enum (prop->value(), _flags));
151 RouteGroup::set_active (bool yn, void *src)
153 if (is_active() == yn) {
157 _flags = Flag (_flags | Active);
159 _flags = Flag (_flags & ~Active);
161 _session.set_dirty ();
162 FlagsChanged (src); /* EMIT SIGNAL */
166 RouteGroup::set_relative (bool yn, void *src)
169 if (is_relative() == yn) {
173 _flags = Flag (_flags | Relative);
175 _flags = Flag (_flags & ~Relative);
177 _session.set_dirty ();
178 FlagsChanged (src); /* EMIT SIGNAL */
182 RouteGroup::set_hidden (bool yn, void *src)
185 if (is_hidden() == yn) {
189 _flags = Flag (_flags | Hidden);
190 if (Config->get_hiding_groups_deactivates_groups()) {
191 _flags = Flag (_flags & ~Active);
194 _flags = Flag (_flags & ~Hidden);
195 if (Config->get_hiding_groups_deactivates_groups()) {
196 _flags = Flag (_flags | Active);
199 _session.set_dirty ();
200 FlagsChanged (src); /* EMIT SIGNAL */
204 RouteGroup::audio_track_group (set<AudioTrack*>& ats)
206 for (list<Route*>::iterator i = routes.begin(); i != routes.end(); ++i) {
207 AudioTrack* at = dynamic_cast<AudioTrack*>(*i);