comparison decoders/mod.c @ 120:bd224f22e6b2

Handles sample rate somewhat more robustly.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 08 Oct 2001 01:40:42 +0000
parents 40de367eb59e
children 1df5c106504e
comparison
equal deleted inserted replaced
119:254916e602c6 120:bd224f22e6b2
186 * so this is just for clarity. I haven't experimented with any of 186 * so this is just for clarity. I haven't experimented with any of
187 * the other flags. There are a few which are said to give better 187 * the other flags. There are a few which are said to give better
188 * sound quality. 188 * sound quality.
189 */ 189 */
190 md_mode |= (DMODE_SOFT_MUSIC | DMODE_16BITS); 190 md_mode |= (DMODE_SOFT_MUSIC | DMODE_16BITS);
191 191 md_mixfreq = 0;
192 #if 0
193 /*
194 * SDL_mixer used to set these, but I don't know... is there
195 * something wrong with the defaults? Actually, the only difference
196 * from the defaults is md_reverb, which is usually 6.
197 */
198 md_device = 0; /* Selects sound driver. 0 = autodetect */
199 md_volume = 96; /* Overall sound volume, 0 - 128 */
200 md_musicvolume = 128; /* Module volume, 0 - 128 */
201 md_sndfxvolume = 128; /* Sound effect volume, 0 - 128 */
202 md_pansep = 128; /* Stereo channels separation, 0 - 128 */
203 md_reverb = 0; /* Sound reverbation, 0 - 15 */
204 #endif
205 192
206 BAIL_IF_MACRO(MikMod_Init(""), MikMod_strerror(MikMod_errno), 0); 193 BAIL_IF_MACRO(MikMod_Init(""), MikMod_strerror(MikMod_errno), 0);
207 194
208 return(1); /* success. */ 195 return(1); /* success. */
209 } /* MOD_init */ 196 } /* MOD_init */
210 197
211 198
212 static void MOD_quit(void) 199 static void MOD_quit(void)
213 { 200 {
214 MikMod_Exit(); 201 MikMod_Exit();
202 md_mixfreq = 0;
215 } /* MOD_quit */ 203 } /* MOD_quit */
216 204
217 205
218 static int MOD_open(Sound_Sample *sample, const char *ext) 206 static int MOD_open(Sound_Sample *sample, const char *ext)
219 { 207 {
227 BAIL_IF_MACRO(reader == NULL, ERR_OUT_OF_MEMORY, 0); 215 BAIL_IF_MACRO(reader == NULL, ERR_OUT_OF_MEMORY, 0);
228 m->module = Player_LoadGeneric(reader, 64, 0); 216 m->module = Player_LoadGeneric(reader, 64, 0);
229 _mm_delete_rwops_reader(reader); 217 _mm_delete_rwops_reader(reader);
230 BAIL_IF_MACRO(m->module == NULL, "MOD: Not a module file.", 0); 218 BAIL_IF_MACRO(m->module == NULL, "MOD: Not a module file.", 0);
231 219
232 md_mixfreq = sample->desired.rate; 220 if (md_mixfreq == 0)
221 md_mixfreq = (!sample->desired.rate) ? 44100 : sample->desired.rate;
222
233 sample->actual.channels = 2; 223 sample->actual.channels = 2;
234 sample->actual.rate = md_mixfreq; 224 sample->actual.rate = md_mixfreq;
235 sample->actual.format = AUDIO_S16SYS; 225 sample->actual.format = AUDIO_S16SYS;
236 internal->decoder_private = (void *) m; 226 internal->decoder_private = (void *) m;
237 227