diff options
author | Taybin Rutkin <taybin@taybin.com> | 2005-09-24 19:13:41 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2005-09-24 19:13:41 +0000 |
commit | 8af0757b61990767f2a85e68f535a5af9976fd79 (patch) | |
tree | f9e06fe12cac866d658a2e7074a61aa74d12f68f /libs/ardour/route_group.cc | |
parent | f9546e5c76afa101e9dbe8a057e72463b03430e5 (diff) |
libardour added.
git-svn-id: svn://localhost/trunk/ardour2@17 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/route_group.cc')
-rw-r--r-- | libs/ardour/route_group.cc | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc new file mode 100644 index 0000000000..225224e684 --- /dev/null +++ b/libs/ardour/route_group.cc @@ -0,0 +1,184 @@ +/* + Copyright (C) 2000-2002 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id$ +*/ + +#define __STDC_FORMAT_MACROS +#include <inttypes.h> + +#include <algorithm> + +#include <sigc++/bind.h> + +#include <pbd/error.h> + +#include <ardour/route_group.h> +#include <ardour/diskstream.h> +#include <ardour/configuration.h> + +using namespace ARDOUR; +using namespace sigc; + +int +RouteGroup::add (Route *r) +{ + routes.push_back (r); + r->GoingAway.connect (sigc::bind (mem_fun (*this, &RouteGroup::remove_when_going_away), r)); + changed (); /* EMIT SIGNAL */ + return 0; +} + +void +RouteGroup::remove_when_going_away (Route *r) +{ + remove (r); +} + +int +RouteGroup::remove (Route *r) +{ + list<Route *>::iterator i; + + if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { + routes.erase (i); + changed (); /* EMIT SIGNAL */ + return 0; + } + return -1; +} + + +gain_t +RouteGroup::get_min_factor(gain_t factor) +{ + gain_t g; + + for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) { + g = (*i)->gain(); + + if ( (g+g*factor) >= 0.0f) + continue; + + if ( g <= 0.0000003f ) + return 0.0f; + + factor = 0.0000003f/g - 1.0f; + } + return factor; +} + +gain_t +RouteGroup::get_max_factor(gain_t factor) +{ + gain_t g; + + for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) { + g = (*i)->gain(); + + // if the current factor woulnd't raise this route above maximum + if ( (g+g*factor) <= 1.99526231f) + continue; + + // if route gain is already at peak, return 0.0f factor + if (g>=1.99526231f) + return 0.0f; + + // factor is calculated so that it would raise current route to max + factor = 1.99526231f/g - 1.0f; + } + + return factor; +} + +XMLNode& +RouteGroup::get_state (void) +{ + char buf[32]; + XMLNode *node = new XMLNode ("RouteGroup"); + node->add_property ("name", _name); + snprintf (buf, sizeof (buf), "%" PRIu32, (uint32_t) _flags); + node->add_property ("flags", buf); + return *node; +} + +int +RouteGroup::set_state (const XMLNode& node) +{ + const XMLProperty *prop; + + if ((prop = node.property ("name")) != 0) { + _name = prop->value(); + } + + if ((prop = node.property ("flags")) != 0) { + _flags = atoi (prop->value().c_str()); + } + + return 0; +} + +void +RouteGroup::set_active (bool yn, void *src) + +{ + if (is_active() == yn) { + return; + } + if (yn) { + _flags |= Active; + } else { + _flags &= ~Active; + } + FlagsChanged (src); /* EMIT SIGNAL */ +} + +void +RouteGroup::set_relative (bool yn, void *src) + +{ + if (is_relative() == yn) { + return; + } + if (yn) { + _flags |= Relative; + } else { + _flags &= ~Relative; + } + FlagsChanged (src); /* EMIT SIGNAL */ +} + +void +RouteGroup::set_hidden (bool yn, void *src) + +{ + if (is_hidden() == yn) { + return; + } + if (yn) { + _flags |= Hidden; + if (Config->does_hiding_groups_deactivates_groups()) { + _flags &= ~Active; + } + } else { + _flags &= ~Hidden; + if (Config->does_hiding_groups_deactivates_groups()) { + _flags |= Active; + } + } + FlagsChanged (src); /* EMIT SIGNAL */ +} |