History

Remove deprecated mixer effect

Ulrich Klauer committed 13 years ago

Commit e60dbd61 parent 003122e10 files · +3 −632Browse files

Unified · Split

10 files
  1. ChangeLog +1 −7
  2. msvc10/LibSoX.vcxproj +0 −1
  3. msvc10/LibSoX.vcxproj.filters +0 −3
  4. msvc9/LibSoX.vcproj +0 −4
  5. sox.1 +0 −60
  6. src/CMakeLists.txt +0 −1
  7. src/Makefile.am +1 −1
  8. src/effects.h +0 −1
  9. src/mixer.c +0 −553
  10. src/sox.c +1 −1
ChangeLog+1−7
@@ -16,16 +16,10 @@ Previously deprecated features that have been removed in this release: · 15 unmodified lines
16 14.3.0 O -s/-u/-f -e16 14.3.0 O -s/-u/-f -e
17 14.3.0 O -A/-U/-o/-i/-a/-g -e17 14.3.0 O -A/-U/-o/-i/-a/-g -e
18 14.4.0 E swap with parameters remix18 14.4.0 E swap with parameters remix
19 14.4.0 E mixer remix
19 14.4.1 OpenMP < 3.0 OpenMP >= 3.020 14.4.1 OpenMP < 3.0 OpenMP >= 3.0
20 14.4.1 F ffmpeg ffmpeg/avconv via pipe21 14.4.1 F ffmpeg ffmpeg/avconv via pipe
21 22
22Previously deprecated features (to be removed in future):
23
24 Deprec- Feature [O(ption)] Removal
25 ated in [F(ormat)] [E(ffect)] Replacement due after
26 ------- ---------------------- ---------------------- -------
27 14.4.0 E mixer remix 2013-03-04
28
29Effects:23Effects:
30 24
31 o 'Deemph' can now also be used at 48kHz sample rate. (robs)25 o 'Deemph' can now also be used at 48kHz sample rate. (robs)
msvc10/LibSoX.vcxproj+0−1
@@ -219,7 +219,6 @@ · 218 unmodified lines
219 <ClCompile Include="..\src\ladspa.c" />219 <ClCompile Include="..\src\ladspa.c" />
220 <ClCompile Include="..\src\loudness.c" />220 <ClCompile Include="..\src\loudness.c" />
221 <ClCompile Include="..\src\mcompand.c" />221 <ClCompile Include="..\src\mcompand.c" />
222 <ClCompile Include="..\src\mixer.c" />
223 <ClCompile Include="..\src\noiseprof.c" />222 <ClCompile Include="..\src\noiseprof.c" />
224 <ClCompile Include="..\src\noisered.c" />223 <ClCompile Include="..\src\noisered.c" />
225 <ClCompile Include="..\src\output.c" />224 <ClCompile Include="..\src\output.c" />
msvc10/LibSoX.vcxproj.filters+0−3
@@ -252,9 +252,6 @@ · 251 unmodified lines
252 <ClCompile Include="..\src\mcompand.c">252 <ClCompile Include="..\src\mcompand.c">
253 <Filter>Effect Sources</Filter>253 <Filter>Effect Sources</Filter>
254 </ClCompile>254 </ClCompile>
255 <ClCompile Include="..\src\mixer.c">
256 <Filter>Effect Sources</Filter>
257 </ClCompile>
258 <ClCompile Include="..\src\noiseprof.c">255 <ClCompile Include="..\src\noiseprof.c">
259 <Filter>Effect Sources</Filter>256 <Filter>Effect Sources</Filter>
260 </ClCompile>257 </ClCompile>
msvc9/LibSoX.vcproj+0−4
@@ -729,10 +729,6 @@ · 728 unmodified lines
729 RelativePath="..\src\mcompand.c"729 RelativePath="..\src\mcompand.c"
730 >730 >
731 </File>731 </File>
732 <File
733 RelativePath="..\src\mixer.c"
734 >
735 </File>
736 <File732 <File
737 RelativePath="..\src\noiseprof.c"733 RelativePath="..\src\noiseprof.c"
738 >734 >
sox.1+0−60
@@ -4174,66 +4174,6 @@ See also · 4173 unmodified lines
4174for a volume-changing effect with different capabilities, and4174for a volume-changing effect with different capabilities, and
4175.B compand4175.B compand
4176for a dynamic-range compression/expansion/limiting effect.4176for a dynamic-range compression/expansion/limiting effect.
4177.SS Deprecated Effects
4178The following effects have been renamed or have their functionality
4179included in another effect; they continue to work in this version of
4180SoX but may be removed in future.
4181.TP
4182\fBmixer\fR [ \fB\-l\fR\^|\^\fB\-r\fR\^|\^\fB\-f\fR\^|\^\fB\-b\fR\^|\^\fB\-1\fR\^|\^\fB\-2\fR\^|\^\fB\-3\fR\^|\^\fB\-4\fR\^|\^\fIn\fR{\fB,\fIn\fR} ]
4183Reduce the number of audio channels by mixing or selecting channels,
4184or increase the number of channels by duplicating channels.
4185Note: this effect operates on the audio
4186.I channels
4187within the SoX effects processing chain; it should not be confused with the
4188.B \-m
4189global option (where multiple
4190.I files
4191are mix-combined before entering the effects chain).
4192.SP
4193When reducing the number of channels it is possible to
4194use the \fB\-l\fR, \fB\-r\fR, \fB\-f\fR, \fB\-b\fR,
4195\fB\-1\fR, \fB\-2\fR, \fB\-3\fR, \fB\-4\fR, options to select only
4196the left, right, front, back channel(s) or specific channel
4197for the output instead of averaging the channels.
4198The \fB\-l\fR, and \fB\-r\fR options will do averaging
4199in quad-channel files so select the exact channel to prevent this.
4200.SP
4201The
4202.B mixer
4203effect can also be invoked with up to 16
4204numbers, separated by commas, which specify the proportion (0 = 0% and 1 = 100%)
4205of each input channel that is to be mixed into each output channel.
4206In two-channel mode, 4 numbers are given: l \*(RA l, l \*(RA r, r \*(RA l, and r \*(RA r,
4207respectively.
4208In four-channel mode, the first 4 numbers give the proportions for the
4209left-front output channel, as follows: lf \*(RA lf, rf \*(RA lf, lb \*(RA lf, and
4210rb \*(RA rf.
4211The next 4 give the right-front output in the same order, then
4212left-back and right-back.
4213.SP
4214It is also possible to use the 16 numbers to expand or reduce the
4215channel count; just specify 0 for unused channels.
4216.SP
4217Finally, certain reduced combination of numbers can be specified
4218for certain input/output channel combinations.
4219.ne 7
4220.TS
4221center;
4222cI cI cI lI
4223c c c l .
4224In Ch Out Ch Num Mappings
42252 1 2 l \*(RA l, r \*(RA l
42262 2 1 adjust balance
42274 1 4 lf \*(RA l, rf \*(RA l, lb \*(RA l, rb \*(RA l
42284 2 2 lf \*(RA l&rf \*(RA r, lb \*(RA l&rb \*(RA r
42294 4 1 adjust balance
42304 4 2 front balance, back balance
4231.TE
4232.DT
4233.SP
4234This effect has been superseded by the
4235.B remix
4236effect that handles any number of channels.
4237.SH DIAGNOSTICS4177.SH DIAGNOSTICS
4238Exit status is 0 for no error, 1 if there is a problem with the4178Exit status is 0 for no error, 1 if there is a problem with the
4239command-line parameters, or 2 if an error occurs during file processing.4179command-line parameters, or 2 if an error occurs during file processing.
src/CMakeLists.txt+0−1
@@ -47,7 +47,6 @@ set(effects_srcs · 46 unmodified lines
47 input47 input
48 loudness48 loudness
49 mcompand49 mcompand
50 mixer
51 noiseprof50 noiseprof
52 noisered51 noisered
53 output52 output
src/Makefile.am+1−1
@@ -72,7 +72,7 @@ libsox_la_SOURCES += \ · 71 unmodified lines
72 echo.c echos.c effects.c effects.h effects_i.c effects_i_dsp.c \72 echo.c echos.c effects.c effects.h effects_i.c effects_i_dsp.c \
73 fade.c fft4g.c fft4g.h fifo.h fir.c firfit.c flanger.c gain.c \73 fade.c fft4g.c fft4g.h fifo.h fir.c firfit.c flanger.c gain.c \
74 hilbert.c input.c ladspa.h ladspa.c loudness.c mcompand.c \74 hilbert.c input.c ladspa.h ladspa.c loudness.c mcompand.c \
75 mcompand_xover.h mixer.c noiseprof.c noisered.c \75 mcompand_xover.h noiseprof.c noisered.c \
76 noisered.h output.c overdrive.c pad.c phaser.c rate.c \76 noisered.h output.c overdrive.c pad.c phaser.c rate.c \
77 rate_filters.h rate_half_fir.h rate_poly_fir0.h rate_poly_fir.h \77 rate_filters.h rate_half_fir.h rate_poly_fir0.h rate_poly_fir.h \
78 remix.c repeat.c reverb.c reverse.c silence.c sinc.c skeleff.c \78 remix.c repeat.c reverb.c reverse.c silence.c sinc.c skeleff.c \
src/effects.h+0−1
@@ -51,7 +51,6 @@ · 50 unmodified lines
51 EFFECT(loudness)51 EFFECT(loudness)
52 EFFECT(lowpass)52 EFFECT(lowpass)
53 EFFECT(mcompand)53 EFFECT(mcompand)
54 EFFECT(mixer)
55 EFFECT(noiseprof)54 EFFECT(noiseprof)
56 EFFECT(noisered)55 EFFECT(noisered)
57 EFFECT(norm)56 EFFECT(norm)
src/mixer.c+0−553
@@ -1,553 +0,0 @@
1/* July 5, 1991
2 * Copyright 1991 Lance Norskog And Sundry Contributors
3 * This source code is freely redistributable and may be used for
4 * any purpose. This copyright notice must be maintained.
5 * Lance Norskog And Sundry Contributors are not responsible for
6 * the consequences of using this software.
7 *
8 * Channel duplication code by Graeme W. Gill - 93/5/18
9 * General-purpose panning by Geoffrey H. Kuenning -- 2000/11/28
10 */
11
12/*
13 * libSoX stereo/quad -> mono mixdown effect file.
14 * and mono/stereo -> stereo/quad channel duplication.
15 */
16
17#include "sox_i.h"
18#include <ctype.h>
19#include <string.h>
20#include <stdlib.h>
21
22typedef struct {
23 /* How to generate each output channel. sources[i][j] */
24 /* represents the fraction of channel i that should be passed */
25 /* through to channel j on output, and so forth. Channel 0 is */
26 /* left front, channel 1 is right front, and 2 and 3 are left */
27 /* and right rear, respectively. (GHK) */
28 double sources[4][4];
29 int num_pans;
30 int mix; /* How are we mixing it? */
31} priv_t;
32
33/* MIX_CENTER is shorthand to mix channels together at 50% each */
34#define MIX_CENTER 0
35#define MIX_SPECIFIED 1
36
37
38/*
39 * Process options
40 */
41static int getopts(sox_effect_t * effp, int argc, char **argv)
42{
43 priv_t * mixer = (priv_t *) effp->priv;
44 double* pans = &mixer->sources[0][0];
45 int i;
46 --argc, ++argv;
47
48 for (i = 0; i < 16; i++)
49 pans[i] = 0.0;
50 mixer->mix = MIX_CENTER;
51 mixer->num_pans = 0;
52
53 /* Parse parameters. Since we don't yet know the number of */
54 /* input and output channels, we'll record the information for */
55 /* later. */
56 if (argc == 1) {
57 if (!strcmp(argv[0], "-l")) mixer->mix = 'l';
58 else if (!strcmp(argv[0], "-r")) mixer->mix = 'r';
59 else if (!strcmp(argv[0], "-f")) mixer->mix = 'f';
60 else if (!strcmp(argv[0], "-b")) mixer->mix = 'b';
61 else if (!strcmp(argv[0], "-1")) mixer->mix = '1';
62 else if (!strcmp(argv[0], "-2")) mixer->mix = '2';
63 else if (!strcmp(argv[0], "-3")) mixer->mix = '3';
64 else if (!strcmp(argv[0], "-4")) mixer->mix = '4';
65 else if (argv[0][0] == '-' && !isdigit((int)argv[0][1])
66 && argv[0][1] != '.')
67 return lsx_usage(effp);
68 else {
69 int commas;
70 char *s;
71 mixer->mix = MIX_SPECIFIED;
72 pans[0] = atof(argv[0]);
73 for (s = argv[0], commas = 0; *s; ++s) {
74 if (*s == ',') {
75 ++commas;
76 if (commas >= 16) {
77 lsx_fail("mixer can only take up to 16 pan values");
78 return (SOX_EOF);
79 }
80 pans[commas] = atof(s+1);
81 }
82 }
83 mixer->num_pans = commas + 1;
84 }
85 }
86 else if (argc == 0) {
87 mixer->mix = MIX_CENTER;
88 }
89 else
90 return lsx_usage(effp);
91
92 return (SOX_SUCCESS);
93}
94
95/*
96 * Start processing
97 */
98static int start(sox_effect_t * effp)
99{
100 /*
101 Hmmm, this is tricky. Lemme think:
102 channel orders are [0][0],[0][1], etc.
103 i.e., 0->0, 0->1, 0->2, 0->3, 1->0, 1->1, ...
104 trailing zeros are omitted
105 L/R balance is x= -1 for left only, 1 for right only
106 1->1 channel effects:
107 changing volume by x is x,0,0,0
108 1->2 channel effects:
109 duplicating everywhere is 1,1,0,0
110 1->4 channel effects:
111 duplicating everywhere is 1,1,1,1
112 2->1 channel effects:
113 left only is 1,0,0,0 0,0,0,0
114 right only is 0,0,0,0 1,0,0,0
115 left+right is 0.5,0,0,0 0.5,0,0,0
116 left-right is 1,0,0,0 -1,0,0,0
117 2->2 channel effects:
118 L/R balance can be done several ways. The standard stereo
119 way is both the easiest and the most sensible:
120 min(1-x,1),0,0,0 0,min(1+x,1),0,0
121 left to both is 1,1,0,0
122 right to both is 0,0,0,0 1,1,0,0
123 left+right to both is 0.5,0.5,0,0 0.5,0.5,0,0
124 left-right to both is 1,1,0,0 -1,-1,0,0
125 left-right to left, right-left to right is 1,-1,0,0 -1,1,0,0
126 2->4 channel effects:
127 front duplicated into rear is 1,0,1,0 0,1,0,1
128 front swapped into rear (why?) is 1,0,0,1 0,1,1,0
129 front put into rear as mono (why?) is 1,0,0.5,0.5 0,1,0.5,0.5
130 4->1 channel effects:
131 left front only is 1,0,0,0
132 left only is 0.5,0,0,0 0,0,0,0 0.5,0,0,0
133 etc.
134 4->2 channel effects:
135 merge front/back is 0.5,0,0,0 0,0.5,0,0 0.5,0,0,0 0,0.5,0,0
136 selections similar to above
137 4->4 channel effects:
138 left front to all is 1,1,1,1 0,0,0,0
139 right front to all is 0,0,0,0 1,1,1,1
140 left f/r to all f/r is 1,1,0,0 0,0,0,0 0,0,1,1 0,0,0,0
141 etc.
142
143 The interesting cases from above (deserving of abbreviations of
144 less than 16 numbers) are:
145
146 0) n->n volume change (1 number)
147 1) 1->n duplication (0 numbers)
148 2) 2->1 mixdown (0 or 2 numbers)
149 3) 2->2 balance (1 number)
150 4) 2->2 fully general mix (4 numbers)
151 5) 2->4 duplication (0 numbers)
152 6) 4->1 mixdown (0 or 4 numbers)
153 7) 4->2 mixdown (0, or 2 numbers)
154 8) 4->4 balance (1 or 2 numbers)
155
156 The above has one ambiguity: n->n volume change conflicts with
157 n->n balance for n != 1. In such a case, we'll prefer
158 balance, since there is already a volume effect in vol.c.
159
160 GHK 2000/11/28
161 */
162 priv_t * mixer = (priv_t *) effp->priv;
163 double pans[16];
164 int i, j;
165 int ichan, ochan;
166
167 for (i = 0; i < 16; i++)
168 pans[i] = ((double*)&mixer->sources[0][0])[i];
169
170 ichan = effp->in_signal.channels;
171 ochan = effp->out_signal.channels;
172 if (ochan == -1) {
173 lsx_fail("Output must have known number of channels");
174 return(SOX_EOF);
175 }
176
177 if ((ichan != 1 && ichan != 2 && ichan != 4 &&
178 mixer->mix != MIX_CENTER && ochan != 1)
179 || (ochan != 1 && ochan != 2 && ochan != 4)) {
180 lsx_fail("Can't mix %d -> %d channels", ichan, ochan);
181 return (SOX_EOF);
182 }
183
184 /* Handle the special-case flags */
185 switch (mixer->mix) {
186 case MIX_CENTER:
187 if (ichan == ochan)
188 return SOX_EFF_NULL;
189 break; /* Code below will handle this case */
190 case 'l':
191 if (ichan == 2 && ochan == 1)
192 {
193 pans[0] = 1.0;
194 pans[1] = 0.0;
195 mixer->num_pans = 2;
196 }
197 else if (ichan == 4 && ochan == 1)
198 {
199 pans[0] = 0.5;
200 pans[1] = 0.0;
201 pans[2] = 0.5;
202 pans[3] = 0.0;
203 mixer->num_pans = 4;
204 }
205 else
206 {
207 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
208 return SOX_EOF;
209 }
210 break;
211 case 'r':
212 if (ichan == 2 && ochan == 1)
213 {
214 pans[0] = 0.0;
215 pans[1] = 1.0;
216 mixer->num_pans = 2;
217 }
218 else if (ichan == 4 && ochan == 1)
219 {
220 pans[0] = 0.0;
221 pans[1] = 0.5;
222 pans[2] = 0.0;
223 pans[3] = 0.5;
224 mixer->num_pans = 4;
225 }
226 else
227 {
228 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
229 return SOX_EOF;
230 }
231 break;
232 case 'f':
233 if (ichan == 4 && ochan == 2)
234 {
235 pans[0] = 1.0;
236 pans[1] = 0.0;
237 mixer->num_pans = 2;
238 }
239 else if (ichan == 4 && ochan == 1)
240 {
241 pans[0] = 0.5;
242 pans[1] = 0.5;
243 pans[2] = 0.0;
244 pans[3] = 0.0;
245 mixer->num_pans = 4;
246 }
247 else
248 {
249 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
250 return SOX_EOF;
251 }
252 break;
253 case 'b':
254 if (ichan == 4 && ochan == 2)
255 {
256 pans[0] = 0.0;
257 pans[1] = 1.0;
258 mixer->num_pans = 2;
259 }
260 else if (ichan == 4 && ochan == 1)
261 {
262 pans[0] = 0.0;
263 pans[1] = 0.0;
264 pans[2] = 0.5;
265 pans[3] = 0.5;
266 mixer->num_pans = 4;
267 }
268 else
269 {
270 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
271 return SOX_EOF;
272 }
273 break;
274 case '1':
275 if (ichan == 2 && ochan == 1)
276 {
277 pans[0] = 1.0;
278 pans[1] = 0.0;
279 mixer->num_pans = 2;
280 }
281 else if (ichan == 4 && ochan == 1)
282 {
283 pans[0] = 1.0;
284 pans[1] = 0.0;
285 pans[2] = 0.0;
286 pans[3] = 0.0;
287 mixer->num_pans = 4;
288 }
289 else
290 {
291 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
292 return SOX_EOF;
293 }
294 break;
295 case '2':
296 if (ichan == 2 && ochan == 1)
297 {
298 pans[0] = 0.0;
299 pans[1] = 1.0;
300 mixer->num_pans = 2;
301 }
302 else if (ichan == 4 && ochan == 1)
303 {
304 pans[0] = 0.0;
305 pans[1] = 1.0;
306 pans[2] = 0.0;
307 pans[3] = 0.0;
308 mixer->num_pans = 4;
309 }
310 else
311 {
312 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
313 return SOX_EOF;
314 }
315 break;
316
317 case '3':
318 if (ichan == 4 && ochan == 1)
319 {
320 pans[0] = 0.0;
321 pans[1] = 0.0;
322 pans[2] = 1.0;
323 pans[3] = 0.0;
324 mixer->num_pans = 4;
325 }
326 else
327 {
328 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
329 return SOX_EOF;
330 }
331 break;
332
333 case '4':
334 if (ichan == 4 && ochan == 1)
335 {
336 pans[0] = 0.0;
337 pans[1] = 0.0;
338 pans[2] = 0.0;
339 pans[3] = 1.0;
340 mixer->num_pans = 4;
341 }
342 else
343 {
344 lsx_fail("Can't mix -%c %d -> %d channels", mixer->mix, ichan, ochan);
345 return SOX_EOF;
346 }
347 break;
348
349 case MIX_SPECIFIED:
350 break;
351 default:
352 lsx_fail("Unknown mix option");
353 return SOX_EOF;
354 }
355
356 /* If number of pans is 4 or less then its a shorthand
357 * representation. If user specified it, then we have
358 * garbage in our sources[][] array. Need to clear that
359 * now that all data is stored in pans[] array.
360 */
361 if (mixer->num_pans <= 4)
362 {
363 for (i = 0; i < ichan; i++)
364 {
365 for (j = 0; j < ochan; j++)
366 {
367 mixer->sources[i][j] = 0;
368 }
369 }
370 }
371
372 /* If the number of pans given is 4 or fewer, handle the special */
373 /* cases listed in the comments above. The code is lengthy but */
374 /* straightforward. */
375 if (mixer->num_pans == 0) {
376 /* CASE 1 */
377 if (ichan == 1 && ochan > ichan) {
378 mixer->sources[0][0] = 1.0;
379 mixer->sources[0][1] = 1.0;
380 mixer->sources[0][2] = 1.0;
381 mixer->sources[0][3] = 1.0;
382 }
383 /* CASE 2, 6 */
384 else if (ochan == 1) {
385 mixer->sources[0][0] = 1.0 / ichan;
386 }
387 /* CASE 5 */
388 else if (ichan == 2 && ochan == 4) {
389 mixer->sources[0][0] = 1.0;
390 mixer->sources[0][2] = 1.0;
391 mixer->sources[1][1] = 1.0;
392 mixer->sources[1][3] = 1.0;
393 }
394 /* CASE 7 */
395 else if (ichan == 4 && ochan == 2) {
396 mixer->sources[0][0] = 0.5;
397 mixer->sources[1][1] = 0.5;
398 mixer->sources[2][0] = 0.5;
399 mixer->sources[3][1] = 0.5;
400 }
401 else {
402 lsx_fail("You must specify at least one mix level when using mixer with an unusual number of channels.");
403 return(SOX_EOF);
404 }
405 }
406 else if (mixer->num_pans == 1) {
407 /* Might be volume change or balance change */
408 /* CASE 3 and CASE 8 */
409 if ((ichan == 2 || ichan == 4) && ichan == ochan) {
410 /* -1 is left only, 1 is right only */
411 if (pans[0] <= 0.0) {
412 mixer->sources[1][1] = pans[0] + 1.0;
413 if (mixer->sources[1][1] < 0.0)
414 mixer->sources[1][1] = 0.0;
415 mixer->sources[0][0] = 1.0;
416 }
417 else {
418 mixer->sources[0][0] = 1.0 - pans[0];
419 if (mixer->sources[0][0] < 0.0)
420 mixer->sources[0][0] = 0.0;
421 mixer->sources[1][1] = 1.0;
422 }
423 if (ichan == 4) {
424 mixer->sources[2][2] = mixer->sources[0][0];
425 mixer->sources[3][3] = mixer->sources[1][1];
426 }
427 }
428 else
429 {
430 lsx_fail("Invalid options while not mixing");
431 return SOX_EOF;
432 }
433 }
434 else if (mixer->num_pans == 2) {
435 /* CASE 2 */
436 if (ichan == 2 && ochan == 1) {
437 mixer->sources[0][0] = pans[0];
438 mixer->sources[1][0] = pans[1];
439 }
440 /* CASE 7 */
441 else if (ichan == 4 && ochan == 2) {
442 mixer->sources[0][0] = pans[0];
443 mixer->sources[1][1] = pans[0];
444 mixer->sources[2][0] = pans[1];
445 mixer->sources[3][1] = pans[1];
446 }
447 /* CASE 8 */
448 else if (ichan == 4 && ochan == 4) {
449 /* pans[0] is front -> front, pans[1] is for back */
450 mixer->sources[0][0] = pans[0];
451 mixer->sources[1][1] = pans[0];
452 mixer->sources[2][2] = pans[1];
453 mixer->sources[3][3] = pans[1];
454 }
455 else
456 {
457 lsx_fail("Invalid options for this channel combination");
458 return SOX_EOF;
459 }
460 }
461 else if (mixer->num_pans == 3) {
462 lsx_fail("Invalid options while not mixing");
463 return SOX_EOF;
464 }
465 else if (mixer->num_pans == 4) {
466 /* CASE 4 */
467 if (ichan == 2 && ochan == 2) {
468 /* Shorthand for 2-channel case */
469 mixer->sources[0][0] = pans[0];
470 mixer->sources[0][1] = pans[1];
471 mixer->sources[1][0] = pans[2];
472 mixer->sources[1][1] = pans[3];
473 }
474 /* CASE 6 */
475 else if (ichan == 4 && ochan == 1) {
476 mixer->sources[0][0] = pans[0];
477 mixer->sources[1][0] = pans[1];
478 mixer->sources[2][0] = pans[2];
479 mixer->sources[3][0] = pans[3];
480 }
481 else
482 {
483 lsx_fail("Invalid options for this channel combination");
484 return SOX_EOF;
485 }
486 }
487
488 if (effp->in_signal.mult) {
489 double max_sum = 0;
490
491 for (j = 0; j < (int)effp->out_signal.channels; ++j) {
492 double sum = 0;
493 for (i = 0; i < (int)effp->in_signal.channels; ++i)
494 sum += fabs(mixer->sources[mixer->mix == MIX_CENTER? 0 : i][j]);
495 max_sum = max(max_sum, sum);
496 }
497 if (max_sum > 1)
498 *effp->in_signal.mult /= max_sum;
499 }
500
501 if (effp->in_signal.channels != effp->out_signal.channels)
502 return SOX_SUCCESS;
503
504 for (i = 0; i < (int)effp->in_signal.channels; ++i)
505 for (j = 0; j < (int)effp->out_signal.channels; ++j)
506 if (mixer->sources[i][j] != (i == j))
507 return SOX_SUCCESS;
508
509 return SOX_EFF_NULL;
510}
511
512/*
513 * Process either isamp or osamp samples, whichever is smaller.
514 */
515
516static int flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
517 size_t *isamp, size_t *osamp)
518{
519 priv_t * mixer = (priv_t *) effp->priv;
520 size_t len, done;
521 int ichan, ochan;
522 int i, j;
523 double samp;
524
525 ichan = effp->in_signal.channels;
526 ochan = effp->out_signal.channels;
527 len = *isamp / ichan;
528 if (len > *osamp / ochan)
529 len = *osamp / ochan;
530 for (done = 0; done < len; done++, ibuf += ichan, obuf += ochan) {
531 for (j = 0; j < ochan; j++) {
532 samp = 0.0;
533 for (i = 0; i < ichan; i++)
534 samp += ibuf[i] * mixer->sources[mixer->mix == MIX_CENTER? 0 : i][j];
535 SOX_SAMPLE_CLIP_COUNT(samp, effp->clips);
536 obuf[j] = samp;
537 }
538 }
539 *isamp = len * ichan;
540 *osamp = len * ochan;
541 return (SOX_SUCCESS);
542}
543
544sox_effect_handler_t const * lsx_mixer_effect_fn(void)
545{
546 static sox_effect_handler_t handler = {
547 "mixer",
548 "[ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
549 SOX_EFF_MCHAN | SOX_EFF_CHAN | SOX_EFF_GAIN | SOX_EFF_DEPRECATED,
550 getopts, start, flow, 0, 0, 0, sizeof(priv_t)
551 };
552 return &handler;
553}
src/sox.c+1−1
@@ -1377,7 +1377,7 @@ static int update_status(sox_bool all_done, void * client_data) · 1376 unmodified lines
1377 {1377 {
1378 /* Not very useful, eh! Sample though of the place you1378 /* Not very useful, eh! Sample though of the place you
1379 * could change the value to effects options1379 * could change the value to effects options
1380 * like vol or speed or mixer.1380 * like vol or speed or remix.
1381 * Modify values in user_effargs[current_eff_chain][xxx]1381 * Modify values in user_effargs[current_eff_chain][xxx]
1382 * and then chain will be drain()ed and restarted whence1382 * and then chain will be drain()ed and restarted whence
1383 * this function is existed.1383 * this function is existed.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t