simple mixer: make output scalers O: optional and use default values instead

Reduces FLASH usage by about 4KB

Command to replace:
for i in *.mix; do sed -r -i '/O: +10000 +10000 +0 +-10000 +10000/d' $i; done
This commit is contained in:
Beat Küng
2018-05-25 07:57:08 +02:00
parent a9275d6c5b
commit c9d179676e
42 changed files with 53 additions and 147 deletions
+16
View File
@@ -40,6 +40,7 @@
#include "mixer.h"
#include <cstring>
#include <ctype.h>
#define debug(fmt, args...) do { } while(0)
//#define debug(fmt, args...) do { printf("[mixer] " fmt "\n", ##args); } while(0)
@@ -125,6 +126,21 @@ Mixer::findtag(const char *buf, unsigned &buflen, char tag)
return nullptr;
}
char
Mixer::findnexttag(const char *buf, unsigned buflen)
{
while (buflen >= 2) {
if (isupper(buf[0]) && buf[1] == ':') {
return buf[0];
}
buf++;
buflen--;
}
return 0;
}
const char *
Mixer::skipline(const char *buf, unsigned &buflen)
{
+9
View File
@@ -265,6 +265,14 @@ protected:
*/
static const char *findtag(const char *buf, unsigned &buflen, char tag);
/**
* Find next tag and return it (0 is returned if no tag is found)
*
* @param buf The buffer to operate on.
* @param buflen length of the buffer.
*/
static char findnexttag(const char *buf, unsigned buflen);
/**
* Skip a line
*
@@ -340,6 +348,7 @@ public:
* M: <control count>
* O: <-ve scale> <+ve scale> <offset> <lower limit> <upper limit>
*
* The second line O: can be omitted. In that case 'O: 10000 10000 0 -10000 10000' is used.
* The definition continues with <control count> entries describing the control
* inputs and their scaling, in the form:
*
+28 -3
View File
@@ -151,6 +151,7 @@ SimpleMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, c
unsigned inputs;
int used;
const char *end = buf + buflen;
char next_tag;
/* enforce that the mixer ends with a new line */
if (!string_well_formed(buf, buflen)) {
@@ -163,6 +164,12 @@ SimpleMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, c
goto out;
}
/* at least 1 input is required */
if (inputs == 0) {
debug("simple parse got 0 inputs");
goto out;
}
buf = skipline(buf, buflen);
if (buf == nullptr) {
@@ -179,9 +186,27 @@ SimpleMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, c
mixinfo->control_count = inputs;
if (parse_output_scaler(end - buflen, buflen, mixinfo->output_scaler)) {
debug("simple mixer parser failed parsing out scaler tag, ret: '%s'", buf);
goto out;
/* find the next tag */
next_tag = findnexttag(end - buflen, buflen);
if (next_tag == 'S') {
/* No output scalers specified. Use default values.
* Corresponds to:
* O: 10000 10000 0 -10000 10000
*/
mixinfo->output_scaler.negative_scale = 1.0f;
mixinfo->output_scaler.positive_scale = 1.0f;
mixinfo->output_scaler.offset = 0.f;
mixinfo->output_scaler.min_output = -1.0f;
mixinfo->output_scaler.max_output = 1.0f;
} else {
if (parse_output_scaler(end - buflen, buflen, mixinfo->output_scaler)) {
debug("simple mixer parser failed parsing out scaler tag, ret: '%s'", buf);
goto out;
}
}
for (unsigned i = 0; i < inputs; i++) {