2 ZynAddSubFX - a software synthesizer
4 DSSIControl.h - DSSI control ports "controller"
5 Copyright (C) 2015 Olivier Jolly
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
14 #ifndef ZYNADDSUBFX_DSSICONTROL_H
15 #define ZYNADDSUBFX_DSSICONTROL_H
18 #include "DSSIControlDescription.h"
22 DSSIControlDescription description
;
24 float *data
; /// pointer to the value for this controller which is updated by the DSSI host
27 * Ctr for a DSSIControl based on a DSSIControl description
28 * @param controller_code the controller code
29 * @param name the human readable code name
31 DSSIControl(DSSIControlDescription description
) : description(description
) { }
34 * update the current control to the Master in charge of dispatching them to the parts, effects, ...
35 * @param master the controller master in charge of further dispatch
37 void forward_control(zyn::Master
*master
);
40 * scale the incoming value refereced by data in the hinted range to one expected by the Master dispatcher.
41 * Boolean are toggled to 0 or 127, ...
43 int get_scaled_data() {
44 if (LADSPA_IS_HINT_TOGGLED(description
.port_range_hint
.HintDescriptor
)) {
45 return *data
<= 0 ? 0 : 127;
46 } else if (description
.port_range_hint
.UpperBound
< 127) {
47 // when not using 127 or 128 as upper bound, scale the input using the port range hint to 0 .. 128
48 return 128 * (*data
- description
.port_range_hint
.LowerBound
) /
49 (description
.port_range_hint
.UpperBound
- description
.port_range_hint
.LowerBound
);
57 #endif //ZYNADDSUBFX_DSSICONTROL_H