45 #define debug(fmt, args...) do { } while(0) 49 Mixer(control_cb, cb_handle),
80 buf =
findtag(buf, buflen,
'O');
82 if ((buf ==
nullptr) || (buflen < 12)) {
83 debug(
"output parser failed finding tag, ret: '%s'", buf);
87 if ((ret = sscanf(buf,
"O: %d %d %d %d %d %n",
88 &s[0], &s[1], &s[2], &s[3], &s[4], &n)) != 5) {
89 debug(
"out scaler parse failed on '%s' (got %d, consumed %d)", buf, ret, n);
96 debug(
"no line ending, line is incomplete");
102 scaler.
offset = s[2] / 10000.0f;
111 uint8_t &control_index)
116 buf =
findtag(buf, buflen,
'S');
118 if ((buf ==
nullptr) || (buflen < 16)) {
119 debug(
"control parser failed finding tag, ret: '%s'", buf);
123 if (sscanf(buf,
"S: %u %u %d %d %d %d %d",
124 &u[0], &u[1], &s[0], &s[1], &s[2], &s[3], &s[4]) != 7) {
125 debug(
"control parse failed on '%s'", buf);
131 if (buf ==
nullptr) {
132 debug(
"no line ending, line is incomplete");
136 control_group = u[0];
137 control_index = u[1];
140 scaler.
offset = s[2] / 10000.0f;
154 const char *end = buf + buflen;
163 if (sscanf(buf,
"M: %u%n", &inputs, &used) != 1) {
164 debug(
"simple parse failed on '%s'", buf);
170 debug(
"simple parse got 0 inputs");
176 if (buf ==
nullptr) {
177 debug(
"no line ending, line is incomplete");
183 if (mixinfo ==
nullptr) {
184 debug(
"could not allocate memory for mixer info");
193 if (next_tag ==
'S') {
206 debug(
"simple mixer parser failed parsing out scaler tag, ret: '%s'", buf);
211 for (
unsigned i = 0; i < inputs; i++) {
216 debug(
"simple mixer parser failed parsing ctrl scaler tag, ret: '%s'", buf);
221 sm =
new SimpleMixer(control_cb, cb_handle, mixinfo);
225 debug(
"loaded mixer with %d input(s)", inputs);
228 debug(
"could not allocate memory for mixer");
233 if (mixinfo !=
nullptr) {
309 return (10 * i + ret);
334 if (scaler.
offset > 1.001f) {
338 if (scaler.
offset < -1.001f) {
unsigned set_trim(float trim) override
Set trim offset for this mixer.
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
mixer_scaler_s output_scaler
scaling for the output
static char findnexttag(const char *buf, unsigned buflen)
Find next tag and return it (0 is returned if no tag is found)
static SimpleMixer * from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen)
Factory method with full external configuration.
int check()
Check that the mixer configuration as loaded is sensible.
static const char * skipline(const char *buf, unsigned &buflen)
Skip a line.
ControlCallback _control_cb
client-supplied callback used when fetching control values
SimpleMixer(ControlCallback control_cb, uintptr_t cb_handle, mixer_simple_s *mixinfo)
Constructor.
int(* ControlCallback)(uintptr_t handle, uint8_t control_group, uint8_t control_index, float &control)
Fetch a control value.
static float scale(const mixer_scaler_s &scaler, float input)
Perform simpler linear scaling.
static int scale_check(struct mixer_scaler_s &scaler)
Validate a scaler.
unsigned get_trim(float *trim) override
Get trim offset for this mixer.
static bool string_well_formed(const char *buf, unsigned &buflen)
Check wether the string is well formed and suitable for parsing.
#define MIXER_SIMPLE_SIZE(_icount)
void groups_required(uint32_t &groups) override
Analyses the mix configuration and updates a bitmask of groups that are required. ...
static int parse_control_scaler(const char *buf, unsigned &buflen, mixer_scaler_s &scaler, uint8_t &control_group, uint8_t &control_index)
static int parse_output_scaler(const char *buf, unsigned &buflen, mixer_scaler_s &scaler)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
unsigned mix(float *outputs, unsigned space) override
Perform the mixing function.
mixer_control_s controls[]
actual size of the array is set by control_count
uint8_t control_count
number of inputs
static const char * findtag(const char *buf, unsigned &buflen, char tag)
Find a tag.
uint8_t control_index
index within the control group
uint8_t control_group
group from which the input reads
#define debug(fmt, args...)
mixer_scaler_s scaler
scaling applied to the input before use
Abstract class defining a mixer mixing zero or more inputs to one or more outputs.