blob: 7c77e862859d8c28fdecaf8960eccfe89f0d41c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include "surface.h"
#include <sstream>
#include <iomanip>
#include <iostream>
using namespace std;
using namespace Mackie;
Surface::Surface( uint32_t max_strips, uint32_t unit_strips )
: _max_strips( max_strips ), _unit_strips( unit_strips )
{
}
void Surface::init()
{
init_controls();
init_strips( _max_strips, _unit_strips );
}
Surface::~Surface()
{
// delete groups
for( Groups::iterator it = groups.begin(); it != groups.end(); ++it )
{
delete it->second;
}
// delete controls
for( Controls::iterator it = controls.begin(); it != controls.end(); ++it )
{
delete *it;
}
}
// Mackie-specific, because of multiple devices on separate ports
// add the strips from 9..max_strips
// unit_strips is the number of strips for additional units.
void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips )
{
if ( strips.size() < max_strips )
{
strips.resize( max_strips );
for ( uint32_t i = strips.size(); i < max_strips; ++i )
{
// because I can't find itoa
ostringstream os;
os << "strip_" << i + 1;
string name = os.str();
// shallow copy existing strip
// which works because the controls
// have the same ids across units
Strip * strip = new Strip( *strips[i % unit_strips] );
// update the relevant values
strip->index( i );
strip->name( name );
// add to data structures
groups[name] = strip;
strips[i] = strip;
}
}
}
/**
TODO could optimise this to use enum, but it's only
called during the protocol class instantiation.
generated using
irb -r controls.rb
sf=Surface.new
sf.parse
controls = sf.groups.find{|x| x[0] =~ /strip/}.each{|x| puts x[1]}
controls[1].each {|x| puts "\telse if ( control.name() == \"#{x.name}\" )\n\t{\n\t\t_#{x.name} = reinterpret_cast<#{x.class.name}*>(&control);\n\t}\n"}
*/
void Strip::add( Control & control )
{
Group::add( control );
if ( control.name() == "gain" )
{
_gain = reinterpret_cast<Fader*>(&control);
}
else if ( control.name() == "vpot" )
{
_vpot = reinterpret_cast<Pot*>(&control);
}
else if ( control.name() == "recenable" )
{
_recenable = reinterpret_cast<Button*>(&control);
}
else if ( control.name() == "solo" )
{
_solo = reinterpret_cast<Button*>(&control);
}
else if ( control.name() == "mute" )
{
_mute = reinterpret_cast<Button*>(&control);
}
else if ( control.name() == "select" )
{
_select = reinterpret_cast<Button*>(&control);
}
else if ( control.name() == "vselect" )
{
_vselect = reinterpret_cast<Button*>(&control);
}
else if ( control.name() == "fader_touch" )
{
_fader_touch = reinterpret_cast<Button*>(&control);
}
else if ( control.type() == Control::type_led || control.type() == Control::type_led_ring )
{
// do nothing
cout << "Strip::add not adding " << control << endl;
}
else
{
ostringstream os;
os << "Strip::add: unknown control type " << control;
throw MackieControlException( os.str() );
}
}
|