1 /* libSoX effect: swap pairs of audio channels
3 * First version written 01/2012 by Ulrich Klauer.
4 * Replaces an older swap effect originally written by Chris Bagwell
7 * Copyright 2012 Chris Bagwell and SoX Contributors
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or (at
12 * your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
17 * General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 static int start(sox_effect_t
*effp
)
28 return effp
->in_signal
.channels
>= 2 ? SOX_SUCCESS
: SOX_EFF_NULL
;
31 static int flow(sox_effect_t
*effp
, const sox_sample_t
*ibuf
,
32 sox_sample_t
*obuf
, size_t *isamp
, size_t *osamp
)
34 size_t len
= min(*isamp
, *osamp
);
35 size_t channels
= effp
->in_signal
.channels
;
37 *isamp
= *osamp
= len
* channels
;
41 for (i
= 0; i
+ 1 < channels
; i
+= 2) {
53 sox_effect_handler_t
const *lsx_swap_effect_fn(void)
55 static sox_effect_handler_t handler
= {
57 SOX_EFF_MCHAN
| SOX_EFF_MODIFY
,
58 NULL
, start
, flow
, NULL
, NULL
, NULL
,