2 Copyright (C) 2009 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.
19 #include "pbd/strsplit.h"
20 #include "pbd/convert.h"
22 #include "ardour/controllable_descriptor.h"
26 using namespace ARDOUR;
29 ControllableDescriptor::set (const std::string& str)
31 string::size_type first_space = str.find_first_of (" ");
33 if (first_space == string::npos) {
37 string front = str.substr (0, first_space);
38 string back = str.substr (first_space);
41 split (front, path, '/');
43 if (path.size() < 2) {
48 split (back, rest, ' ');
50 if (rest.size() < 1) {
54 if (path[0] == "route" || path[0] == "rid") {
56 _top_level_type = PresentationOrderRoute;
58 if (rest[0][0] == 'B') {
60 _presentation_order = atoi (rest[0].substr (1));
61 } else if (rest[0][0] == 'S') {
62 _top_level_type = SelectionCount;
64 _selection_id = atoi (rest[0].substr (1));
65 } else if (isdigit (rest[0][0])) {
67 _presentation_order = atoi (rest[0]);
72 } else if (path[0] == "vca") {
74 _top_level_type = PresentationOrderVCA;
76 if (rest[0][0] == 'B') {
78 _presentation_order = atoi (rest[0].substr (1));
79 } else if (rest[0][0] == 'S') {
80 _top_level_type = SelectionCount;
82 _selection_id = atoi (rest[0].substr (1));
83 } else if (isdigit (rest[0][0])) {
85 _presentation_order = atoi (rest[0]);
90 } else if (path[0] == "bus" || path[0] == "track") {
92 _top_level_type = NamedRoute;
93 _top_level_name = rest[0];
96 if (path[1] == "gain") {
99 } else if (path[1] == "trim") {
102 } else if (path[1] == "solo") {
105 } else if (path[1] == "mute") {
108 } else if (path[1] == "recenable") {
109 _subtype = Recenable;
111 } else if (path[1] == "balance") {
114 } else if (path[1] == "panwidth") {
117 } else if (path[1] == "pandirection") {
118 _subtype = PanDirection;
120 } else if (path[1] == "plugin") {
121 if (path.size() == 3 && rest.size() == 3) {
122 if (path[2] == "parameter") {
123 _subtype = PluginParameter;
124 _target.push_back (atoi (rest[1]));
125 _target.push_back (atoi (rest[2]));
132 } else if (path[1] == "send") {
134 if (path.size() == 3 && rest.size() == 2) {
135 if (path[2] == "gain") {
137 _target.push_back (atoi (rest[1]));
150 ControllableDescriptor::presentation_order () const
153 return _presentation_order + _bank_offset;
156 return _presentation_order;
160 ControllableDescriptor::selection_id () const
163 return _selection_id + _bank_offset;
166 return _selection_id;
170 ControllableDescriptor::target (uint32_t n) const
172 if (n < _target.size()) {