annotate playercode/virtch.c @ 13:32f80cd7bfee

General tidy up..
author darius
date Thu, 23 Apr 1998 07:20:19 +0000
parents d14fd386d182
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name: VIRTCH.C
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5 Description:
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 Sample mixing routines, using a 32 bits mixing buffer.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8 Optional features include:
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 (a) 4-step reverb (for 16 bit output only)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10 (b) Interpolation of sample data during mixing
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11 (c) Dolby Surround Sound
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12 (d) Optimized assembly mixers for the Intel platform
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 (e) Optional high-speed or high-quality modes
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15 C Mixer Portability:
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16 All Systems -- All compilers.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18 Assembly Mixer Portability:
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20 MSDOS: BC(?) Watcom(y) DJGPP(y)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 Win95: ?
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22 Os2: ?
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23 Linux: y
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 (y) - yes
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26 (n) - no (not possible or not useful)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 (?) - may be possible, but not tested
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29 */
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31 #include <stddef.h>
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32 #include <string.h>
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33 #include "mikmod.h"
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 // REVERBERATION : Larger numbers result in shorter reverb duration.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36 #define REVERBERATION 110000l
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39 #ifdef __GNUC__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 #define __cdecl
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43 #ifdef __WATCOMC__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 #define inline
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48 // for PC-assembly mixing
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49 // ======================
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50 //
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51 // Uncomment both lines below for assembly mixing under WATCOM or GCC for
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 // Linux.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 // Note that there is no 16 bit mixers for assembly yet (C only), so
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54 // defining __ASSEMBLY__ if not defining __FASTMIXER__ will lead to compiler
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55 // errors.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 #define __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 //#define __ASSEMBLY__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 #define FRACBITS 11
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61 #define FRACMASK ((1l<<FRACBITS)-1)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63 #define TICKLSIZE 3600
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64 #define TICKWSIZE (TICKLSIZE*2)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 #define TICKBSIZE (TICKWSIZE*2)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 #ifndef MIN
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 #ifndef MAX
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 #define MAX(a,b) (((a)>(b))?(a):(b))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 typedef struct
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 { BOOL active;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 UWORD infmt;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 UWORD flags;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 UBYTE *buffer;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 UWORD *buffer;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 ULONG size;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86 ULONG speed;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87 ULONG speedfactor;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 SLONG current;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89 SLONG increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90 SLONG writepos;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 } VSTREAM;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 typedef struct
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 { UBYTE kick; // =1 -> sample has to be restarted
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 UBYTE active; // =1 -> sample is playing
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 UWORD flags; // 16/8 bits looping/one-shot
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 SWORD handle; // identifies the sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 ULONG start; // start index
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100 ULONG size; // samplesize
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101 ULONG reppos; // loop start
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 ULONG repend; // loop end
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103 ULONG frq; // current frequency
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104 UWORD vol; // current volume
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 UWORD pan; // current panning position
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 SLONG current; // current index in the sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 SLONG increment; // fixed-point increment value
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 } VINFO;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112 static SBYTE **Samples;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 static SWORD **Samples;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117 // Volume table for 8 bit sample mixing
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 static SLONG **voltab;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 static VINFO *vinf = NULL, *vnf;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123 static VSTREAM vstream;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124 static ULONG samplesthatfit;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125 static BOOL vc_stream = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126 static int vc_memory, vc_softchn;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127 static SLONG idxsize,idxlpos,idxlend;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128 static SLONG TICKLEFT, *VC_TICKBUF = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129 static UWORD vc_mode;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132 // Reverb control variables
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133 // ========================
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135 static int RVc1, RVc2, RVc3, RVc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136 static ULONG RVRindex;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139 // For Mono or Left Channel
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141 static SLONG *RVbuf1 = NULL, *RVbuf2 = NULL, *RVbuf3 = NULL,
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142 *RVbuf4 = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144 // For Stereo only (Right Channel)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 // Values start at 9 to leave room for expanding this to 8-step
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 // reverb in the future.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148 static SLONG *RVbuf9 = NULL, *RVbuf10 = NULL, *RVbuf11 = NULL,
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149 *RVbuf12 = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 int bitshift; // Amplification shift (amount to decrease 32 bit mixing buffer by!)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155 SLONG *lvoltab, *rvoltab; // Volume Table values for use by 8 bit mixers
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 static SLONG lvolsel, rvolsel; // Volume Selectors for 16 bit mixers.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 // Define external Assembly Language Prototypes
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163 // ============================================
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 #ifdef __ASSEMBLY__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 #ifdef __cplusplus
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
168 extern "C" {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
169 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
170
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
171 #ifdef __GNUC__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
172 #define __cdecl
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
173 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
174
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
175 void __cdecl AsmStereoNormal(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
176 void __cdecl AsmStereoSurround(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
177 void __cdecl AsmMonoNormal(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
178
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
179 #ifdef __cplusplus
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
180 };
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
181 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
182
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
183 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
184
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
185 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
186
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
187 // ==============================================================
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
188 // 8 bit sample mixers!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
189
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
190 static SLONG MixStereoNormal(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
191 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
192 UBYTE sample1, sample2, sample3, sample4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
193 int remain;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
194
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
195 remain = todo & 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
196
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
197 for(todo>>=2; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
198 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
199 sample1 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
200 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
201 sample2 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
202 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
203 sample3 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
204 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
205 sample4 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
206 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
207
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
208 *dest++ += lvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
209 *dest++ += rvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
210 *dest++ += lvoltab[sample2];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
211 *dest++ += rvoltab[sample2];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
212 *dest++ += lvoltab[sample3];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
213 *dest++ += rvoltab[sample3];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
214 *dest++ += lvoltab[sample4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
215 *dest++ += rvoltab[sample4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
216 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
217
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
218 for(; remain--; )
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
219 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
220 sample1 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
221 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
222 *dest++ += lvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
223 *dest++ += rvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
224 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
225
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
226 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
227 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
228
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
229
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
230 static SLONG MixStereoSurround(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
231 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
232 SLONG sample1, sample2, sample3, sample4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
233 int remain;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
234
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
235 remain = todo & 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
236
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
237 for(todo>>=2; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
238 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
239 sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
240 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
241 sample2 = lvoltab[(UBYTE)srce[index >> FRACBITS]];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
242 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
243 sample3 = lvoltab[(UBYTE)srce[index >> FRACBITS]];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
244 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
245 sample4 = lvoltab[(UBYTE)srce[index >> FRACBITS]];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
246 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
247
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
248 *dest++ += sample1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
249 *dest++ -= sample1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
250 *dest++ += sample2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
251 *dest++ -= sample2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
252 *dest++ += sample3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
253 *dest++ -= sample3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
254 *dest++ += sample4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
255 *dest++ -= sample4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
256 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
257
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
258 for(; remain--; )
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
259 { sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
260 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
261 *dest++ += sample1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
262 *dest++ -= sample1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
263 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
264
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
265 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
266 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
267
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
268
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
269 static SLONG MixMonoNormal(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
270 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
271 UBYTE sample1, sample2, sample3, sample4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
272 int remain;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
273
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
274 remain = todo & 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
275
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
276 for(todo>>=2; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
277 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
278 sample1 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
279 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
280 sample2 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
281 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
282 sample3 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
283 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
284 sample4 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
285 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
286
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
287 *dest++ += lvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
288 *dest++ += lvoltab[sample2];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
289 *dest++ += lvoltab[sample3];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
290 *dest++ += lvoltab[sample4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
291 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
292
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
293 for(; remain--;)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
294 { sample1 = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
295 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
296 *dest++ -= lvoltab[sample1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
297 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
298
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
299 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
300 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
301
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
302 #else // not __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
303
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
304 // ==============================================================
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
305 // 16 bit sample mixers!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
306
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
307 static SLONG MixStereoNormal(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
308 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
309 SWORD sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
310
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
311 for(; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
312 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
313 sample = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
314 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
315
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
316 *dest++ += lvolsel * sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
317 *dest++ += rvolsel * sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
318 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
319
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
320 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
321 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
322
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
323
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
324 static SLONG MixStereoSurround(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
325 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
326 SWORD sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
327
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
328 for (; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
329 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
330 sample = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
331 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
332
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
333 *dest++ += lvolsel * sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
334 *dest++ -= lvolsel * sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
335 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
336
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
337 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
338 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
339
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
340
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
341 static SLONG MixMonoNormal(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
342 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
343 SWORD sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
344
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
345 for(; todo; todo--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
346 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
347 sample = srce[index >> FRACBITS];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
348 index += increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
349
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
350 *dest++ += lvolsel * sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
351 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
352
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
353 return index;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
354 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
355
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
356 #endif // __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
357 #endif // __ASSEMBLY__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
358
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
359 static void (*MixReverb16)(SLONG *srce, SLONG count);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
360
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
361 static void MixReverb16_Normal(SLONG *srce, SLONG count)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
362 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
363 unsigned int speedup;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
364 int ReverbPct;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
365 unsigned int loc1, loc2, loc3, loc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
366
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
367 ReverbPct = 63 + (md_reverb*4);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
368
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
369 loc1 = RVRindex % RVc1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
370 loc2 = RVRindex % RVc2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
371 loc3 = RVRindex % RVc3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
372 loc4 = RVRindex % RVc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
373
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
374 for(; count; count--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
375 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
376 // Compute the LEFT CHANNEL echo buffers!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
377
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
378 speedup = *srce >> 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
379
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
380 RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
381 RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
382 RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
383 RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
384
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
385 // Prepare to compute actual finalized data!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
386
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
387 RVRindex++;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
388 loc1 = RVRindex % RVc1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
389 loc2 = RVRindex % RVc2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
390 loc3 = RVRindex % RVc3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
391 loc4 = RVRindex % RVc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
392
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
393 // Left Channel!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
394
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
395 *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
396 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
397 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
398
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
399
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
400 static void MixReverb16_Stereo(SLONG *srce, SLONG count)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
401 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
402 unsigned int speedup;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
403 int ReverbPct;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
404 unsigned int loc1, loc2, loc3, loc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
405
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
406 ReverbPct = 63 + (md_reverb*4);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
407
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
408 loc1 = RVRindex % RVc1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
409 loc2 = RVRindex % RVc2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
410 loc3 = RVRindex % RVc3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
411 loc4 = RVRindex % RVc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
412
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
413 for(; count; count--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
414 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
415 // Compute the LEFT CHANNEL echo buffers!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
416
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
417 speedup = *srce >> 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
418
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
419 RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
420 RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
421 RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
422 RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
423
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
424 // Compute the RIGHT CHANNEL echo buffers!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
425
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
426 speedup = srce[1] >> 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
427
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
428 RVbuf9[loc1] = speedup + ((ReverbPct * RVbuf9[loc1]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
429 RVbuf10[loc2] = speedup + ((ReverbPct * RVbuf11[loc2]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
430 RVbuf11[loc3] = speedup + ((ReverbPct * RVbuf12[loc3]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
431 RVbuf12[loc4] = speedup + ((ReverbPct * RVbuf12[loc4]) / 128l);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
432
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
433 // Prepare to compute actual finalized data!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
434
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
435 RVRindex++;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
436 loc1 = RVRindex % RVc1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
437 loc2 = RVRindex % RVc2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
438 loc3 = RVRindex % RVc3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
439 loc4 = RVRindex % RVc4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
440
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
441 // Left Channel!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
442
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
443 *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
444
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
445 // Right Channel!
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
446
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
447 *srce++ += RVbuf9[loc1] - RVbuf10[loc2] + RVbuf11[loc3] - RVbuf12[loc4];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
448 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
449 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
450
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
451
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
452 static void Mix32To16(SWORD *dste, SLONG *srce, SLONG count)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
453 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
454 SLONG x1, x2, x3, x4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
455 int remain;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
456
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
457 remain = count & 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
458
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
459 for(count>>=2; count; count--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
460 { x1 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
461 x2 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
462 x3 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
463 x4 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
464 x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
465 x2 = (x2 > 32767) ? 32767 : (x2 < -32768) ? -32768 : x2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
466 x3 = (x3 > 32767) ? 32767 : (x3 < -32768) ? -32768 : x3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
467 x4 = (x4 > 32767) ? 32767 : (x4 < -32768) ? -32768 : x4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
468 *dste++ = x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
469 *dste++ = x2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
470 *dste++ = x3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
471 *dste++ = x4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
472 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
473
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
474 for(; remain; remain--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
475 { x1 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
476 x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
477 *dste++ = x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
478 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
479 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
480
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
481
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
482 static void Mix32To8(SBYTE *dste, SLONG *srce, SLONG count)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
483 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
484 int x1, x2, x3, x4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
485 int remain;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
486
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
487 remain = count & 3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
488
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
489 for(count>>=2; count; count--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
490 { x1 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
491 x2 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
492 x3 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
493 x4 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
494
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
495 x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
496 x2 = (x2 > 127) ? 127 : (x2 < -128) ? -128 : x2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
497 x3 = (x3 > 127) ? 127 : (x3 < -128) ? -128 : x3;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
498 x4 = (x4 > 127) ? 127 : (x4 < -128) ? -128 : x4;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
499
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
500 *dste++ = x1 + 128;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
501 *dste++ = x2 + 128;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
502 *dste++ = x3 + 128;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
503 *dste++ = x4 + 128;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
504 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
505
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
506 for(; remain; remain--)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
507 { x1 = *srce++ >> bitshift;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
508 x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
509 *dste++ = x1 + 128;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
510 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
511 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
512
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
513
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
514 static ULONG samples2bytes(ULONG samples)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
515 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
516 if(vc_mode & DMODE_16BITS) samples <<= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
517 if(vc_mode & DMODE_STEREO) samples <<= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
518 return samples;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
519 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
520
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
521
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
522 static ULONG bytes2samples(ULONG bytes)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
523 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
524 if(vc_mode & DMODE_16BITS) bytes >>= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
525 if(vc_mode & DMODE_STEREO) bytes >>= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
526 return bytes;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
527 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
528
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
529
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
530 static void AddChannel(SLONG *ptr, SLONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
531 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
532 SLONG end, done;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
533 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
534 SBYTE *s;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
535 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
536 SWORD *s;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
537 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
538
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
539 while(todo > 0)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
540 { // update the 'current' index so the sample loops, or
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
541 // stops playing if it reached the end of the sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
542
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
543 if(vnf->flags & SF_REVERSE)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
544 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
545 // The sample is playing in reverse
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
546
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
547 if((vnf->flags & SF_LOOP) && (vnf->current < idxlpos))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
548 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
549 // the sample is looping, and it has
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
550 // reached the loopstart index
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
551
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
552 if(vnf->flags & SF_BIDI)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
553 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
554 // sample is doing bidirectional loops, so 'bounce'
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
555 // the current index against the idxlpos
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
556
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
557 vnf->current = idxlpos+(idxlpos-vnf->current);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
558 vnf->flags &=~SF_REVERSE;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
559 vnf->increment =-vnf->increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
560 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
561 // normal backwards looping, so set the
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
562 // current position to loopend index
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
563
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
564 vnf->current = idxlend-(idxlpos-vnf->current);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
565 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
566 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
567 // the sample is not looping, so check
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
568 // if it reached index 0
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
569
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
570 if(vnf->current < 0)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
571 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
572 // playing index reached 0, so stop
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
573 // playing this sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
574
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
575 vnf->current = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
576 vnf->active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
577 break;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
578 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
579 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
580 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
581 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
582 // The sample is playing forward
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
583
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
584 if((vnf->flags & SF_LOOP) && (vnf->current > idxlend))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
585 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
586 // the sample is looping, so check if
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
587 // it reached the loopend index
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
588
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
589 if(vnf->flags & SF_BIDI)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
590 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
591 // sample is doing bidirectional loops, so 'bounce'
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
592 // the current index against the idxlend
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
593
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
594 vnf->flags |=SF_REVERSE;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
595 vnf->increment =-vnf->increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
596 vnf->current =idxlend-(vnf->current-idxlend);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
597 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
598 // normal backwards looping, so set the
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
599 // current position to loopend index
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
600
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
601 vnf->current = idxlpos + (vnf->current-idxlend);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
602 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
603 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
604 // sample is not looping, so check
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
605 // if it reached the last position
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
606
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
607 if(vnf->current > idxsize)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
608 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
609 // yes, so stop playing this sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
610
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
611 vnf->current = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
612 vnf->active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
613 break;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
614 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
615 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
616 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
617
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
618 if(!(s=Samples[vnf->handle]))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
619 { vnf->current = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
620 vnf->active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
621 break;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
622 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
623
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
624 end = (vnf->flags & SF_REVERSE) ?
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
625 (vnf->flags & SF_LOOP) ? idxlpos : 0 :
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
626 (vnf->flags & SF_LOOP) ? idxlend : idxsize;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
627
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
628 done = MIN((end - vnf->current) / vnf->increment + 1, todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
629
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
630 if(!done)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
631 { vnf->active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
632 break;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
633 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
634
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
635 if(vnf->vol)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
636 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
637 #ifdef __ASSEMBLY__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
638 if(vc_mode & DMODE_STEREO)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
639 if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
640 AsmStereoSurround(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
641 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
642 AsmStereoNormal(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
643 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
644 AsmMonoNormal(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
645 vnf->current += (vnf->increment*done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
646 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
647 if(vc_mode & DMODE_STEREO)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
648 if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
649 vnf->current = MixStereoSurround(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
650 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
651 vnf->current = MixStereoNormal(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
652 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
653 vnf->current = MixMonoNormal(s,ptr,vnf->current,vnf->increment,done);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
654 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
655 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
656 todo -= done;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
657 ptr += (vc_mode & DMODE_STEREO) ? (done<<1) : done;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
658 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
659 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
660
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
661
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
662 void VC_WriteSamples(SBYTE *buf, ULONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
663 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
664 int left, portion = 0, count;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
665 SBYTE *buffer, *samplebuf;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
666 int t;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
667 int pan, vol;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
668 int sampletodo;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
669
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
670 samplebuf = buf;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
671 sampletodo = todo;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
672
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
673 while(todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
674 { if(TICKLEFT==0)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
675 { if(vc_mode & DMODE_SOFT_MUSIC) md_player();
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
676 TICKLEFT = (md_mixfreq*125l) / (md_bpm*50L);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
677 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
678
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
679 left = MIN(TICKLEFT, todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
680
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
681 buffer = buf;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
682 TICKLEFT -= left;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
683 todo -= left;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
684
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
685 buf += samples2bytes(left);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
686
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
687 while(left)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
688 { portion = MIN(left, samplesthatfit);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
689 count = (vc_mode & DMODE_STEREO) ? (portion<<1) : portion;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
690
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
691 memset(VC_TICKBUF, 0, count<<2);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
692
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
693 for(t=0; t<vc_softchn; t++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
694 { vnf = &vinf[t];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
695
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
696 if(vnf->kick)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
697 { vnf->current = vnf->start << FRACBITS;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
698 vnf->kick = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
699 vnf->active = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
700 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
701
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
702 if(vnf->frq == 0) vnf->active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
703
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
704 if(vnf->active)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
705 { vnf->increment = (vnf->frq<<FRACBITS) / md_mixfreq;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
706 if(vnf->flags & SF_REVERSE) vnf->increment=-vnf->increment;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
707
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
708 vol = vnf->vol; pan = vnf->pan;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
709
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
710 if(vc_mode & DMODE_STEREO)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
711 { if(pan != PAN_SURROUND)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
712 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
713 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
714 lvoltab = voltab[(vol * (255-pan)) / 1024];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
715 rvoltab = voltab[(vol * pan) / 1024];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
716 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
717 lvolsel = (vol * (255-pan)) >> 8;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
718 rvolsel = (vol * pan) >> 8;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
719 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
720 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
721 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
722 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
723 lvoltab = voltab[(vol+1)>>3];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
724 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
725 lvolsel = vol/2;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
726 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
727 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
728 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
729 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
730 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
731 lvoltab = voltab[(vol+1)>>2];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
732 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
733 lvolsel = vol;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
734 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
735 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
736 idxsize = (vnf->size) ? (vnf->size << FRACBITS)-1 : 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
737 idxlend = (vnf->repend) ? (vnf->repend << FRACBITS)-1 : 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
738 idxlpos = vnf->reppos << FRACBITS;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
739 AddChannel(VC_TICKBUF, portion);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
740 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
741 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
742
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
743 if(md_reverb) MixReverb16(VC_TICKBUF, portion);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
744
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
745 if(vc_mode & DMODE_16BITS)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
746 Mix32To16((SWORD *) buffer, VC_TICKBUF, count);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
747 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
748 Mix32To8((SBYTE *) buffer, VC_TICKBUF, count);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
749
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
750 buffer += samples2bytes(portion);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
751 left -= portion;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
752 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
753 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
754 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
755
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
756
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
757 void VC_SilenceBytes(SBYTE *buf, ULONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
758
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
759 // Fill the buffer with 'todo' bytes of silence (it depends on the mixing
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
760 // mode how the buffer is filled)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
761
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
762 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
763 // clear the buffer to zero (16 bits
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
764 // signed ) or 0x80 (8 bits unsigned)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
765
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
766 if(vc_mode & DMODE_16BITS)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
767 memset(buf,0,todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
768 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
769 memset(buf,0x80,todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
770 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
771
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
772
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
773 ULONG VC_WriteBytes(SBYTE *buf, ULONG todo)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
774
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
775 // Writes 'todo' mixed SBYTES (!!) to 'buf'. It returns the number of
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
776 // SBYTES actually written to 'buf' (which is rounded to number of samples
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
777 // that fit into 'todo' bytes).
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
778
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
779 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
780 if(vc_softchn == 0)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
781 { VC_SilenceBytes(buf,todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
782 return todo;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
783 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
784
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
785 todo = bytes2samples(todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
786 VC_WriteSamples(buf,todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
787
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
788 return samples2bytes(todo);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
789 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
790
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
791
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
792 static UBYTE log2(ULONG x)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
793 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
794 UBYTE result = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
795 while (x>>=1) result++;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
796
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
797 return result;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
798 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
799
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
800
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
801 BOOL VC_PlayStart(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
802 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
803 int t, numchn;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
804
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
805 numchn = md_softchn;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
806 if(vc_stream) numchn++;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
807
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
808 if(numchn > 0)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
809 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
810 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
811 int c;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
812 SLONG maxvol, volmul;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
813
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
814 if(vc_stream) numchn++;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
815 maxvol = 16777216L / (numchn+6);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
816
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
817 for(t=0; t<65; t++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
818 { volmul = (maxvol*t) / 64;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
819 for(c=-128; c<128; c++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
820 voltab[t][(UBYTE)c] = (SLONG)c*volmul;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
821 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
822
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
823 bitshift = 16 - log2(numchn);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
824 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
825 bitshift = (log2(numchn)>>3) + 7;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
826
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
827 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
828
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
829 if (!(vc_mode & DMODE_16BITS))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
830 bitshift += 8;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
831 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
832
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
833 samplesthatfit = TICKLSIZE;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
834 if(vc_mode & DMODE_STEREO) samplesthatfit >>= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
835 TICKLEFT = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
836
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
837
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
838 RVc1 = (5000L * md_mixfreq) / REVERBERATION;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
839 RVc2 = (5078L * md_mixfreq) / REVERBERATION;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
840 RVc3 = (5313L * md_mixfreq) / REVERBERATION;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
841 RVc4 = (5703L * md_mixfreq) / REVERBERATION;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
842
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
843 if((RVbuf1 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
844 if((RVbuf2 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
845 if((RVbuf3 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
846 if((RVbuf4 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
847
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
848 if(vc_mode & DMODE_STEREO)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
849 { if((RVbuf9 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
850 if((RVbuf10 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
851 if((RVbuf11 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
852 if((RVbuf12 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
853 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
854
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
855 RVRindex = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
856
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
857 return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
858 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
859
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
860
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
861 void VC_PlayStop(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
862 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
863 if(RVbuf1 != NULL) free(RVbuf1);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
864 if(RVbuf2 != NULL) free(RVbuf2);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
865 if(RVbuf3 != NULL) free(RVbuf3);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
866 if(RVbuf4 != NULL) free(RVbuf4);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
867 if(RVbuf9 != NULL) free(RVbuf9);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
868 if(RVbuf10 != NULL) free(RVbuf10);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
869 if(RVbuf11 != NULL) free(RVbuf11);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
870 if(RVbuf12 != NULL) free(RVbuf12);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
871
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
872 RVbuf1 = NULL; RVbuf2 = NULL; RVbuf3 = NULL; RVbuf4 = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
873 RVbuf9 = NULL; RVbuf10 = NULL; RVbuf11 = NULL; RVbuf12 = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
874 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
875
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
876
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
877 BOOL VC_Init(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
878 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
879
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
880 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
881 int t;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
882
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
883 _mm_errno = MMERR_INITIALIZING_MIXER;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
884 if((voltab = (SLONG **)calloc(65,sizeof(SLONG *))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
885 for(t=0; t<65; t++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
886 if((voltab[t] = (SLONG *)calloc(256,sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
887
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
888 if((Samples = (SBYTE **)calloc(MAXSAMPLEHANDLES, sizeof(SBYTE *))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
889 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
890 _mm_errno = MMERR_INITIALIZING_MIXER;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
891 if((Samples = (SWORD **)calloc(MAXSAMPLEHANDLES, sizeof(SWORD *))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
892 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
893
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
894 if(VC_TICKBUF==NULL) if((VC_TICKBUF=(SLONG *)malloc((TICKLSIZE+32) * sizeof(SLONG))) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
895 if(md_mode & DMODE_INTERP) md_mode &= ~DMODE_INTERP;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
896
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
897 MixReverb16 = (md_mode & DMODE_STEREO) ? MixReverb16_Stereo : MixReverb16_Normal;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
898 vc_mode = md_mode;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
899
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
900
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
901 _mm_errno = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
902 return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
903 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
904
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
905
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
906 void VC_Exit(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
907 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
908 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
909 int t;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
910 if(voltab!=NULL)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
911 { for(t=0; t<65; t++) if(voltab[t]!=NULL) free(voltab[t]);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
912 free(voltab); voltab = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
913 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
914 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
915
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
916 //if(VC_TICKBUF!=NULL) free(VC_TICKBUF);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
917 if(vinf!=NULL) free(vinf);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
918 if(Samples!=NULL) free(Samples);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
919
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
920 //VC_TICKBUF = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
921 vinf = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
922 Samples = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
923 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
924
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
925
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
926 BOOL VC_SetNumVoices(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
927 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
928 int t;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
929
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
930 if((vc_softchn = md_softchn) == 0) return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
931
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
932 if(vinf!=NULL) free(vinf);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
933 if((vinf = _mm_calloc(sizeof(VINFO),vc_softchn)) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
934
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
935 for(t=0; t<vc_softchn; t++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
936 { vinf[t].frq = 10000;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
937 vinf[t].pan = (t&1) ? 0 : 255;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
938 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
939
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
940 return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
941 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
942
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
943
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
944 void VC_VoiceSetVolume(UBYTE voice, UWORD vol)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
945 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
946 vinf[voice].vol = vol;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
947 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
948
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
949
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
950 void VC_VoiceSetFrequency(UBYTE voice, ULONG frq)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
951 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
952 vinf[voice].frq = frq;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
953 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
954
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
955
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
956 void VC_VoiceSetPanning(UBYTE voice, ULONG pan)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
957 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
958 vinf[voice].pan = pan;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
959 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
960
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
961
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
962 void VC_VoicePlay(UBYTE voice, SWORD handle, ULONG start, ULONG size, ULONG reppos, ULONG repend, UWORD flags)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
963 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
964 vinf[voice].flags = flags;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
965 vinf[voice].handle = handle;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
966 vinf[voice].start = start;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
967 vinf[voice].size = size;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
968 vinf[voice].reppos = reppos;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
969 vinf[voice].repend = repend;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
970 vinf[voice].kick = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
971 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
972
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
973
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
974 void VC_VoiceStop(UBYTE voice)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
975 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
976 vinf[voice].active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
977 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
978
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
979
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
980 BOOL VC_VoiceStopped(UBYTE voice)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
981 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
982 return(vinf[voice].active==0);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
983 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
984
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
985
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
986 void VC_VoiceReleaseSustain(UBYTE voice)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
987 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
988
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
989 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
990
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
991
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
992 SLONG VC_VoiceGetPosition(UBYTE voice)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
993 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
994 return(vinf[voice].current>>FRACBITS);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
995 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
996
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
997
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
998 /**************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
999 ***************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1000 ***************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1001 **************************************************/
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1002
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1003
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1004 void VC_SampleUnload(SWORD handle)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1005 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1006 void *sampleadr = Samples[handle];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1007
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1008 free(sampleadr);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1009 Samples[handle] = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1010 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1011
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1012
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1013 SWORD VC_SampleLoad(SAMPLOAD *sload, int type, FILE *fp)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1014 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1015 SAMPLE *s = sload->sample;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1016 int handle;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1017 ULONG t, length,loopstart,loopend;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1018
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1019 if(type==MD_HARDWARE) return -1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1020
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1021 // Find empty slot to put sample address in
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1022 for(handle=0; handle<MAXSAMPLEHANDLES; handle++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1023 if(Samples[handle]==NULL) break;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1024
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1025 if(handle==MAXSAMPLEHANDLES)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1026 { _mm_errno = MMERR_OUT_OF_HANDLES;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1027 return -1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1028 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1029
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1030 length = s->length;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1031 loopstart = s->loopstart;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1032 loopend = s->loopend;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1033
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1034 SL_SampleSigned(sload);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1035
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1036 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1037 SL_Sample16to8(sload);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1038 if((Samples[handle]=(SBYTE *)malloc(length+16))==NULL)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1039 { _mm_errno = MMERR_SAMPLE_TOO_BIG;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1040 return -1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1041 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1042 // read sample into buffer.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1043 SL_Load(Samples[handle],sload,length);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1044 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1045 SL_Sample8to16(sload);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1046 if((Samples[handle]=(SWORD *)malloc((length+16)<<1))==NULL)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1047 { _mm_errno = MMERR_SAMPLE_TOO_BIG;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1048 return -1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1049 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1050 // read sample into buffer.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1051 SL_Load(Samples[handle],sload,length);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1052 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1053
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1054
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1055 // Unclick samples:
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1056
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1057 if(s->flags & SF_LOOP)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1058 { if(s->flags & SF_BIDI)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1059 for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][(loopend-t)-1];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1060 else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1061 for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][t+loopstart];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1062 } else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1063 for(t=0; t<16; t++) Samples[handle][t+length] = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1064
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1065 return handle;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1066 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1067
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1068
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1069 ULONG VC_SampleSpace(int type)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1070 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1071 return vc_memory;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1072 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1073
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1074
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1075 ULONG VC_SampleLength(int type, SAMPLE *s)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1076 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1077 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1078 return s->length + 16;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1079 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1080 return (s->length * ((s->flags&SF_16BITS) ? 2 : 1)) + 16;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1081 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1082 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1083
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1084
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1085 /**************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1086 ***************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1087 ***************************************************
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1088 **************************************************/
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1089
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1090
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1091 ULONG VC_VoiceRealVolume(UBYTE voice)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1092 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1093 ULONG i,s,size;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1094 int k,j;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1095 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1096 SBYTE *smp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1097 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1098 SWORD *smp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1099 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1100 SLONG t;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1101
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1102 t = vinf[voice].current>>FRACBITS;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1103 if(vinf[voice].active==0) return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1104
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1105 s = vinf[voice].handle;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1106 size = vinf[voice].size;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1107
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1108 i=64; t-=64; k=0; j=0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1109 if(i>size) i = size;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1110 if(t<0) t = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1111 if(t+i > size) t = size-i;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1112
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1113 i &= ~1; // make sure it's EVEN.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1114
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1115 smp = &Samples[s][t];
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1116 for(; i; i--, smp++)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1117 { if(k<*smp) k = *smp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1118 if(j>*smp) j = *smp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1119 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1120
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1121 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1122 k = abs(k-j)<<8;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1123 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1124 k = abs(k-j);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1125 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1126
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1127 return k;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1128 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1129
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1130
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1131 BOOL VC_StreamInit(ULONG speed, UWORD flags)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1132
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1133 // flags - Disk Format - SF_STEREO, SF_16BITS, etc.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1134 // speed - speed at which to replay sample
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1135 //
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1136 // Returns - TRUE if init failed
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1137
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1138 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1139 ULONG tmp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1140
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1141 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1142 tmp = stream_bufsize * speed * (((flags & SF_STEREO) && (vc_mode & DMODE_STEREO)) ? 2 : 1);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1143 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1144 tmp = stream_bufsize * speed * (((flags & SF_STEREO) && (vc_mode & DMODE_STEREO)) ? 2 : 1)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1145 * ((flags & SF_16BITS) && (vc_mode & DMODE_16BITS)) ? 2 : 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1146 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1147 if((flags & SF_STEREO) && (vc_mode & DMODE_STEREO)) tmp <<= 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1148
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1149 vstream.size = tmp;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1150 if((vstream.buffer=_mm_calloc(vstream.size,1024)) == NULL) return 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1151
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1152 vstream.speed = speed;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1153 vstream.speedfactor = (md_mixfreq / speed);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1154 if(!((vstream.speedfactor==2) || (vstream.speedfactor==4)))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1155 vstream.speedfactor = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1156
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1157 vstream.infmt = flags;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1158 vstream.flags = flags;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1159 #ifdef __FASTMIXER__
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1160 vstream.flags = flags &= ~SF_16BITS;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1161 #else
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1162 vstream.flags = flags |= SF_16BITS;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1163 #endif
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1164 if(!(vc_mode&DMODE_STEREO)) vstream.flags &= ~SF_STEREO;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1165
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1166 vstream.active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1167 vstream.current = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1168 vstream.increment = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1169
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1170 vc_stream = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1171 VC_PlayStart();
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1172
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1173 return 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1174 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1175
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1176
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1177 void VC_StreamExit(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1178 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1179 vstream.active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1180 if(vstream.buffer != NULL) free(vstream.buffer);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1181 vstream.buffer = NULL;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1182 vc_stream = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1183 VC_PlayStart();
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1184 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1185
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1186
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1187 void VC_StreamSetSpeed(ULONG speed)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1188 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1189 vstream.speed = speed;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1190 vstream.speedfactor = (md_mixfreq/speed);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1191 if(!((vstream.speedfactor==2) || (vstream.speedfactor==4)))
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1192 vstream.speedfactor = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1193 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1194
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1195
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1196 SLONG VC_StreamGetPosition(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1197 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1198 return(vstream.current >> FRACBITS);
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1199 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1200
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1201
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1202 void VC_StreamStart(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1203 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1204 if(vstream.buffer!=NULL) vstream.active = 1;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1205 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1206
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1207
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1208 void VC_StreamStop(void)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1209 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1210 vstream.active = 0;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1211 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1212
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1213
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1214 void VC_StreamCommit(void *sample, ULONG size)
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1215
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1216 // Read 'size' bytes from the specified buffer and commit them to
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1217 // the streaming audio buffer.
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1218
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1219 {
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1220 //ULONG last, curr;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1221 //ULONG todo;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1222
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1223 if(vstream.buffer==NULL) return;
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1224
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1225 }
d14fd386d182 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1226