comparison src/timidity/libtimidity/instrum.c @ 1978:fa9f85cebade

s/vfs_/aud_vfs_/g
author William Pitcock <nenolod@atheme.org>
date Sun, 07 Oct 2007 00:25:33 -0500
parents 6acf1bda788b
children
comparison
equal deleted inserted replaced
1977:5a6b60ceaa0f 1978:fa9f85cebade
200 DEBUG_MSG("Loading instrument %s\n", tmp); 200 DEBUG_MSG("Loading instrument %s\n", tmp);
201 201
202 /* Read some headers and do cursory sanity checks. There are loads 202 /* Read some headers and do cursory sanity checks. There are loads
203 of magic offsets. This could be rewritten... */ 203 of magic offsets. This could be rewritten... */
204 204
205 if ((239 != vfs_fread(tmp, 1, 239, fp)) || 205 if ((239 != aud_vfs_fread(tmp, 1, 239, fp)) ||
206 (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && 206 (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) &&
207 memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the 207 memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the
208 differences are */ 208 differences are */
209 { 209 {
210 DEBUG_MSG("%s: not an instrument\n", name); 210 DEBUG_MSG("%s: not an instrument\n", name);
234 sint32 tmplong; 234 sint32 tmplong;
235 uint16 tmpshort; 235 uint16 tmpshort;
236 uint8 tmpchar; 236 uint8 tmpchar;
237 237
238 #define READ_CHAR(thing) \ 238 #define READ_CHAR(thing) \
239 if (1 != vfs_fread(&tmpchar, 1, 1, fp)) goto fail; \ 239 if (1 != aud_vfs_fread(&tmpchar, 1, 1, fp)) goto fail; \
240 thing = tmpchar; 240 thing = tmpchar;
241 #define READ_SHORT(thing) \ 241 #define READ_SHORT(thing) \
242 if (1 != vfs_fread(&tmpshort, 2, 1, fp)) goto fail; \ 242 if (1 != aud_vfs_fread(&tmpshort, 2, 1, fp)) goto fail; \
243 thing = SWAPLE16(tmpshort); 243 thing = SWAPLE16(tmpshort);
244 #define READ_LONG(thing) \ 244 #define READ_LONG(thing) \
245 if (1 != vfs_fread(&tmplong, 4, 1, fp)) goto fail; \ 245 if (1 != aud_vfs_fread(&tmplong, 4, 1, fp)) goto fail; \
246 thing = SWAPLE32(tmplong); 246 thing = SWAPLE32(tmplong);
247 247
248 vfs_fseek(fp, 7, SEEK_CUR); /* Skip the wave name */ 248 aud_vfs_fseek(fp, 7, SEEK_CUR); /* Skip the wave name */
249 249
250 if (1 != vfs_fread(&fractions, 1, 1, fp)) 250 if (1 != aud_vfs_fread(&fractions, 1, 1, fp))
251 { 251 {
252 fail: 252 fail:
253 DEBUG_MSG("Error reading sample %d\n", i); 253 DEBUG_MSG("Error reading sample %d\n", i);
254 for (j=0; j<i; j++) 254 for (j=0; j<i; j++)
255 free(ip->sample[j].data); 255 free(ip->sample[j].data);
267 READ_LONG(sp->low_freq); 267 READ_LONG(sp->low_freq);
268 READ_LONG(sp->high_freq); 268 READ_LONG(sp->high_freq);
269 READ_LONG(sp->root_freq); 269 READ_LONG(sp->root_freq);
270 sp->low_vel = 0; 270 sp->low_vel = 0;
271 sp->high_vel = 127; 271 sp->high_vel = 127;
272 vfs_fseek(fp, 2, SEEK_CUR); /* Why have a "root frequency" and then 272 aud_vfs_fseek(fp, 2, SEEK_CUR); /* Why have a "root frequency" and then
273 * "tuning"?? */ 273 * "tuning"?? */
274 274
275 READ_CHAR(tmp[0]); 275 READ_CHAR(tmp[0]);
276 276
277 if (panning==-1) 277 if (panning==-1)
278 sp->panning = (tmp[0] * 8 + 4) & 0x7f; 278 sp->panning = (tmp[0] * 8 + 4) & 0x7f;
279 else 279 else
280 sp->panning=(uint8)(panning & 0x7F); 280 sp->panning=(uint8)(panning & 0x7F);
281 281
282 /* envelope, tremolo, and vibrato */ 282 /* envelope, tremolo, and vibrato */
283 if (18 != vfs_fread(tmp, 1, 18, fp)) goto fail; 283 if (18 != aud_vfs_fread(tmp, 1, 18, fp)) goto fail;
284 284
285 if (!tmp[13] || !tmp[14]) 285 if (!tmp[13] || !tmp[14])
286 { 286 {
287 sp->tremolo_sweep_increment= 287 sp->tremolo_sweep_increment=
288 sp->tremolo_phase_increment=sp->tremolo_depth=0; 288 sp->tremolo_phase_increment=sp->tremolo_depth=0;
316 316
317 } 317 }
318 318
319 READ_CHAR(sp->modes); 319 READ_CHAR(sp->modes);
320 320
321 vfs_fseek(fp, 40, SEEK_CUR); /* skip the useless scale frequency, scale 321 aud_vfs_fseek(fp, 40, SEEK_CUR); /* skip the useless scale frequency, scale
322 factor (what's it mean?), and reserved 322 factor (what's it mean?), and reserved
323 space */ 323 space */
324 324
325 /* Mark this as a fixed-pitch instrument if such a deed is desired. */ 325 /* Mark this as a fixed-pitch instrument if such a deed is desired. */
326 if (note_to_use!=-1) 326 if (note_to_use!=-1)
390 convert_envelope_offset(tmp[6+j]); 390 convert_envelope_offset(tmp[6+j]);
391 } 391 }
392 392
393 /* Then read the sample data */ 393 /* Then read the sample data */
394 sp->data = safe_malloc(sp->data_length); 394 sp->data = safe_malloc(sp->data_length);
395 if (1 != vfs_fread(sp->data, sp->data_length, 1, fp)) 395 if (1 != aud_vfs_fread(sp->data, sp->data_length, 1, fp))
396 goto fail; 396 goto fail;
397 397
398 if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ 398 if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */
399 { 399 {
400 sint32 i=sp->data_length; 400 sint32 i=sp->data_length;
505 DEBUG_MSG(" - Stripping tail\n"); 505 DEBUG_MSG(" - Stripping tail\n");
506 sp->data_length = sp->loop_end; 506 sp->data_length = sp->loop_end;
507 } 507 }
508 } 508 }
509 509
510 vfs_fclose(fp); 510 aud_vfs_fclose(fp);
511 return ip; 511 return ip;
512 } 512 }
513 513
514 static int fill_bank(MidSong *song, int dr, int b) 514 static int fill_bank(MidSong *song, int dr, int b)
515 { 515 {