Skip to content

Commit bca5323

Browse files
committed
effect: Unify opt_info and plot_info.
1 parent f5e30ee commit bca5323

13 files changed

+31
-34
lines changed

biquad.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2013-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -472,7 +472,7 @@ struct effect * biquad_effect_init(const struct effect_info *ei, const struct st
472472
e->istream.channels = e->ostream.channels = istream->channels;
473473
e->channel_selector = NEW_SELECTOR(istream->channels);
474474
COPY_SELECTOR(e->channel_selector, channel_selector, istream->channels);
475-
e->opt_info |= OPT_INFO_REORDERABLE;
475+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
476476
biquad_effect_set_run_func(e);
477477
e->reset = biquad_effect_reset;
478478
e->plot = biquad_effect_plot;

crossfeed.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2013-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -118,7 +118,7 @@ struct effect * crossfeed_effect_init(const struct effect_info *ei, const struct
118118
e->name = ei->name;
119119
e->istream.fs = e->ostream.fs = istream->fs;
120120
e->istream.channels = e->ostream.channels = istream->channels;
121-
e->plot_info |= PLOT_INFO_MIX;
121+
e->flags |= EFFECT_FLAG_PLOT_MIX;
122122
e->run = crossfeed_effect_run;
123123
e->reset = crossfeed_effect_reset;
124124
e->plot = crossfeed_effect_plot;

decorrelate.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2020-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2020-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -172,7 +172,7 @@ struct effect * decorrelate_effect_init(const struct effect_info *ei, const stru
172172
e->name = ei->name;
173173
e->istream.fs = e->ostream.fs = istream->fs;
174174
e->istream.channels = e->ostream.channels = istream->channels;
175-
e->opt_info |= OPT_INFO_REORDERABLE;
175+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
176176
e->run = decorrelate_effect_run;
177177
e->reset = decorrelate_effect_reset;
178178
e->plot = decorrelate_effect_plot;

delay.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -135,7 +135,7 @@ struct effect * delay_effect_init(const struct effect_info *ei, const struct str
135135
e->name = ei->name;
136136
e->istream.fs = e->ostream.fs = istream->fs;
137137
e->istream.channels = e->ostream.channels = istream->channels;
138-
e->opt_info |= OPT_INFO_REORDERABLE;
138+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
139139
e->run = delay_effect_run;
140140
e->delay = delay_effect_delay;
141141
e->reset = delay_effect_reset;

effect.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2013-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -334,7 +334,7 @@ static void effects_chain_optimize(struct effects_chain *chain)
334334
|| m_src->ostream.channels != m_dest->ostream.channels
335335
) break;
336336
if (m_src->merge == NULL) {
337-
if (m_src->opt_info & OPT_INFO_REORDERABLE) goto skip;
337+
if (m_src->flags & EFFECT_FLAG_OPT_REORDERABLE) goto skip;
338338
break;
339339
}
340340
if (m_dest->merge(m_dest, m_src)) {
@@ -472,8 +472,8 @@ void plot_effects_chain(struct effects_chain *chain, int input_fs, int input_cha
472472
LOG_FMT(LL_ERROR, "plot: error: effect '%s' does not support plotting", e->name);
473473
return;
474474
}
475-
if (e->istream.channels != e->ostream.channels && !(e->plot_info & PLOT_INFO_MIX)) {
476-
LOG_FMT(LL_ERROR, "plot: BUG: effect '%s' changed the number of channels but does not have PLOT_INFO_MIX set!", e->name);
475+
if (e->istream.channels != e->ostream.channels && !(e->flags & EFFECT_FLAG_PLOT_MIX)) {
476+
LOG_FMT(LL_ERROR, "plot: BUG: effect '%s' changed the number of channels but does not have EFFECT_FLAG_PLOT_MIX set!", e->name);
477477
return;
478478
}
479479
fs = e->ostream.fs;
@@ -485,7 +485,7 @@ void plot_effects_chain(struct effects_chain *chain, int input_fs, int input_cha
485485
e = start_e;
486486
int channels = input_channels, start_idx = 0;
487487
for (int i = 0; e != NULL; ++i) {
488-
if (e->plot_info & PLOT_INFO_MIX) {
488+
if (e->flags & EFFECT_FLAG_PLOT_MIX) {
489489
for (int k = 0; k < e->istream.channels; ++k) {
490490
printf("Ht%d_%d(f)=1.0", k, i);
491491
struct effect *e2 = start_e;

effect.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2013-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -30,19 +30,16 @@ struct effect_info {
3030
};
3131

3232
enum {
33-
PLOT_INFO_MIX = 1<<0,
34-
};
35-
36-
enum {
37-
OPT_INFO_REORDERABLE = 1<<0,
33+
EFFECT_FLAG_PLOT_MIX = 1<<0,
34+
EFFECT_FLAG_OPT_REORDERABLE = 1<<1,
3835
};
3936

4037
struct effect {
4138
struct effect *next;
4239
const char *name;
4340
struct stream_info istream, ostream;
4441
char *channel_selector; /* for use *only* by the effect */
45-
int plot_info, opt_info;
42+
int flags;
4643
/* All functions may be NULL */
4744
sample_t * (*run)(struct effect *, ssize_t *, sample_t *, sample_t *); /* if NULL, the effect will not be used */
4845
ssize_t (*delay)(struct effect *); /* returns the latency in frames at ostream.fs */

fir.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -288,7 +288,7 @@ struct effect * fir_effect_init_with_filter(const struct effect_info *ei, const
288288
e->name = ei->name;
289289
e->istream.fs = e->ostream.fs = istream->fs;
290290
e->istream.channels = e->ostream.channels = istream->channels;
291-
e->opt_info |= OPT_INFO_REORDERABLE;
291+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
292292

293293
if (filter_frames <= MAX_DIRECT_LEN || force_direct) {
294294
e->run = fir_direct_effect_run;

fir_p.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2020-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2020-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -263,7 +263,7 @@ struct effect * fir_p_effect_init_with_filter(const struct effect_info *ei, cons
263263
e->name = ei->name;
264264
e->istream.fs = e->ostream.fs = istream->fs;
265265
e->istream.channels = e->ostream.channels = istream->channels;
266-
e->opt_info |= OPT_INFO_REORDERABLE;
266+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
267267
e->run = fir_p_effect_run;
268268
e->reset = fir_p_effect_reset;
269269
e->plot = fir_p_effect_plot;

gain.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2013-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -129,7 +129,7 @@ struct effect * gain_effect_init(const struct effect_info *ei, const struct stre
129129
}
130130
else {
131131
v_noop = 1.0;
132-
e->opt_info |= OPT_INFO_REORDERABLE;
132+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
133133
e->run = gain_effect_run;
134134
e->plot = gain_effect_plot;
135135
e->merge = gain_effect_merge;

noise.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -95,7 +95,7 @@ struct effect * noise_effect_init(const struct effect_info *ei, const struct str
9595
e->istream.channels = e->ostream.channels = istream->channels;
9696
e->channel_selector = NEW_SELECTOR(istream->channels);
9797
COPY_SELECTOR(e->channel_selector, channel_selector, istream->channels);
98-
e->plot_info |= PLOT_INFO_MIX;
98+
e->flags |= EFFECT_FLAG_PLOT_MIX;
9999
e->run = noise_effect_run;
100100
e->plot = noise_effect_plot;
101101
e->destroy = noise_effect_destroy;

remix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -169,7 +169,7 @@ struct effect * remix_effect_init(const struct effect_info *ei, const struct str
169169
e->istream.fs = e->ostream.fs = istream->fs;
170170
e->istream.channels = istream->channels;
171171
e->ostream.channels = out_channels;
172-
e->plot_info |= PLOT_INFO_MIX;
172+
e->flags |= EFFECT_FLAG_PLOT_MIX;
173173
if (use_run_1a) {
174174
state->fast_sel.s1 = calloc(out_channels, sizeof(int));
175175
for (int k = 0; k < out_channels; ++k) {

st2ms.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2018-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2018-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -96,7 +96,7 @@ struct effect * st2ms_effect_init(const struct effect_info *ei, const struct str
9696
e->name = ei->name;
9797
e->istream.fs = e->ostream.fs = istream->fs;
9898
e->istream.channels = e->ostream.channels = istream->channels;
99-
e->plot_info |= PLOT_INFO_MIX;
99+
e->flags |= EFFECT_FLAG_PLOT_MIX;
100100
switch (ei->effect_number) {
101101
case ST2MS_EFFECT_NUMBER_ST2MS:
102102
e->run = st2ms_effect_run;

zita_convolver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2016-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2016-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -229,7 +229,7 @@ struct effect * zita_convolver_effect_init(const struct effect_info *ei, const s
229229
e->istream.channels = e->ostream.channels = istream->channels;
230230
e->channel_selector = (char *) NEW_SELECTOR(istream->channels);
231231
COPY_SELECTOR(e->channel_selector, channel_selector, istream->channels);
232-
e->opt_info |= OPT_INFO_REORDERABLE;
232+
e->flags |= EFFECT_FLAG_OPT_REORDERABLE;
233233
e->run = zita_convolver_effect_run;
234234
e->delay = zita_convolver_effect_delay;
235235
e->reset = zita_convolver_effect_reset;

0 commit comments

Comments
 (0)