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/controllable_descriptor.h"
20 #include "pbd/strsplit.h"
21 #include "pbd/convert.h"
27 ControllableDescriptor::set (const std::string& str)
29 string::size_type first_space = str.find_first_of (" ");
31 if (first_space == string::npos) {
35 string front = str.substr (0, first_space);
36 string back = str.substr (first_space);
39 split (front, path, '/');
41 if (path.size() < 2) {
46 split (back, rest, ' ');
48 if (rest.size() < 1) {
52 if (path[0] == "route" || path[0] == "rid") {
54 _top_level_type = RemoteControlID;
56 if (rest[0][0] == 'B') {
58 _rid = atoi (rest[0].substr (1));
59 } else if (rest[0][0] == 'S') {
60 _top_level_type = SelectionCount;
62 _selection_id = atoi (rest[0].substr (1));
63 } else if (isdigit (rest[0][0])) {
65 _rid = atoi (rest[0]);
70 } else if (path[0] == "bus" || path[0] == "track") {
72 _top_level_type = NamedRoute;
73 _top_level_name = rest[0];
76 if (path[1] == "gain") {
79 } else if (path[1] == "trim") {
82 } else if (path[1] == "solo") {
85 } else if (path[1] == "mute") {
88 } else if (path[1] == "recenable") {
91 } else if (path[1] == "balance") {
94 } else if (path[1] == "panwidth") {
97 } else if (path[1] == "pandirection") {
98 _subtype = PanDirection;
100 } else if (path[1] == "plugin") {
101 if (path.size() == 3 && rest.size() == 3) {
102 if (path[2] == "parameter") {
103 _subtype = PluginParameter;
104 _target.push_back (atoi (rest[1]));
105 _target.push_back (atoi (rest[2]));
112 } else if (path[1] == "send") {
114 if (path.size() == 3 && rest.size() == 2) {
115 if (path[2] == "gain") {
117 _target.push_back (atoi (rest[1]));
130 ControllableDescriptor::rid () const
133 return _rid + _bank_offset;
140 ControllableDescriptor::selection_id () const
143 return _selection_id + _bank_offset;
146 return _selection_id;
150 ControllableDescriptor::target (uint32_t n) const
152 if (n < _target.size()) {