annotate playercode/virtch2.c @ 11:d5cb2cfc8eca

Initial revision
author darius
date Fri, 23 Jan 1998 16:05:11 +0000
parents 5d614bcc4287
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name: VIRTCH2.C
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5 Description:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 All-c sample mixing routines, using a 32 bits mixing buffer, interpolation,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7 and sample smoothing [improves sound quality and removes clicks].
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 Future Additions:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10 Low-Pass filter to remove annoying staticy buzz.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 C Mixer Portability:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14 All Systems -- All compilers.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16 Assembly Mixer Portability:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18 MSDOS: BC(?) Watcom(y) DJGPP(y)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19 Win95: ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20 Os2: ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 Linux: y
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23 (y) - yes
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24 (n) - no (not possible or not useful)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 (?) - may be possible, but not tested
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 */
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29 #include <stddef.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30 #include <string.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31 #include "mikmod.h"
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34 // REVERBERATION : Larger numbers result in shorter reverb duration.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 // Longer reverb durations can cause unwanted static and make the
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36 // reverb sound more like an echo.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38 #define REVERBERATION 28000l
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 // SAMPLING_SHIFT : Specified the shift multiplier which controls by how
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 // much the mixing rate is multiplied while mixing. Higher values
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42 // can improve quality by smoothing the soudn and reducing pops and
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43 // clicks. Note, this is a shift value, so a value of 2 becomes a
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 // mixing-rate multiplier of 4, and a value of 3 = 8, etc.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46 #define SAMPLING_SHIFT 2
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47 #define SAMPLING_FACTOR (SLONG)(1<<SAMPLING_SHIFT)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50 // FRACBITS : the number of bits per integer devoted to the fractional
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51 // part of the number. This value HAS to be changed if the compiler
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 // does not support 64 bit integers. If 32 bit integers are used,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 // FRACBITS _must_ be 9 or smaller.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55 #define FRACBITS 28
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56 #define FRACMASK ((1l<<FRACBITS)-1)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 #define TICKLSIZE 4096
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59 #define TICKWSIZE (TICKLSIZE*2)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 #define TICKBSIZE (TICKWSIZE*2)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 #ifndef MIN
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64 #endif
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 #ifndef MAX
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 #define MAX(a,b) (((a)>(b))?(a):(b))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 #endif
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 typedef struct
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 { UBYTE kick; // =1 -> sample has to be restarted
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73 UBYTE active; // =1 -> sample is playing
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74 UWORD flags; // 16/8 bits looping/one-shot
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75 SWORD handle; // identifies the sample
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 ULONG start; // start index
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 ULONG size; // samplesize
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 ULONG reppos; // loop start
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 ULONG repend; // loop end
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80 ULONG frq; // current frequency
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 UWORD vol; // current volume
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 UWORD pan; // current panning position
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 SDOUBLE current; // current index in the sample
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 SDOUBLE increment; // fixed-point increment value
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 } VINFO;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 static SWORD **Samples;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90 static VINFO *vinf = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 static VINFO *vnf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 static ULONG samplesthatfit;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93 static int vc_memory, vc_softchn;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 static SDOUBLE idxsize,idxlpos,idxlend;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 static SLONG TICKLEFT;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 static SLONG *VC2_TICKBUF = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 static UWORD vc_mode;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 static int bitshift; // Amplification shift (amount to decrease 32 bit mixing buffer by!)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 static SLONG lvolsel, rvolsel; // Volume factor .. range 0-255
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 // Reverb control variables
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103 // ========================
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 static int RVc1, RVc2, RVc3, RVc4, RVc5, RVc6, RVc7, RVc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 static ULONG RVRindex;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 // For Mono or Left Channel
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109 static SLONG *RVbuf1 = NULL, *RVbuf2 = NULL, *RVbuf3 = NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 *RVbuf4 = NULL, *RVbuf5 = NULL, *RVbuf6 = NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 *RVbuf7 = NULL, *RVbuf8 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113 // For Stereo only (Right Channel)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 static SLONG *RVbuf9 = NULL, *RVbuf10 = NULL, *RVbuf11 = NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 *RVbuf12 = NULL, *RVbuf13 = NULL, *RVbuf14 = NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116 *RVbuf15 = NULL, *RVbuf16 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 // ==============================================================
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120 // 16 bit sample mixers!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 static SDOUBLE MixStereoNormal(SWORD *srce, SLONG *dest, SDOUBLE index, SDOUBLE increment, ULONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124 SWORD sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126 for(; todo; todo--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127 { sample = (index & FRACBITS) ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128 (((srce[index >> FRACBITS] * (FRACBITS - (index & FRACBITS))) +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129 (srce[(index >> FRACBITS)+1] * (index & FRACBITS))) / FRACBITS)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130 : srce[index >> FRACBITS];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131 index += increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133 *dest++ += lvolsel * sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134 *dest++ += rvolsel * sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137 return index;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141 static SDOUBLE MixStereoSurround(SWORD *srce, SLONG *dest, SDOUBLE index, SDOUBLE increment, ULONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143 SWORD sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 for(dest--; todo; todo--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 { sample = (index & FRACBITS) ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147 (((srce[index >> FRACBITS] * (FRACBITS - (index & FRACBITS))) +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148 (srce[(index >> FRACBITS)+1] * (index & FRACBITS))) / FRACBITS)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149 : srce[index >> FRACBITS];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150 index += increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 *dest++ += lvolsel * sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153 *dest++ -= lvolsel * sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 return index;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160 static SDOUBLE MixMonoNormal(SWORD *srce, SLONG *dest, SDOUBLE index, SDOUBLE increment, SLONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 SWORD sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164 for(; todo; todo--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 { sample = (index & FRACBITS) ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166 (((srce[index >> FRACBITS] * (FRACBITS - (index & FRACBITS))) +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 (srce[(index >> FRACBITS)+1] * (index & FRACBITS))) / FRACBITS)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
168 : srce[index >> FRACBITS];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
169 index += increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
170
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
171 *dest++ += lvolsel * sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
172 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
173
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
174 return index;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
175 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
176
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
177
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
178 static void (*Mix32to16)(SWORD *dste, SLONG *srce, SLONG count);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
179 static void (*Mix32to8)(SBYTE *dste, SLONG *srce, SLONG count);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
180 static void (*MixReverb)(SLONG *srce, SLONG count);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
181
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
182
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
183 static void MixReverb_Normal(SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
184 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
185 SLONG speedup;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
186 int ReverbPct;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
187 unsigned int loc1, loc2, loc3, loc4,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
188 loc5, loc6, loc7, loc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
189
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
190 ReverbPct = 63 + (md_reverb*4);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
191
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
192 loc1 = RVRindex % RVc1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
193 loc2 = RVRindex % RVc2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
194 loc3 = RVRindex % RVc3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
195 loc4 = RVRindex % RVc4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
196 loc5 = RVRindex % RVc5;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
197 loc6 = RVRindex % RVc6;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
198 loc7 = RVRindex % RVc7;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
199 loc8 = RVRindex % RVc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
200
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
201 for(; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
202 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
203 // Compute the LEFT CHANNEL echo buffers!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
204
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
205 speedup = *srce >> 3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
206
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
207 RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
208 RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
209 RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
210 RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
211 RVbuf5[loc5] = speedup + ((ReverbPct * RVbuf5[loc5]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
212 RVbuf6[loc6] = speedup + ((ReverbPct * RVbuf6[loc6]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
213 RVbuf7[loc7] = speedup + ((ReverbPct * RVbuf7[loc7]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
214 RVbuf8[loc8] = speedup + ((ReverbPct * RVbuf8[loc8]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
215
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
216 // Prepare to compute actual finalized data!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
217
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
218 RVRindex++;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
219 loc1 = RVRindex % RVc1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
220 loc2 = RVRindex % RVc2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
221 loc3 = RVRindex % RVc3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
222 loc4 = RVRindex % RVc4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
223 loc5 = RVRindex % RVc5;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
224 loc6 = RVRindex % RVc6;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
225 loc7 = RVRindex % RVc7;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
226 loc8 = RVRindex % RVc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
227
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
228 // Left Channel!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
229
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
230 *srce++ += (RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4] +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
231 RVbuf5[loc5] - RVbuf6[loc6] + RVbuf7[loc7] - RVbuf8[loc8]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
232 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
233 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
234
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
235
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
236 static void MixReverb_Stereo(SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
237 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
238 SLONG speedup;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
239 int ReverbPct;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
240 unsigned int loc1, loc2, loc3, loc4,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
241 loc5, loc6, loc7, loc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
242
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
243 ReverbPct = 63 + (md_reverb*4);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
244
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
245 loc1 = RVRindex % RVc1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
246 loc2 = RVRindex % RVc2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
247 loc3 = RVRindex % RVc3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
248 loc4 = RVRindex % RVc4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
249 loc5 = RVRindex % RVc5;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
250 loc6 = RVRindex % RVc6;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
251 loc7 = RVRindex % RVc7;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
252 loc8 = RVRindex % RVc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
253
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
254 for(; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
255 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
256 // Compute the LEFT CHANNEL echo buffers!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
257
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
258 speedup = *srce >> 3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
259
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
260 RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
261 RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
262 RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
263 RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
264 RVbuf5[loc5] = speedup + ((ReverbPct * RVbuf5[loc5]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
265 RVbuf6[loc6] = speedup + ((ReverbPct * RVbuf6[loc6]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
266 RVbuf7[loc7] = speedup + ((ReverbPct * RVbuf7[loc7]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
267 RVbuf8[loc8] = speedup + ((ReverbPct * RVbuf8[loc8]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
268
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
269 // Compute the RIGHT CHANNEL echo buffers!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
270
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
271 speedup = srce[1] >> 3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
272
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
273 RVbuf9[loc1] = speedup + ((ReverbPct * RVbuf9[loc1]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
274 RVbuf10[loc2] = speedup + ((ReverbPct * RVbuf11[loc2]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
275 RVbuf11[loc3] = speedup + ((ReverbPct * RVbuf12[loc3]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
276 RVbuf12[loc4] = speedup + ((ReverbPct * RVbuf12[loc4]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
277 RVbuf13[loc5] = speedup + ((ReverbPct * RVbuf13[loc5]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
278 RVbuf14[loc6] = speedup + ((ReverbPct * RVbuf14[loc6]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
279 RVbuf15[loc7] = speedup + ((ReverbPct * RVbuf15[loc7]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
280 RVbuf16[loc8] = speedup + ((ReverbPct * RVbuf16[loc8]) / 128);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
281
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
282 // Prepare to compute actual finalized data!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
283
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
284 RVRindex++;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
285 loc1 = RVRindex % RVc1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
286 loc2 = RVRindex % RVc2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
287 loc3 = RVRindex % RVc3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
288 loc4 = RVRindex % RVc4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
289 loc5 = RVRindex % RVc5;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
290 loc6 = RVRindex % RVc6;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
291 loc7 = RVRindex % RVc7;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
292 loc8 = RVRindex % RVc8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
293
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
294 // Left Channel!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
295
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
296 *srce++ += (RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4] +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
297 RVbuf5[loc5] - RVbuf6[loc6] + RVbuf7[loc7] - RVbuf8[loc8]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
298
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
299 // Right Channel!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
300
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
301 *srce++ += (RVbuf9[loc1] - RVbuf10[loc2] + RVbuf11[loc3] - RVbuf12[loc4] +
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
302 RVbuf13[loc5] - RVbuf14[loc6] + RVbuf15[loc7] - RVbuf16[loc8]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
303 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
304 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
305
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
306
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
307 static void Mix32To16_Normal(SWORD *dste, SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
308 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
309 SLONG x1, x2, tmpx;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
310 int i;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
311
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
312 for(count/=SAMPLING_FACTOR; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
313 { tmpx = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
314
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
315 for(i=SAMPLING_FACTOR/2; i; i--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
316 { x1 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
317 x2 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
318
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
319 x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
320 x2 = (x2 > 32767) ? 32767 : (x2 < -32768) ? -32768 : x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
321
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
322 tmpx += x1 + x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
323 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
324
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
325 *dste++ = tmpx / SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
326 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
327 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
328
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
329
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
330 static void Mix32To16_Stereo(SWORD *dste, SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
331 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
332 SLONG x1, x2, x3, x4, tmpx, tmpy;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
333 int i;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
334
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
335 for(count/=SAMPLING_FACTOR; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
336 { tmpx = tmpy = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
337
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
338 for(i=SAMPLING_FACTOR/2; i; i--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
339 { x1 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
340 x2 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
341 x3 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
342 x4 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
343
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
344 x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
345 x2 = (x2 > 32767) ? 32767 : (x2 < -32768) ? -32768 : x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
346 x3 = (x3 > 32767) ? 32767 : (x3 < -32768) ? -32768 : x3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
347 x4 = (x4 > 32767) ? 32767 : (x4 < -32768) ? -32768 : x4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
348
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
349 tmpx += x1 + x3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
350 tmpy += x2 + x4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
351 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
352
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
353 *dste++ = tmpx / SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
354 *dste++ = tmpy / SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
355 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
356 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
357
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
358
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
359 static void Mix32To8_Normal(SBYTE *dste, SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
360 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
361 int x1, x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
362 int i, tmpx;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
363
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
364 for(count/=SAMPLING_FACTOR; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
365 { tmpx = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
366
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
367 for(i=SAMPLING_FACTOR/2; i; i--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
368 { x1 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
369 x2 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
370
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
371 x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
372 x2 = (x2 > 127) ? 127 : (x2 < -128) ? -128 : x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
373
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
374 tmpx += x1 + x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
375 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
376
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
377 *dste++ = (tmpx / SAMPLING_FACTOR) + 128;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
378 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
379 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
380
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
381
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
382 static void Mix32To8_Stereo(SBYTE *dste, SLONG *srce, SLONG count)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
383 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
384 int x1, x2, x3, x4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
385 int i, tmpx, tmpy;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
386
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
387 for(count/=SAMPLING_FACTOR; count; count--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
388 { tmpx = tmpy = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
389
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
390 for(i=SAMPLING_FACTOR/2; i; i--)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
391 { x1 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
392 x2 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
393 x3 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
394 x4 = *srce++ / bitshift;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
395
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
396 x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
397 x2 = (x2 > 127) ? 127 : (x2 < -128) ? -128 : x2;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
398 x3 = (x3 > 127) ? 127 : (x3 < -128) ? -128 : x3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
399 x4 = (x4 > 127) ? 127 : (x4 < -128) ? -128 : x4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
400
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
401 tmpx += x1 + x3;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
402 tmpy += x2 + x4;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
403 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
404
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
405 *dste++ = (tmpx / SAMPLING_FACTOR) + 128;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
406 *dste++ = (tmpy / SAMPLING_FACTOR) + 128;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
407 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
408 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
409
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
410
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
411 static ULONG samples2bytes(ULONG samples)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
412 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
413 if(vc_mode & DMODE_16BITS) samples <<= 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
414 if(vc_mode & DMODE_STEREO) samples <<= 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
415
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
416 return samples;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
417 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
418
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
419
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
420 static ULONG bytes2samples(ULONG bytes)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
421 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
422 if(vc_mode & DMODE_16BITS) bytes >>= 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
423 if(vc_mode & DMODE_STEREO) bytes >>= 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
424
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
425 return bytes;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
426 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
427
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
428
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
429 static void AddChannel(SLONG *ptr, SLONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
430 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
431 SDOUBLE end;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
432 SLONG done;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
433 SWORD *s;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
434
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
435 while(todo > 0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
436 { // update the 'current' index so the sample loops, or
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
437 // stops playing if it reached the end of the sample
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
438
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
439 if(vnf->flags & SF_REVERSE)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
440 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
441 // The sample is playing in reverse
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
442
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
443 if((vnf->flags & SF_LOOP) && (vnf->current < idxlpos))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
444 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
445 // the sample is looping, and it has
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
446 // reached the loopstart index
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
447
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
448 if(vnf->flags & SF_BIDI)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
449 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
450 // sample is doing bidirectional loops, so 'bounce'
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
451 // the current index against the idxlpos
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
452
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
453 vnf->current = idxlpos + (idxlpos - vnf->current);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
454 vnf->flags &= ~SF_REVERSE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
455 vnf->increment = -vnf->increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
456 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
457 // normal backwards looping, so set the
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
458 // current position to loopend index
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
459
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
460 vnf->current = idxlend - (idxlpos-vnf->current);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
461 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
462 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
463 // the sample is not looping, so check
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
464 // if it reached index 0
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
465
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
466 if(vnf->current < 0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
467 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
468 // playing index reached 0, so stop
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
469 // playing this sample
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
470
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
471 vnf->current = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
472 vnf->active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
473 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
474 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
475 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
476 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
477 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
478 // The sample is playing forward
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
479
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
480 if((vnf->flags & SF_LOOP) && (vnf->current > idxlend))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
481 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
482 // the sample is looping, so check if
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
483 // it reached the loopend index
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
484
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
485 if(vnf->flags & SF_BIDI)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
486 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
487 // sample is doing bidirectional loops, so 'bounce'
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
488 // the current index against the idxlend
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
489
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
490 vnf->flags |= SF_REVERSE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
491 vnf->increment = -vnf->increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
492 vnf->current = idxlend-(vnf->current-idxlend);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
493 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
494 // normal backwards looping, so set the
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
495 // current position to loopend index
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
496
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
497 vnf->current = idxlpos + (vnf->current-idxlend);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
498 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
499 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
500 // sample is not looping, so check
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
501 // if it reached the last position
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
502
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
503 if(vnf->current > idxsize)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
504 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
505 // yes, so stop playing this sample
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
506
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
507 vnf->current = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
508 vnf->active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
509 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
510 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
511 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
512 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
513
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
514 if(!(s=Samples[vnf->handle]))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
515 { vnf->current = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
516 vnf->active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
517 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
518 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
519
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
520 end = (vnf->flags & SF_REVERSE) ?
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
521 (vnf->flags & SF_LOOP) ? idxlpos : 0 :
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
522 (vnf->flags & SF_LOOP) ? idxlend : idxsize;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
523
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
524 done = MIN((end - vnf->current) / vnf->increment + 1, todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
525
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
526 if(!done)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
527 { vnf->active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
528 break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
529 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
530
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
531 if(vnf->vol)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
532 { if(vc_mode & DMODE_STEREO)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
533 if(vnf->pan == PAN_SURROUND && vc_mode&DMODE_SURROUND)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
534 vnf->current = MixStereoSurround(s,ptr,vnf->current,vnf->increment,done);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
535 else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
536 vnf->current = MixStereoNormal(s,ptr,vnf->current,vnf->increment,done);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
537 else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
538 vnf->current = MixMonoNormal(s,ptr,vnf->current,vnf->increment,done);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
539 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
540 todo -= done;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
541 ptr += (vc_mode & DMODE_STEREO) ? (done<<1) : done;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
542 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
543 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
544
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
545
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
546 void VC2_WriteSamples(SBYTE *buf, ULONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
547 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
548 int left, portion = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
549 SBYTE *buffer;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
550 int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
551 int pan, vol;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
552
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
553 todo *= SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
554
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
555 while(todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
556 { if(TICKLEFT==0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
557 { if(vc_mode & DMODE_SOFT_MUSIC) md_player();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
558 TICKLEFT = (md_mixfreq*125l*SAMPLING_FACTOR) / (md_bpm*50l);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
559 TICKLEFT &= ~(SAMPLING_FACTOR-1);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
560 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
561
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
562 left = MIN(TICKLEFT, todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
563
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
564 buffer = buf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
565 TICKLEFT -= left;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
566 todo -= left;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
567
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
568 buf += samples2bytes(left) / SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
569
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
570 while(left)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
571 { portion = MIN(left, samplesthatfit);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
572 memset(VC2_TICKBUF, 0, portion << ((vc_mode & DMODE_STEREO) ? 3 : 2));
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
573
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
574 for(t=0; t<vc_softchn; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
575 { vnf = &vinf[t];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
576
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
577 if(vnf->kick)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
578 { vnf->current = (SDOUBLE)(vnf->start) << FRACBITS;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
579 vnf->kick = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
580 vnf->active = 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
581 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
582
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
583 if(vnf->frq == 0) vnf->active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
584
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
585 if(vnf->active)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
586 { vnf->increment = ((SDOUBLE)(vnf->frq) << (FRACBITS-SAMPLING_SHIFT)) / (SDOUBLE)md_mixfreq;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
587 if(vnf->flags & SF_REVERSE) vnf->increment=-vnf->increment;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
588
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
589 vol = vnf->vol; pan = vnf->pan;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
590
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
591 if((vc_mode & DMODE_STEREO) && (pan!=PAN_SURROUND))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
592 { lvolsel = (vol * (255-pan)) >> 8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
593 rvolsel = (vol * pan) >> 8;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
594 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
595 lvolsel = (vol*256l) / 480;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
596
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
597 idxsize = (vnf->size) ? ((SDOUBLE)(vnf->size) << FRACBITS)-1 : 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
598 idxlend = (vnf->repend) ? ((SDOUBLE)(vnf->repend) << FRACBITS)-1 : 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
599 idxlpos = (SDOUBLE)(vnf->reppos) << FRACBITS;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
600 AddChannel(VC2_TICKBUF, portion);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
601 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
602 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
603
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
604 if(md_reverb) MixReverb(VC2_TICKBUF, portion);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
605
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
606 if(vc_mode & DMODE_16BITS)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
607 Mix32to16((SWORD *) buffer, VC2_TICKBUF, portion);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
608 else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
609 Mix32to8((SBYTE *) buffer, VC2_TICKBUF, portion);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
610
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
611 buffer += samples2bytes(portion) / SAMPLING_FACTOR;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
612 left -= portion;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
613 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
614 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
615 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
616
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
617
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
618 void VC2_SilenceBytes(SBYTE *buf, ULONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
619
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
620 // Fill the buffer with 'todo' bytes of silence (it depends on the mixing
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
621 // mode how the buffer is filled)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
622
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
623 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
624 // clear the buffer to zero (16 bits
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
625 // signed ) or 0x80 (8 bits unsigned)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
626
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
627 if(vc_mode & DMODE_16BITS)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
628 memset(buf,0,todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
629 else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
630 memset(buf,0x80,todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
631 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
632
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
633
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
634 ULONG VC2_WriteBytes(SBYTE *buf, ULONG todo)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
635
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
636 // Writes 'todo' mixed SBYTES (!!) to 'buf'. It returns the number of
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
637 // SBYTES actually written to 'buf' (which is rounded to number of samples
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
638 // that fit into 'todo' bytes).
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
639
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
640 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
641 if(vc_softchn == 0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
642 { VC2_SilenceBytes(buf,todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
643 return todo;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
644 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
645
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
646 todo = bytes2samples(todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
647 VC2_WriteSamples(buf,todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
648
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
649 return samples2bytes(todo);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
650 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
651
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
652
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
653 BOOL VC2_PlayStart(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
654 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
655 if(vc_softchn > 0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
656 { bitshift = vc_softchn + 257;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
657 if(!(vc_mode & DMODE_16BITS))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
658 bitshift *= 256;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
659 if(md_reverb) bitshift++;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
660 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
661
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
662 samplesthatfit = TICKLSIZE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
663 if(vc_mode & DMODE_STEREO) samplesthatfit >>= 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
664 TICKLEFT = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
665
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
666 /* Original Reverb Code!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
667 The stuff I use avoids floating point (below).
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
668
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
669 RVc1 = (SLONG)(500 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
670 RVc2 = (SLONG)(507.8125 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
671 RVc3 = (SLONG)(531.25 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
672 RVc4 = (SLONG)(570.3125 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
673 RVc5 = (SLONG)(625 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
674 RVc6 = (SLONG)(695.3125 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
675 RVc7 = (SLONG)(781.25 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
676 RVc8 = (SLONG)(882.8125 * md_mixfreq) / 11000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
677 ReverbPct = 99 - (md_reverb*2);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
678 */
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
679
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
680 RVc1 = (5000L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
681 RVc2 = (5078L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
682 RVc3 = (5313L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
683 RVc4 = (5703L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
684 RVc5 = (6250L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
685 RVc6 = (6953L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
686 RVc7 = (7813L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
687 RVc8 = (8828L * md_mixfreq) / REVERBERATION;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
688
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
689 if((RVbuf1 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
690 if((RVbuf2 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
691 if((RVbuf3 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
692 if((RVbuf4 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
693 if((RVbuf5 = (SLONG *)_mm_calloc((RVc5+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
694 if((RVbuf6 = (SLONG *)_mm_calloc((RVc6+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
695 if((RVbuf7 = (SLONG *)_mm_calloc((RVc7+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
696 if((RVbuf8 = (SLONG *)_mm_calloc((RVc8+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
697
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
698 if(vc_mode & DMODE_STEREO)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
699 { if((RVbuf9 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
700 if((RVbuf10 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
701 if((RVbuf11 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
702 if((RVbuf12 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
703 if((RVbuf13 = (SLONG *)_mm_calloc((RVc5+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
704 if((RVbuf14 = (SLONG *)_mm_calloc((RVc6+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
705 if((RVbuf15 = (SLONG *)_mm_calloc((RVc7+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
706 if((RVbuf16 = (SLONG *)_mm_calloc((RVc8+1),sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
707 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
708
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
709 RVRindex = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
710 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
711 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
712
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
713
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
714 void VC2_PlayStop(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
715 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
716 if(RVbuf1 != NULL) free(RVbuf1);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
717 if(RVbuf2 != NULL) free(RVbuf2);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
718 if(RVbuf3 != NULL) free(RVbuf3);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
719 if(RVbuf4 != NULL) free(RVbuf4);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
720 if(RVbuf5 != NULL) free(RVbuf5);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
721 if(RVbuf6 != NULL) free(RVbuf6);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
722 if(RVbuf7 != NULL) free(RVbuf7);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
723 if(RVbuf8 != NULL) free(RVbuf8);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
724 if(RVbuf9 != NULL) free(RVbuf9);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
725 if(RVbuf10 != NULL) free(RVbuf10);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
726 if(RVbuf11 != NULL) free(RVbuf11);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
727 if(RVbuf12 != NULL) free(RVbuf12);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
728 if(RVbuf13 != NULL) free(RVbuf13);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
729 if(RVbuf14 != NULL) free(RVbuf14);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
730 if(RVbuf15 != NULL) free(RVbuf15);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
731 if(RVbuf16 != NULL) free(RVbuf16);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
732
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
733 RVbuf1 = NULL; RVbuf2 = NULL; RVbuf3 = NULL; RVbuf4 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
734 RVbuf5 = NULL; RVbuf6 = NULL; RVbuf7 = NULL; RVbuf8 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
735 RVbuf9 = NULL; RVbuf10 = NULL; RVbuf11 = NULL; RVbuf12 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
736 RVbuf13 = NULL; RVbuf14 = NULL; RVbuf15 = NULL; RVbuf16 = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
737 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
738
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
739
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
740 BOOL VC2_Init(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
741 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
742 _mm_errno = MMERR_INITIALIZING_MIXER;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
743 if((Samples = (SWORD **)calloc(MAXSAMPLEHANDLES, sizeof(SWORD *))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
744 if(VC2_TICKBUF==NULL) if((VC2_TICKBUF=(SLONG *)malloc((TICKLSIZE+32) * sizeof(SLONG))) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
745
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
746 if(md_mode & DMODE_STEREO)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
747 { Mix32to16 = Mix32To16_Stereo;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
748 Mix32to8 = Mix32To8_Stereo;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
749 MixReverb = MixReverb_Stereo;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
750 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
751 { Mix32to16 = Mix32To16_Normal;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
752 Mix32to8 = Mix32To8_Normal;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
753 MixReverb = MixReverb_Normal;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
754 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
755
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
756 vc_mode = md_mode;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
757
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
758 _mm_errno = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
759 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
760 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
761
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
762
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
763 void VC2_Exit(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
764
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
765 // Yay, he joys and fruits of C and C++ -
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
766 // Deallocation of arrays!
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
767
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
768 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
769 //if(VC2_TICKBUF!=NULL) free(VC2_TICKBUF);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
770 if(vinf!=NULL) free(vinf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
771 if(Samples!=NULL) free(Samples);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
772
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
773 // VC2_TICKBUF = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
774 vinf = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
775 Samples = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
776 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
777
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
778
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
779 BOOL VC2_SetNumVoices(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
780 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
781 int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
782
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
783 if((vc_softchn = md_softchn) == 0) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
784
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
785 if(vinf!=NULL) free(vinf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
786 if((vinf = _mm_calloc(sizeof(VINFO),vc_softchn)) == NULL) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
787
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
788 for(t=0; t<vc_softchn; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
789 { vinf[t].frq = 10000;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
790 vinf[t].pan = (t & 1) ? 0 : 255;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
791 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
792
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
793 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
794 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
795
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
796
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
797 void VC2_VoiceSetVolume(UBYTE voice, UWORD vol)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
798 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
799 vinf[voice].vol = vol;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
800 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
801
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
802
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
803 void VC2_VoiceSetFrequency(UBYTE voice, ULONG frq)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
804 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
805 vinf[voice].frq = frq;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
806 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
807
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
808
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
809 void VC2_VoiceSetPanning(UBYTE voice, ULONG pan)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
810 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
811 vinf[voice].pan = pan;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
812 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
813
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
814
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
815 void VC2_VoicePlay(UBYTE voice, SWORD handle, ULONG start, ULONG size, ULONG reppos, ULONG repend, UWORD flags)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
816 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
817 vinf[voice].flags = flags;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
818 vinf[voice].handle = handle;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
819 vinf[voice].start = start;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
820 vinf[voice].size = size;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
821 vinf[voice].reppos = reppos;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
822 vinf[voice].repend = repend;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
823 vinf[voice].kick = 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
824 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
825
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
826
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
827 void VC2_VoiceStop(UBYTE voice)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
828 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
829 vinf[voice].active = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
830 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
831
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
832
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
833 BOOL VC2_VoiceStopped(UBYTE voice)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
834 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
835 return(vinf[voice].active==0);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
836 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
837
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
838
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
839 void VC2_VoiceReleaseSustain(UBYTE voice)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
840 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
841
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
842 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
843
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
844
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
845 SLONG VC2_VoiceGetPosition(UBYTE voice)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
846 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
847 return(vinf[voice].current>>FRACBITS);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
848 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
849
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
850
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
851 /**************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
852 ***************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
853 ***************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
854 **************************************************/
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
855
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
856
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
857 void VC2_SampleUnload(SWORD handle)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
858 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
859 void *sampleadr = Samples[handle];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
860
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
861 free(sampleadr);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
862 Samples[handle] = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
863 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
864
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
865
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
866 SWORD VC2_SampleLoad(SAMPLOAD *sload, int type, FILE *fp)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
867 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
868 SAMPLE *s = sload->sample;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
869 int handle;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
870 ULONG t, length,loopstart,loopend;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
871
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
872 if(type==MD_HARDWARE) return -1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
873
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
874 // Find empty slot to put sample address in
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
875 for(handle=0; handle<MAXSAMPLEHANDLES; handle++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
876 if(Samples[handle]==NULL) break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
877
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
878 if(handle==MAXSAMPLEHANDLES)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
879 { _mm_errno = MMERR_OUT_OF_HANDLES;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
880 return -1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
881 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
882
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
883 length = s->length;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
884 loopstart = s->loopstart;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
885 loopend = s->loopend;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
886
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
887 SL_SampleSigned(sload);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
888
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
889 SL_Sample8to16(sload);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
890 if((Samples[handle]=(SWORD *)malloc((length+16)<<1))==NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
891 { _mm_errno = MMERR_SAMPLE_TOO_BIG;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
892 return -1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
893 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
894 // read sample into buffer.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
895 SL_Load(Samples[handle],sload,length);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
896
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
897 // Unclick samples:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
898
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
899 if(s->flags & SF_LOOP)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
900 { if(s->flags & SF_BIDI)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
901 for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][(loopend-t)-1];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
902 else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
903 for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][t+loopstart];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
904 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
905 for(t=0; t<16; t++) Samples[handle][t+length] = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
906
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
907 return handle;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
908 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
909
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
910
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
911 ULONG VC2_SampleSpace(int type)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
912 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
913 return vc_memory;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
914 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
915
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
916
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
917 ULONG VC2_SampleLength(int type, SAMPLE *s)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
918 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
919 return (s->length * ((s->flags & SF_16BITS) ? 2 : 1)) + 16;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
920 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
921
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
922
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
923 /**************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
924 ***************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
925 ***************************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
926 **************************************************/
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
927