171 | kis00022 | yav | 1996/08/13 07:59:45 |
前へ
後へ
上へ
|
Re: Tech report fkiswav1.lzh
170へのコメント
失礼,続きでーす.
/* check Microsoft RIFF-WAVE header
* return data offset
* == 0 : Not wav file
* < 0 : Not supported format
*/
int check_wav_header(buf)
unsigned char *buf;
{
int i;
long data_rate;
long data_channel;
unsigned char *p;
long len;
sound_little_endian = 1;
if (strncmp(buf, "RIFF", 4))
return 0; /* Not wav file */
len = get_long(buf+4);
if (strncmp(buf+8, "WAVE", 4))
return 0; /* Not wav file */
p = buf+12;
while (strncmp(p, "fmt ", 4) != 0) {
len = get_long(p+4);
p += 8 + len;
}
len = get_long(p+4);
p += 8;
i = get_short(p);
switch (i) {
case 0x0001: /* WAVE_FORMAT_PCM */
break;
case 0x0000: /* WAVE_FORMAT_UNKNOWN */
case 0x0002: /* WAVE_FORMAT_ADPCM */
case 0x0006: /* WAVE_FORMAT_ALAW */
case 0x0007: /* WAVE_FORMAT_MULAW */
case 0x0010: /* WAVE_FORMAT_OKI_ADPCM */
case 0x0015: /* WAVE_FORMAT_DIGISTD */
case 0x0016: /* WAVE_FORMAT_DIGIFIX */
case 0x0101: /* IBM_FORMAT_MULAW */
case 0x0102: /* IBM_FORMAT_ALAW */
case 0x0103: /* IBM_FORMAT_ADPCM */
default:
if (sound_debug)
fprintf(stderr, "RIFF-WAVE format 0x%04x not supported!\n", i);
return -1; /* Not supported format */
}
data_channel = get_short(p+2);
data_rate = get_long(p+4);
/* long: average bytes/second */
/* short: block align */
i = get_short(p+14); /* bits/sample? */
if (sound_debug)
fprintf(stderr, "RIFF-WAVE %ld-channels, %ldHz, %d-bits/sample\n",
data_channel, data_rate, i);
switch (i) {
case 8:
i = 1; sound_bits = 8; sound_unsigned = 1;
break;
case 16:
i = 2; sound_bits = 16; sound_unsigned = 0;
break;
case 32:
i = 4; sound_bits = 32; sound_unsigned = 0;
break;
default:
if (sound_debug)
fprintf(stderr, "RIFF-WAVE 0x%04x-bits/sample not supported!\n", i);
return -1; /* Not supported format */
}
p += len;
if (strncmp(p, "data", 4)) {
if (sound_debug)
fprintf(stderr, "RIFF-WAVE data lost!\n");
return -1; /* Not supported format */
}
/* number of samples = get_long(p+4) / i */
sound_channels = data_channel;
sound_rate = data_rate;
sound_ulaw_encoded = 0;
p += 8;
if (sound_debug)
fprintf(stderr, "RIFF-WAVE offset %d\n", p - buf);
return p - buf; /* return data offset */
}
というわけで,なぜか "data" が
ないないたいです!? うーむ?謎
それから,最後に ブツッ!とノイズが聞こえるのが多かったと
思うのですが?これもなぞです.
UHD98984@pcvan.or.jp
yav