+// helpers for simple linear interpolation: delay real val for two slots,
+// and calc the two deltas, for a 'look at the future behaviour'
+#define simple_interp_store \
+ sb->SB[28] = 0; \
+ sb->SB[29] = sb->SB[30]; \
+ sb->SB[30] = sb->SB[31]; \
+ sb->SB[31] = fa; \
+ sb->SB[32] = 1
+
+#define simple_interp_get \
+ if(sinc<0x10000) /* -> upsampling? */ \
+ InterpolateUp(sb, sinc); /* --> interpolate up */ \
+ else InterpolateDown(sb, sinc); /* --> else down */ \
+ dst[ns] = sb->SB[29]
+
+make_do_samples(do_samples_nointerp, , fa = sb->SB[29],
+ , dst[ns] = fa, sb->SB[29] = fa)
+make_do_samples(do_samples_simple, , ,
+ simple_interp_store, simple_interp_get, )
+make_do_samples(do_samples_gauss, , ,
+ StoreInterpolationGaussCubic(sb, fa),
+ dst[ns] = GetInterpolationGauss(sb, *spos), )
+make_do_samples(do_samples_cubic, , ,
+ StoreInterpolationGaussCubic(sb, fa),
+ dst[ns] = GetInterpolationCubic(sb, *spos), )
+make_do_samples(do_samples_fmod,
+ sinc = FModChangeFrequency(spu.s_chan[ch].iRawPitch, ns, iFMod), ,
+ StoreInterpolationGaussCubic(sb, fa),
+ dst[ns] = GetInterpolationGauss(sb, *spos), )
+
+INLINE int do_samples_adpcm(int *dst,
+ int (*decode_f)(void *context, int ch, int *SB), void *ctx,
+ int ch, int ns_to, int fmod, sample_buf *sb, int sinc, int *spos, int *sbpos)
+{
+ int interp = spu.interpolation;
+ if (fmod == 1)
+ return do_samples_fmod(dst, decode_f, ctx, ch, ns_to, sb, sinc, spos, sbpos);
+ if (fmod)
+ interp = 2;
+ switch (interp) {
+ case 0:
+ return do_samples_nointerp(dst, decode_f, ctx, ch, ns_to, sb, sinc, spos, sbpos);
+ case 1:
+ return do_samples_simple (dst, decode_f, ctx, ch, ns_to, sb, sinc, spos, sbpos);
+ default:
+ return do_samples_gauss (dst, decode_f, ctx, ch, ns_to, sb, sinc, spos, sbpos);
+ case 3:
+ return do_samples_cubic (dst, decode_f, ctx, ch, ns_to, sb, sinc, spos, sbpos);