annotate Plugins/Output/crossfade/rate.c @ 395:0923a41170bb trunk

[svn] Add S3M support back after receiving a convincing testcase.
author chainsaw
date Sat, 07 Jan 2006 06:18:13 -0800
parents 88b38e2414a1
children 5b81b0f310e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2 * XMMS Crossfade Plugin
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
3 * Copyright (C) 2000-2004 Peter Eisenlohr <peter@eisenlohr.org>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
4 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
5 * based on the original OSS Output Plugin
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
6 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
7 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
11 * (at your option) any later version.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
12 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
16 * GNU General Public License for more details.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
17 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
21 * USA.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
22 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
23
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
24 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
25 * Rate conversion for 16bit stereo samples.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
26 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
27 * The algorithm (Least Common Multiple Linear Interpolation) was
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
28 * adapted from the rate conversion code used in
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
29 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
30 * sox-12.16, Copyright 1998 Fabrice Bellard, originally
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
31 * Copyright 1991 Lance Norskog And Sundry Contributors.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
32 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
33 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
34 * NOTE: As of XMMS-crossfade 0.3.6, the resampling code has been extended
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
35 * to use libsamplerate (also known as Secret Rabbit Code) for better
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
36 * quality. See http://www.mega-nerd.com/SRC/ for details.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
37 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
38 * CREDIT: While I started implementing support on my own, it never reached
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
39 * a usable state. A working re-implementation of libsamplerate
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
40 * support has finally been provided by Samuel Krempp.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
41 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
42 * Many thanks for your work and the patch!
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
43 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
44
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
45
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
46 #ifdef HAVE_CONFIG_H
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
47 # include "config.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
48 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
49
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
50 #include "crossfade.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
51 #include "rate.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
52 #include "volume.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
53
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
54 #include <string.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
55 #include <assert.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
56 #include <math.h> /* for ceil */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
57
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
58
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
59 #ifndef HAVE_LIBSAMPLERATE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
60 static glong gcd(glong m, glong n)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
61 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
62 glong r;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
63 while(1) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
64 r = m % n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
65 if(r == 0) return n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
66 m = n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
67 n = r;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
68 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
69 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
70
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
71 static glong lcm(gint i, gint j)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
72 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
73 return ((glong)i * j) / gcd(i, j);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
74 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
75 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
76
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
77
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
78 void rate_init(rate_context_t *rc)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
79 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
80 memset(rc, 0, sizeof(*rc));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
81 volume_init(&rc->vc);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
82 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
83
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
84 void rate_config(rate_context_t *rc, gint in_rate, gint out_rate, int converter_type)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
85 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
86 if((in_rate <= 0) || (in_rate > 65535) ||
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
87 (out_rate <= 0) || (out_rate > 65535)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
88 DEBUG(("[crossfade] rate_config: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
89 "illegal rates (in=%d, out=%d)!\n", in_rate, out_rate));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
90 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
91 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
92
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
93 rate_free(rc);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
94
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
95 rc->in_rate = in_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
96 rc->out_rate = out_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
97 #ifdef HAVE_LIBSAMPLERATE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
98 rc->converter_type = converter_type;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
99 rc->src_data.src_ratio = out_rate *1.0/ in_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
100 if (!(rc->src_state = src_new(converter_type, 2, NULL))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
101 DEBUG(("[crossfade] rate_config: error creating converter!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
102 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
103 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
104 DEBUG(("[crossfade] rate_config: using \"%s\" for %d -> %d rate conversion\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
105 src_get_name(converter_type), in_rate, out_rate));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
106
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
107 src_set_ratio(rc->src_state, rc->src_data.src_ratio);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
108 rc->src_data.end_of_input = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
109 #else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
110 rc->lcm_rate = lcm(in_rate, out_rate);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
111 rc->in_skip = rc->lcm_rate / in_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
112 rc->out_skip = rc->lcm_rate / out_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
113 rc->in_ofs = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
114 rc->out_ofs = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
115 rc->started = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
116 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
117 rc->valid = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
118 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
119
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
120 gint realloc_if_needed(gpointer *pointer, gint *size, gint req_size)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
121 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
122 gpointer data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
123 if(req_size==0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
124 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
125
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
126 if(!*pointer || *size < req_size ) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
127 DEBUG(("*** allocation %d bytes\n", req_size));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
128 if(!(data = g_realloc(*pointer, req_size) ) ) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
129 DEBUG(("[crossfade] rate_flow: g_realloc(%d) failed!\n", req_size));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
130 return -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
131 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
132 *pointer = data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
133 *size = req_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
134 return req_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
135 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
136 else return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
137 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
138
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
139 gint16 final_quantize(volume_context_t *vc, gfloat v, gfloat scale)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
140 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
141 if(config->mixer_software)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
142 v *= scale;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
143
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
144 v = rintf(v);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
145 if(v > 32767 || v < -32768) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
146 ++vc->clips;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
147 v = CLAMP(v, -32768, 32767);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
148 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
149
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
150 return (gint16) v;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
151 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
152
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
153 gint rate_flow(rate_context_t *rc, gpointer *buffer, gint length)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
154 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
155 gint size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
156 gfloat volume_scale_l=1, volume_scale_r=1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
157 struct timeval tv;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
158 glong dt;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
159
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
160 /* print clipping warnings at most once every second : */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
161 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
162 dt = (tv.tv_sec - rc->vc.tv_last.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
163 + (tv.tv_usec - rc->vc.tv_last.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
164 if(((dt < 0) || (dt > 1000)) && (rc->vc.clips > 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
165 g_message("[crossfade] final_quantize: %d samples clipped!", rc->vc.clips);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
166 rc->vc.clips = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
167 rc->vc.tv_last = tv;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
168 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
169
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
170 /* attenuate 1dB every 4% -> 25dB for 100% */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
171 if(config->mixer_software) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
172 volume_scale_l = volume_compute_factor(config->mixer_vol_left, 25);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
173 volume_scale_r = volume_compute_factor(config->mixer_vol_right, 25);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
174 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
175
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
176 if(rc->in_rate == rc->out_rate) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
177 /* trivial case, special code (no actual resampling !) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
178 gint16 *int_p = *buffer, *int_p2 = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
179 gint i;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
180
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
181 gint error = realloc_if_needed((gpointer*) &rc->data, &rc->size, length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
182 assert(error != -1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
183 int_p2 = rc->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
184
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
185 length /= 4; /* 2 channels x 2 bytes */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
186 for(i=0; i<length; i++) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
187 gfloat v_l = *(int_p++);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
188 gfloat v_r = *(int_p++);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
189 *(int_p2 ++) = final_quantize(&rc->vc, v_l, volume_scale_l);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
190 *(int_p2 ++) = final_quantize(&rc->vc, v_r, volume_scale_r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
191 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
192
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
193 *buffer = rc->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
194 return length*4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
195 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
196
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
197 #ifdef HAVE_LIBSAMPLERATE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
198 gint16 *int_p;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
199 gfloat *float_p;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
200 gint i, out_bound, out_len, error = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
201
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
202 assert( length % 4 == 0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
203 length /= 4; /* 2 channels x 2 bytes */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
204 /* safe upper bound of output length: */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
205 out_bound = (gint) ceil((rc->src_data.src_ratio + 0.05) * length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
206
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
207 /* (re-)allocate our buffers */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
208 size = length * 2 * sizeof(gfloat);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
209 error = realloc_if_needed((gpointer*)&rc->src_data.data_in, &rc->src_in_size, size);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
210 assert(error != -1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
211
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
212 rc->src_data.input_frames = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
213 rc->src_data.end_of_input = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
214
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
215 size = out_bound * 2 * sizeof(gfloat);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
216 error = realloc_if_needed((gpointer*) &rc->src_data.data_out, &rc->src_out_size, size);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
217 assert(error != -1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
218
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
219 rc->src_data.output_frames = out_bound;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
220
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
221 size = out_bound * 2 * sizeof(gint16);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
222 error = realloc_if_needed((gpointer*) &rc->data, &rc->size, size);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
223 assert(error != -1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
224
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
225 /* putting data into the float buffers : */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
226 float_p = rc->src_data.data_in;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
227 int_p = *buffer;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
228 for(i=0; i < 2*length; i++)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
229 *(float_p++) = (gfloat) *(int_p++) / 32768.;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
230 assert(float_p == rc->src_data.data_in + length*2);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
231
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
232 /* process the float buffers : */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
233 error = src_process(rc->src_state, & rc->src_data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
234 if(error) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
235 g_message("[crossfade] rate_flow : src_error %d (%s)", error, src_strerror(error));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
236 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
237
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
238 float_p = rc->src_data.data_out;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
239 int_p = rc->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
240 out_len = rc->src_data.output_frames_gen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
241 assert(out_len <= out_bound);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
242 assert(rc->src_data.input_frames_used == length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
243
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
244 for(i=0; i<out_len; i++) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
245 gfloat v_l = 32768* *(float_p ++);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
246 gfloat v_r = 32768* *(float_p ++);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
247
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
248 *(int_p ++) = final_quantize(&rc->vc, v_l, volume_scale_l);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
249 *(int_p ++) = final_quantize(&rc->vc, v_r, volume_scale_r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
250 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
251
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
252 *buffer = rc->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
253 return out_len * 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
254
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
255 #else /* rustic resampling */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
256
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
257 gpointer data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
258 gint isamp, emitted = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
259 gint16 *out, *in = *buffer;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
260
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
261 /* some sanity checks */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
262 if(length & 3) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
263 DEBUG(("[crossfade] rate_flow: truncating %d bytes!", length & 3));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
264 length &= -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
265 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
266 isamp = length / 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
267 if(isamp <= 0) return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
268 if(!rc || !rc->valid) return length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
269 if(rc->in_skip == rc->out_skip) return length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
270
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
271 /* (re)allocate buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
272 size = ((isamp * rc->in_skip) / rc->out_skip + 1) * 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
273 if(!rc->data || (size > rc->size)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
274 if(!(data = g_realloc(rc->data, size))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
275 DEBUG(("[crossfade] rate_flow: g_realloc(%d) failed!\n", size));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
276 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
277 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
278 rc->data = data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
279 rc->size = size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
280 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
281 *buffer = out = rc->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
282
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
283 /* first sample? */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
284 if(!rc->started) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
285 rc->last_l = in[0];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
286 rc->last_r = in[1];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
287 rc->started = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
288 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
289
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
290 /* advance input range to span next output */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
291 while(((rc->in_ofs + rc->in_skip) <= rc->out_ofs) && (isamp-- > 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
292 rc->last_l = *in++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
293 rc->last_r = *in++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
294 rc->in_ofs += rc->in_skip;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
295 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
296 if(isamp == 0) return emitted * 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
297
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
298 /* interpolate */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
299 for(;;) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
300 gfloat v_l = rc->last_l + (((gfloat)in[0] - rc->last_l)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
301 * (rc->out_ofs - rc->in_ofs)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
302 / rc->in_skip);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
303
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
304 gfloat v_r = rc->last_r + (((gfloat)in[1] - rc->last_r)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
305 * (rc->out_ofs - rc->in_ofs)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
306 / rc->in_skip);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
307 *(out ++) = final_quantize(&rc->vc, v_l, volume_scale_l);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
308 *(out ++) = final_quantize(&rc->vc, v_r, volume_scale_r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
309 /* count emitted samples*/
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
310 emitted++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
311
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
312 /* advance to next output */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
313 rc->out_ofs += rc->out_skip;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
314
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
315 /* advance input range to span next output */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
316 while((rc->in_ofs + rc->in_skip) <= rc->out_ofs) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
317 rc->last_l = *in++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
318 rc->last_r = *in++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
319 rc->in_ofs += rc->in_skip;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
320 if(--isamp == 0) return emitted * 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
321 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
322
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
323 /* long samples with high LCM's overrun counters! */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
324 if(rc->out_ofs == rc->in_ofs)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
325 rc->out_ofs = rc->in_ofs = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
326 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
327
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
328 return 0; /* program flow never reaches this point */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
329 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
330 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
331
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
332 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
333 rate_free(rate_context_t *rc)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
334 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
335 #ifdef HAVE_LIBSAMPLERATE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
336 if(rc->src_state) src_delete(rc->src_state);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
337 if(rc->src_data.data_in) g_free(rc->src_data.data_in);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
338 if(rc->src_data.data_out) g_free(rc->src_data.data_out);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
339 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
340 if(rc->data) g_free(rc->data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
341
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
342 memset(rc, 0, sizeof(*rc));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
343 }