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.
21 #define __STDC_FORMAT_MACROS
26 #include <sigc++/bind.h>
28 #include <pbd/error.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)
129 XMLNode *node = new XMLNode ("RouteGroup");
130 node->add_property ("name", _name);
131 snprintf (buf, sizeof (buf), "%" PRIu32, (uint32_t) _flags);
132 node->add_property ("flags", buf);
137 RouteGroup::set_state (const XMLNode& node)
139 const XMLProperty *prop;
141 if ((prop = node.property ("name")) != 0) {
142 _name = prop->value();
145 if ((prop = node.property ("flags")) != 0) {
146 _flags = atoi (prop->value().c_str());
153 RouteGroup::set_active (bool yn, void *src)
156 if (is_active() == yn) {
164 _session.set_dirty ();
165 FlagsChanged (src); /* EMIT SIGNAL */
169 RouteGroup::set_relative (bool yn, void *src)
172 if (is_relative() == yn) {
180 _session.set_dirty ();
181 FlagsChanged (src); /* EMIT SIGNAL */
185 RouteGroup::set_hidden (bool yn, void *src)
188 if (is_hidden() == yn) {
193 if (Config->get_hiding_groups_deactivates_groups()) {
198 if (Config->get_hiding_groups_deactivates_groups()) {
202 _session.set_dirty ();
203 FlagsChanged (src); /* EMIT SIGNAL */
207 RouteGroup::audio_track_group (set<AudioTrack*>& ats)
209 for (list<Route*>::iterator i = routes.begin(); i != routes.end(); ++i) {
210 AudioTrack* at = dynamic_cast<AudioTrack*>(*i);