Subversion Repositories eduke32

Rev

Rev 8561 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8561 Rev 8616
1
/* Extended Module Player
1
/* Extended Module Player
2
 * Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
2
 * Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
3
 *
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the "Software"),
5
 * copy of this software and associated documentation files (the "Software"),
6
 * to deal in the Software without restriction, including without limitation
6
 * to deal in the Software without restriction, including without limitation
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 * and/or sell copies of the Software, and to permit persons to whom the
8
 * and/or sell copies of the Software, and to permit persons to whom the
9
 * Software is furnished to do so, subject to the following conditions:
9
 * Software is furnished to do so, subject to the following conditions:
10
 *
10
 *
11
 * The above copyright notice and this permission notice shall be included in
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
12
 * all copies or substantial portions of the Software.
13
 *
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
 * THE SOFTWARE.
20
 * THE SOFTWARE.
21
 */
21
 */
22
22
23
#include "common.h"
23
#include "common.h"
24
#include "virtual.h"
24
#include "virtual.h"
25
#include "mixer.h"
25
#include "mixer.h"
26
#include "precomp_lut.h"
26
#include "precomp_lut.h"
27
27
28
/* Mixers
28
/* Mixers
29
 *
29
 *
30
 * To increase performance eight mixers are defined, one for each
30
 * To increase performance eight mixers are defined, one for each
31
 * combination of the following parameters: interpolation, resolution
31
 * combination of the following parameters: interpolation, resolution
32
 * and number of channels.
32
 * and number of channels.
33
 */
33
 */
34
#define NEAREST_NEIGHBOR() do { \
34
#define NEAREST_NEIGHBOR() do { \
35
    smp_in = ((int16)sptr[pos] << 8); \
35
    smp_in = ((int16)sptr[pos] << 8); \
36
} while (0)
36
} while (0)
37
37
38
#define NEAREST_NEIGHBOR_16BIT() do { \
38
#define NEAREST_NEIGHBOR_16BIT() do { \
39
    smp_in = sptr[pos]; \
39
    smp_in = sptr[pos]; \
40
} while (0)
40
} while (0)
41
41
42
#define LINEAR_INTERP() do { \
42
#define LINEAR_INTERP() do { \
43
    smp_l1 = ((int16)sptr[pos] << 8); \
43
    smp_l1 = ((int16)sptr[pos] << 8); \
44
    smp_dt = ((int16)sptr[pos + 1] << 8) - smp_l1; \
44
    smp_dt = ((int16)sptr[pos + 1] << 8) - smp_l1; \
45
    smp_in = smp_l1 + (((frac >> 1) * smp_dt) >> (SMIX_SHIFT - 1)); \
45
    smp_in = smp_l1 + (((frac >> 1) * smp_dt) >> (SMIX_SHIFT - 1)); \
46
} while (0)
46
} while (0)
47
47
48
#define LINEAR_INTERP_16BIT() do { \
48
#define LINEAR_INTERP_16BIT() do { \
49
    smp_l1 = sptr[pos]; \
49
    smp_l1 = sptr[pos]; \
50
    smp_dt = sptr[pos + 1] - smp_l1; \
50
    smp_dt = sptr[pos + 1] - smp_l1; \
51
    smp_in = smp_l1 + (((frac >> 1) * smp_dt) >> (SMIX_SHIFT - 1)); \
51
    smp_in = smp_l1 + (((frac >> 1) * smp_dt) >> (SMIX_SHIFT - 1)); \
52
} while (0)
52
} while (0)
53
53
54
/* The following lut settings are PRECOMPUTED. If you plan on changing these
54
/* The following lut settings are PRECOMPUTED. If you plan on changing these
55
 * settings, you MUST also regenerate the arrays.
55
 * settings, you MUST also regenerate the arrays.
56
 */
56
 */
57
/* number of bits used to scale spline coefs */
57
/* number of bits used to scale spline coefs */
58
#define SPLINE_QUANTBITS  14
58
#define SPLINE_QUANTBITS  14
59
#define SPLINE_SHIFT    (SPLINE_QUANTBITS)
59
#define SPLINE_SHIFT    (SPLINE_QUANTBITS)
60
60
61
/* log2(number) of precalculated splines (range is [4..14]) */
61
/* log2(number) of precalculated splines (range is [4..14]) */
62
#define SPLINE_FRACBITS 10
62
#define SPLINE_FRACBITS 10
63
#define SPLINE_LUTLEN (1L<<SPLINE_FRACBITS)
63
#define SPLINE_LUTLEN (1L<<SPLINE_FRACBITS)
64
64
65
#define SPLINE_FRACSHIFT ((16 - SPLINE_FRACBITS) - 2)
65
#define SPLINE_FRACSHIFT ((16 - SPLINE_FRACBITS) - 2)
66
#define SPLINE_FRACMASK  (((1L << (16 - SPLINE_FRACSHIFT)) - 1) & ~3)
66
#define SPLINE_FRACMASK  (((1L << (16 - SPLINE_FRACSHIFT)) - 1) & ~3)
67
67
68
#define SPLINE_INTERP() do { \
68
#define SPLINE_INTERP() do { \
69
    int f = frac >> 6; \
69
    int f = frac >> 6; \
70
    smp_in = (cubic_spline_lut0[f] * sptr[(int)pos - 1] + \
70
    smp_in = (cubic_spline_lut0[f] * sptr[(int)pos - 1] + \
71
              cubic_spline_lut1[f] * sptr[pos    ] + \
71
              cubic_spline_lut1[f] * sptr[pos    ] + \
72
              cubic_spline_lut3[f] * sptr[pos + 2] + \
72
              cubic_spline_lut3[f] * sptr[pos + 2] + \
73
              cubic_spline_lut2[f] * sptr[pos + 1]) >> (SPLINE_SHIFT - 8); \
73
              cubic_spline_lut2[f] * sptr[pos + 1]) >> (SPLINE_SHIFT - 8); \
74
} while (0)
74
} while (0)
75
75
76
#define SPLINE_INTERP_16BIT() do { \
76
#define SPLINE_INTERP_16BIT() do { \
77
    int f = frac >> 6; \
77
    int f = frac >> 6; \
78
    smp_in = (cubic_spline_lut0[f] * sptr[(int)pos - 1] + \
78
    smp_in = (cubic_spline_lut0[f] * sptr[(int)pos - 1] + \
79
              cubic_spline_lut1[f] * sptr[pos    ] + \
79
              cubic_spline_lut1[f] * sptr[pos    ] + \
80
              cubic_spline_lut3[f] * sptr[pos + 2] + \
80
              cubic_spline_lut3[f] * sptr[pos + 2] + \
81
              cubic_spline_lut2[f] * sptr[pos + 1]) >> SPLINE_SHIFT; \
81
              cubic_spline_lut2[f] * sptr[pos + 1]) >> SPLINE_SHIFT; \
82
} while (0)
82
} while (0)
83
83
84
#define LOOP_AC for (; count > ramp; count--)
84
#define LOOP_AC for (; count > ramp; count--)
85
85
86
#define LOOP for (; count; count--)
86
#define LOOP for (; count; count--)
87
87
88
#define UPDATE_POS() do { \
88
#define UPDATE_POS() do { \
89
    frac += step; \
89
    frac += step; \
90
    pos += frac >> SMIX_SHIFT; \
90
    pos += frac >> SMIX_SHIFT; \
91
    frac &= SMIX_MASK; \
91
    frac &= SMIX_MASK; \
92
} while (0)
92
} while (0)
93
93
94
#define MIX_MONO() do { \
94
#define MIX_MONO() do { \
95
    *(buffer++) += smp_in * vl; \
95
    *(buffer++) += smp_in * vl; \
96
} while (0)
96
} while (0)
97
97
98
#define MIX_MONO_AC() do { \
98
#define MIX_MONO_AC() do { \
99
    *(buffer++) += smp_in * (old_vl >> 8); old_vl += delta_l; \
99
    *(buffer++) += smp_in * (old_vl >> 8); old_vl += delta_l; \
100
} while (0)
100
} while (0)
101
101
102
#define MIX_MONO_FILTER() do { \
102
#define MIX_MONO_FILTER() do { \
103
    sl = (a0 * smp_in * vl + b0 * fl1 + b1 * fl2) >> FILTER_SHIFT; \
103
    sl = (a0 * smp_in * vl + b0 * fl1 + b1 * fl2) >> FILTER_SHIFT; \
104
    fl2 = fl1; fl1 = sl; \
104
    fl2 = fl1; fl1 = sl; \
105
    *(buffer++) += sl; \
105
    *(buffer++) += sl; \
106
} while (0)
106
} while (0)
107
107
108
#define MIX_MONO_FILTER_AC() do { \
108
#define MIX_MONO_FILTER_AC() do { \
109
    int vl = old_vl >> 8; \
109
    int vl = old_vl >> 8; \
110
    MIX_MONO_FILTER(); \
110
    MIX_MONO_FILTER(); \
111
    old_vl += delta_l; \
111
    old_vl += delta_l; \
112
} while (0)
112
} while (0)
113
113
114
#define MIX_STEREO() do { \
114
#define MIX_STEREO() do { \
115
    *(buffer++) += smp_in * vr; \
115
    *(buffer++) += smp_in * vr; \
116
    *(buffer++) += smp_in * vl; \
116
    *(buffer++) += smp_in * vl; \
117
} while (0)
117
} while (0)
118
118
119
#define MIX_STEREO_AC() do { \
119
#define MIX_STEREO_AC() do { \
120
    *(buffer++) += smp_in * (old_vr >> 8); old_vr += delta_r; \
120
    *(buffer++) += smp_in * (old_vr >> 8); old_vr += delta_r; \
121
    *(buffer++) += smp_in * (old_vl >> 8); old_vl += delta_l; \
121
    *(buffer++) += smp_in * (old_vl >> 8); old_vl += delta_l; \
122
} while (0)
122
} while (0)
123
123
124
#define MIX_STEREO_FILTER() do { \
124
#define MIX_STEREO_FILTER() do { \
125
    sr = (a0 * smp_in * vr + b0 * fr1 + b1 * fr2) >> FILTER_SHIFT; \
125
    sr = (a0 * smp_in * vr + b0 * fr1 + b1 * fr2) >> FILTER_SHIFT; \
126
    fr2 = fr1; fr1 = sr; \
126
    fr2 = fr1; fr1 = sr; \
127
    sl = (a0 * smp_in * vl + b0 * fl1 + b1 * fl2) >> FILTER_SHIFT; \
127
    sl = (a0 * smp_in * vl + b0 * fl1 + b1 * fl2) >> FILTER_SHIFT; \
128
    fl2 = fl1; fl1 = sl; \
128
    fl2 = fl1; fl1 = sl; \
129
    *(buffer++) += sr; \
129
    *(buffer++) += sr; \
130
    *(buffer++) += sl; \
130
    *(buffer++) += sl; \
131
} while (0)
131
} while (0)
132
132
133
#define MIX_STEREO_FILTER_AC() do { \
133
#define MIX_STEREO_FILTER_AC() do { \
134
    int vr = old_vr >> 8; \
134
    int vr = old_vr >> 8; \
135
    int vl = old_vl >> 8; \
135
    int vl = old_vl >> 8; \
136
    MIX_STEREO_FILTER(); \
136
    MIX_STEREO_FILTER(); \
137
    old_vr += delta_r; \
137
    old_vr += delta_r; \
138
    old_vl += delta_l; \
138
    old_vl += delta_l; \
139
} while (0)
139
} while (0)
140
140
141
#define MIX_STEREO_FILTER_AC() do { \
141
#define MIX_STEREO_FILTER_AC() do { \
142
    int vr = old_vr >> 8; \
142
    int vr = old_vr >> 8; \
143
    int vl = old_vl >> 8; \
143
    int vl = old_vl >> 8; \
144
    MIX_STEREO_FILTER(); \
144
    MIX_STEREO_FILTER(); \
145
    old_vr += delta_r; \
145
    old_vr += delta_r; \
146
    old_vl += delta_l; \
146
    old_vl += delta_l; \
147
} while (0)
147
} while (0)
148
148
149
#define VAR_NORM(x) \
149
#define VAR_NORM(x) \
150
    int smp_in; \
150
    int smp_in; \
151
    x *sptr = (x *)vi->sptr; \
151
    x *sptr = (x *)vi->sptr; \
152
    unsigned int pos = (unsigned int)vi->pos; \
152
    unsigned int pos = (unsigned int)vi->pos; \
153
    if (vi->pos >= vi->slen) return; \
-
 
154
    int frac = (int)((1 << SMIX_SHIFT) * (vi->pos - (int)vi->pos))
153
    int frac = (int)((1 << SMIX_SHIFT) * (vi->pos - (int)vi->pos))
155
154
156
#define VAR_LINEAR_MONO(x) \
155
#define VAR_LINEAR_MONO(x) \
157
    VAR_NORM(x); \
156
    VAR_NORM(x); \
158
    int old_vl = vi->old_vl; \
157
    int old_vl = vi->old_vl; \
159
    int smp_l1, smp_dt
158
    int smp_l1, smp_dt
160
159
161
#define VAR_LINEAR_STEREO(x) \
160
#define VAR_LINEAR_STEREO(x) \
162
    VAR_LINEAR_MONO(x); \
161
    VAR_LINEAR_MONO(x); \
163
    int old_vr = vi->old_vr
162
    int old_vr = vi->old_vr
164
163
165
#define VAR_SPLINE_MONO(x) \
164
#define VAR_SPLINE_MONO(x) \
166
    int old_vl = vi->old_vl; \
165
    int old_vl = vi->old_vl; \
167
    VAR_NORM(x)
166
    VAR_NORM(x)
168
167
169
#define VAR_SPLINE_STEREO(x) \
168
#define VAR_SPLINE_STEREO(x) \
170
    VAR_SPLINE_MONO(x); \
169
    VAR_SPLINE_MONO(x); \
171
    int old_vr = vi->old_vr
170
    int old_vr = vi->old_vr
172
171
173
#ifndef LIBXMP_CORE_DISABLE_IT
172
#ifndef LIBXMP_CORE_DISABLE_IT
174
173
175
#define VAR_FILTER_MONO \
174
#define VAR_FILTER_MONO \
176
    int fl1 = vi->filter.l1, fl2 = vi->filter.l2; \
175
    int fl1 = vi->filter.l1, fl2 = vi->filter.l2; \
177
    int64 a0 = vi->filter.a0, b0 = vi->filter.b0, b1 = vi->filter.b1; \
176
    int64 a0 = vi->filter.a0, b0 = vi->filter.b0, b1 = vi->filter.b1; \
178
    int sl
177
    int sl
179
178
180
#define VAR_FILTER_STEREO \
179
#define VAR_FILTER_STEREO \
181
    VAR_FILTER_MONO; \
180
    VAR_FILTER_MONO; \
182
    int fr1 = vi->filter.r1, fr2 = vi->filter.r2; \
181
    int fr1 = vi->filter.r1, fr2 = vi->filter.r2; \
183
    int sr
182
    int sr
184
183
185
#define SAVE_FILTER_MONO() do { \
184
#define SAVE_FILTER_MONO() do { \
186
    vi->filter.l1 = fl1; \
185
    vi->filter.l1 = fl1; \
187
    vi->filter.l2 = fl2; \
186
    vi->filter.l2 = fl2; \
188
} while (0)
187
} while (0)
189
188
190
#define SAVE_FILTER_STEREO() do { \
189
#define SAVE_FILTER_STEREO() do { \
191
    SAVE_FILTER_MONO(); \
190
    SAVE_FILTER_MONO(); \
192
    vi->filter.r1 = fr1; \
191
    vi->filter.r1 = fr1; \
193
    vi->filter.r2 = fr2; \
192
    vi->filter.r2 = fr2; \
194
} while (0)
193
} while (0)
195
194
196
#endif
195
#endif
197
196
198
197
199
/*
198
/*
200
 * Nearest neighbor mixers
199
 * Nearest neighbor mixers
201
 */
200
 */
202
201
203
/* Handler for 8 bit samples, nearest neighbor mono output
202
/* Handler for 8 bit samples, nearest neighbor mono output
204
 */
203
 */
205
MIXER(mono_8bit_nearest)
204
MIXER(mono_8bit_nearest)
206
{
205
{
207
    VAR_NORM(int8);
206
    VAR_NORM(int8);
208
207
209
    LOOP { NEAREST_NEIGHBOR(); MIX_MONO(); UPDATE_POS(); }
208
    LOOP { NEAREST_NEIGHBOR(); MIX_MONO(); UPDATE_POS(); }
210
}
209
}
211
210
212
211
213
/* Handler for 16 bit samples, nearest neighbor mono output
212
/* Handler for 16 bit samples, nearest neighbor mono output
214
 */
213
 */
215
MIXER(mono_16bit_nearest)
214
MIXER(mono_16bit_nearest)
216
{
215
{
217
    VAR_NORM(int16);
216
    VAR_NORM(int16);
218
217
219
    LOOP { NEAREST_NEIGHBOR_16BIT(); MIX_MONO(); UPDATE_POS(); }
218
    LOOP { NEAREST_NEIGHBOR_16BIT(); MIX_MONO(); UPDATE_POS(); }
220
}
219
}
221
220
222
/* Handler for 8 bit samples, nearest neighbor stereo output
221
/* Handler for 8 bit samples, nearest neighbor stereo output
223
 */
222
 */
224
MIXER(stereo_8bit_nearest)
223
MIXER(stereo_8bit_nearest)
225
{
224
{
226
    VAR_NORM(int8);
225
    VAR_NORM(int8);
227
226
228
    LOOP { NEAREST_NEIGHBOR(); MIX_STEREO(); UPDATE_POS(); }
227
    LOOP { NEAREST_NEIGHBOR(); MIX_STEREO(); UPDATE_POS(); }
229
}
228
}
230
229
231
/* Handler for 16 bit samples, nearest neighbor stereo output
230
/* Handler for 16 bit samples, nearest neighbor stereo output
232
 */
231
 */
233
MIXER(stereo_16bit_nearest)
232
MIXER(stereo_16bit_nearest)
234
{
233
{
235
    VAR_NORM(int16);
234
    VAR_NORM(int16);
236
235
237
    LOOP { NEAREST_NEIGHBOR_16BIT(); MIX_STEREO(); UPDATE_POS(); }
236
    LOOP { NEAREST_NEIGHBOR_16BIT(); MIX_STEREO(); UPDATE_POS(); }
238
}
237
}
239
238
240
239
241
/*
240
/*
242
 * Linear mixers
241
 * Linear mixers
243
 */
242
 */
244
243
245
/* Handler for 8 bit samples, linear interpolated mono output
244
/* Handler for 8 bit samples, linear interpolated mono output
246
 */
245
 */
247
MIXER(mono_8bit_linear)
246
MIXER(mono_8bit_linear)
248
{
247
{
249
    VAR_LINEAR_MONO(int8);
248
    VAR_LINEAR_MONO(int8);
250
249
251
    LOOP_AC { LINEAR_INTERP(); MIX_MONO_AC(); UPDATE_POS(); }
250
    LOOP_AC { LINEAR_INTERP(); MIX_MONO_AC(); UPDATE_POS(); }
252
    LOOP    { LINEAR_INTERP(); MIX_MONO(); UPDATE_POS(); }
251
    LOOP    { LINEAR_INTERP(); MIX_MONO(); UPDATE_POS(); }
253
}
252
}
254
253
255
/* Handler for 16 bit samples, linear interpolated mono output
254
/* Handler for 16 bit samples, linear interpolated mono output
256
 */
255
 */
257
MIXER(mono_16bit_linear)
256
MIXER(mono_16bit_linear)
258
{
257
{
259
    VAR_LINEAR_MONO(int16);
258
    VAR_LINEAR_MONO(int16);
260
259
261
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_MONO_AC(); UPDATE_POS(); }
260
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_MONO_AC(); UPDATE_POS(); }
262
    LOOP    { LINEAR_INTERP_16BIT(); MIX_MONO(); UPDATE_POS(); }
261
    LOOP    { LINEAR_INTERP_16BIT(); MIX_MONO(); UPDATE_POS(); }
263
}
262
}
264
263
265
/* Handler for 8 bit samples, linear interpolated stereo output
264
/* Handler for 8 bit samples, linear interpolated stereo output
266
 */
265
 */
267
MIXER(stereo_8bit_linear)
266
MIXER(stereo_8bit_linear)
268
{
267
{
269
   VAR_LINEAR_STEREO(int8);
268
   VAR_LINEAR_STEREO(int8);
270
269
271
    LOOP_AC { LINEAR_INTERP(); MIX_STEREO_AC(); UPDATE_POS(); }
270
    LOOP_AC { LINEAR_INTERP(); MIX_STEREO_AC(); UPDATE_POS(); }
272
    LOOP    { LINEAR_INTERP(); MIX_STEREO(); UPDATE_POS(); }
271
    LOOP    { LINEAR_INTERP(); MIX_STEREO(); UPDATE_POS(); }
273
}
272
}
274
273
275
/* Handler for 16 bit samples, linear interpolated stereo output
274
/* Handler for 16 bit samples, linear interpolated stereo output
276
 */
275
 */
277
MIXER(stereo_16bit_linear)
276
MIXER(stereo_16bit_linear)
278
{
277
{
279
    VAR_LINEAR_STEREO(int16);
278
    VAR_LINEAR_STEREO(int16);
280
279
281
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_STEREO_AC(); UPDATE_POS(); }
280
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_STEREO_AC(); UPDATE_POS(); }
282
    LOOP    { LINEAR_INTERP_16BIT(); MIX_STEREO(); UPDATE_POS(); }
281
    LOOP    { LINEAR_INTERP_16BIT(); MIX_STEREO(); UPDATE_POS(); }
283
}
282
}
284
283
285
284
286
#ifndef LIBXMP_CORE_DISABLE_IT
285
#ifndef LIBXMP_CORE_DISABLE_IT
287
286
288
/* Handler for 8 bit samples, filtered linear interpolated mono output
287
/* Handler for 8 bit samples, filtered linear interpolated mono output
289
 */
288
 */
290
MIXER(mono_8bit_linear_filter)
289
MIXER(mono_8bit_linear_filter)
291
{
290
{
292
    VAR_LINEAR_MONO(int8);
291
    VAR_LINEAR_MONO(int8);
293
    VAR_FILTER_MONO;
292
    VAR_FILTER_MONO;
294
293
295
    LOOP_AC { LINEAR_INTERP(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
294
    LOOP_AC { LINEAR_INTERP(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
296
    LOOP    { LINEAR_INTERP(); MIX_MONO_FILTER(); UPDATE_POS(); }
295
    LOOP    { LINEAR_INTERP(); MIX_MONO_FILTER(); UPDATE_POS(); }
297
296
298
    SAVE_FILTER_MONO();
297
    SAVE_FILTER_MONO();
299
}
298
}
300
299
301
/* Handler for 16 bit samples, filtered linear interpolated mono output
300
/* Handler for 16 bit samples, filtered linear interpolated mono output
302
 */
301
 */
303
MIXER(mono_16bit_linear_filter)
302
MIXER(mono_16bit_linear_filter)
304
{
303
{
305
    VAR_LINEAR_MONO(int16);
304
    VAR_LINEAR_MONO(int16);
306
    VAR_FILTER_MONO;
305
    VAR_FILTER_MONO;
307
306
308
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
307
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
309
    LOOP    { LINEAR_INTERP_16BIT(); MIX_MONO_FILTER(); UPDATE_POS(); }
308
    LOOP    { LINEAR_INTERP_16BIT(); MIX_MONO_FILTER(); UPDATE_POS(); }
310
309
311
    SAVE_FILTER_MONO();
310
    SAVE_FILTER_MONO();
312
}
311
}
313
312
314
/* Handler for 8 bit samples, filtered linear interpolated stereo output
313
/* Handler for 8 bit samples, filtered linear interpolated stereo output
315
 */
314
 */
316
MIXER(stereo_8bit_linear_filter)
315
MIXER(stereo_8bit_linear_filter)
317
{
316
{
318
    VAR_LINEAR_STEREO(int8);
317
    VAR_LINEAR_STEREO(int8);
319
    VAR_FILTER_STEREO;
318
    VAR_FILTER_STEREO;
320
319
321
    LOOP_AC { LINEAR_INTERP(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
320
    LOOP_AC { LINEAR_INTERP(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
322
    LOOP    { LINEAR_INTERP(); MIX_STEREO_FILTER(); UPDATE_POS(); }
321
    LOOP    { LINEAR_INTERP(); MIX_STEREO_FILTER(); UPDATE_POS(); }
323
322
324
    SAVE_FILTER_STEREO();
323
    SAVE_FILTER_STEREO();
325
}
324
}
326
325
327
/* Handler for 16 bit samples, filtered linear interpolated stereo output
326
/* Handler for 16 bit samples, filtered linear interpolated stereo output
328
 */
327
 */
329
MIXER(stereo_16bit_linear_filter)
328
MIXER(stereo_16bit_linear_filter)
330
{
329
{
331
    VAR_LINEAR_STEREO(int16);
330
    VAR_LINEAR_STEREO(int16);
332
    VAR_FILTER_STEREO;
331
    VAR_FILTER_STEREO;
333
332
334
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
333
    LOOP_AC { LINEAR_INTERP_16BIT(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
335
    LOOP    { LINEAR_INTERP_16BIT(); MIX_STEREO_FILTER(); UPDATE_POS(); }
334
    LOOP    { LINEAR_INTERP_16BIT(); MIX_STEREO_FILTER(); UPDATE_POS(); }
336
335
337
    SAVE_FILTER_STEREO();
336
    SAVE_FILTER_STEREO();
338
}
337
}
339
338
340
#endif
339
#endif
341
340
342
/*
341
/*
343
 * Spline mixers
342
 * Spline mixers
344
 */
343
 */
345
344
346
/* Handler for 8 bit samples, spline interpolated mono output
345
/* Handler for 8 bit samples, spline interpolated mono output
347
 */
346
 */
348
MIXER(mono_8bit_spline)
347
MIXER(mono_8bit_spline)
349
{
348
{
350
    VAR_SPLINE_MONO(int8);
349
    VAR_SPLINE_MONO(int8);
351
350
352
    LOOP_AC { SPLINE_INTERP(); MIX_MONO_AC(); UPDATE_POS(); }
351
    LOOP_AC { SPLINE_INTERP(); MIX_MONO_AC(); UPDATE_POS(); }
353
    LOOP    { SPLINE_INTERP(); MIX_MONO(); UPDATE_POS(); }
352
    LOOP    { SPLINE_INTERP(); MIX_MONO(); UPDATE_POS(); }
354
}
353
}
355
354
356
/* Handler for 16 bit samples, spline interpolated mono output
355
/* Handler for 16 bit samples, spline interpolated mono output
357
 */
356
 */
358
MIXER(mono_16bit_spline)
357
MIXER(mono_16bit_spline)
359
{
358
{
360
    VAR_SPLINE_MONO(int16);
359
    VAR_SPLINE_MONO(int16);
361
360
362
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_MONO_AC(); UPDATE_POS(); }
361
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_MONO_AC(); UPDATE_POS(); }
363
    LOOP    { SPLINE_INTERP_16BIT(); MIX_MONO(); UPDATE_POS(); }
362
    LOOP    { SPLINE_INTERP_16BIT(); MIX_MONO(); UPDATE_POS(); }
364
}
363
}
365
364
366
/* Handler for 8 bit samples, spline interpolated stereo output
365
/* Handler for 8 bit samples, spline interpolated stereo output
367
 */
366
 */
368
MIXER(stereo_8bit_spline)
367
MIXER(stereo_8bit_spline)
369
{
368
{
370
    VAR_SPLINE_STEREO(int8);
369
    VAR_SPLINE_STEREO(int8);
371
370
372
    LOOP_AC { SPLINE_INTERP(); MIX_STEREO_AC(); UPDATE_POS(); }
371
    LOOP_AC { SPLINE_INTERP(); MIX_STEREO_AC(); UPDATE_POS(); }
373
    LOOP    { SPLINE_INTERP(); MIX_STEREO(); UPDATE_POS(); }
372
    LOOP    { SPLINE_INTERP(); MIX_STEREO(); UPDATE_POS(); }
374
}
373
}
375
374
376
/* Handler for 16 bit samples, spline interpolated stereo output
375
/* Handler for 16 bit samples, spline interpolated stereo output
377
 */
376
 */
378
MIXER(stereo_16bit_spline)
377
MIXER(stereo_16bit_spline)
379
{
378
{
380
    VAR_SPLINE_STEREO(int16);
379
    VAR_SPLINE_STEREO(int16);
381
380
382
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_STEREO_AC(); UPDATE_POS(); }
381
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_STEREO_AC(); UPDATE_POS(); }
383
    LOOP    { SPLINE_INTERP_16BIT(); MIX_STEREO(); UPDATE_POS(); }
382
    LOOP    { SPLINE_INTERP_16BIT(); MIX_STEREO(); UPDATE_POS(); }
384
}
383
}
385
384
386
#ifndef LIBXMP_CORE_DISABLE_IT
385
#ifndef LIBXMP_CORE_DISABLE_IT
387
386
388
/* Handler for 8 bit samples, filtered spline interpolated mono output
387
/* Handler for 8 bit samples, filtered spline interpolated mono output
389
 */
388
 */
390
MIXER(mono_8bit_spline_filter)
389
MIXER(mono_8bit_spline_filter)
391
{
390
{
392
    VAR_SPLINE_MONO(int8);
391
    VAR_SPLINE_MONO(int8);
393
    VAR_FILTER_MONO;
392
    VAR_FILTER_MONO;
394
393
395
    LOOP_AC { SPLINE_INTERP(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
394
    LOOP_AC { SPLINE_INTERP(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
396
    LOOP    { SPLINE_INTERP(); MIX_MONO_FILTER(); UPDATE_POS(); }
395
    LOOP    { SPLINE_INTERP(); MIX_MONO_FILTER(); UPDATE_POS(); }
397
396
398
    SAVE_FILTER_MONO();
397
    SAVE_FILTER_MONO();
399
}
398
}
400
399
401
/* Handler for 16 bit samples, filtered spline interpolated mono output
400
/* Handler for 16 bit samples, filtered spline interpolated mono output
402
 */
401
 */
403
MIXER(mono_16bit_spline_filter)
402
MIXER(mono_16bit_spline_filter)
404
{
403
{
405
    VAR_SPLINE_MONO(int16);
404
    VAR_SPLINE_MONO(int16);
406
    VAR_FILTER_MONO;
405
    VAR_FILTER_MONO;
407
406
408
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
407
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_MONO_FILTER_AC(); UPDATE_POS(); }
409
    LOOP    { SPLINE_INTERP_16BIT(); MIX_MONO_FILTER(); UPDATE_POS(); }
408
    LOOP    { SPLINE_INTERP_16BIT(); MIX_MONO_FILTER(); UPDATE_POS(); }
410
409
411
    SAVE_FILTER_MONO();
410
    SAVE_FILTER_MONO();
412
}
411
}
413
412
414
/* Handler for 8 bit samples, filtered spline interpolated stereo output
413
/* Handler for 8 bit samples, filtered spline interpolated stereo output
415
 */
414
 */
416
MIXER(stereo_8bit_spline_filter)
415
MIXER(stereo_8bit_spline_filter)
417
{
416
{
418
    VAR_SPLINE_STEREO(int8);
417
    VAR_SPLINE_STEREO(int8);
419
    VAR_FILTER_STEREO;
418
    VAR_FILTER_STEREO;
420
419
421
    LOOP_AC { SPLINE_INTERP(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
420
    LOOP_AC { SPLINE_INTERP(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
422
    LOOP    { SPLINE_INTERP(); MIX_STEREO_FILTER(); UPDATE_POS(); }
421
    LOOP    { SPLINE_INTERP(); MIX_STEREO_FILTER(); UPDATE_POS(); }
423
422
424
    SAVE_FILTER_STEREO();
423
    SAVE_FILTER_STEREO();
425
}
424
}
426
425
427
/* Handler for 16 bit samples, filtered spline interpolated stereo output
426
/* Handler for 16 bit samples, filtered spline interpolated stereo output
428
 */
427
 */
429
MIXER(stereo_16bit_spline_filter)
428
MIXER(stereo_16bit_spline_filter)
430
{
429
{
431
    VAR_SPLINE_STEREO(int16);
430
    VAR_SPLINE_STEREO(int16);
432
    VAR_FILTER_STEREO;
431
    VAR_FILTER_STEREO;
433
432
434
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
433
    LOOP_AC { SPLINE_INTERP_16BIT(); MIX_STEREO_FILTER_AC(); UPDATE_POS(); }
435
    LOOP    { SPLINE_INTERP_16BIT(); MIX_STEREO_FILTER(); UPDATE_POS(); }
434
    LOOP    { SPLINE_INTERP_16BIT(); MIX_STEREO_FILTER(); UPDATE_POS(); }
436
435
437
    SAVE_FILTER_STEREO();
436
    SAVE_FILTER_STEREO();
438
}
437
}
439
438
440
#endif
439
#endif
441
 
440