11 MSDOS: BC(y) Watcom(y) DJGPP(?)
\r
16 (n) - no (not possible or not useful)
\r
17 (?) - may be possible, but not tested
\r
35 ULONG nSamplesPerSec;
\r
36 ULONG nAvgBytesPerSec;
\r
38 UWORD nFormatSpecific;
\r
43 SAMPLE *MW_LoadWavFP(FILE *fp)
\r
51 /* read wav header */
\r
53 _mm_read_str(wh.rID,4,fp);
\r
54 wh.rLen=_mm_read_I_ULONG(fp);
\r
55 _mm_read_str(wh.wID,4,fp);
\r
56 _mm_read_str(wh.fID,4,fp);
\r
57 wh.fLen=_mm_read_I_ULONG(fp);
\r
58 wh.wFormatTag=_mm_read_I_UWORD(fp);
\r
59 wh.nChannels=_mm_read_I_UWORD(fp);
\r
60 wh.nSamplesPerSec=_mm_read_I_ULONG(fp);
\r
61 wh.nAvgBytesPerSec=_mm_read_I_ULONG(fp);
\r
62 wh.nBlockAlign=_mm_read_I_UWORD(fp);
\r
63 wh.nFormatSpecific=_mm_read_I_UWORD(fp);
\r
68 memcmp(wh.rID,"RIFF",4) ||
\r
69 memcmp(wh.wID,"WAVE",4) ||
\r
70 memcmp(wh.fID,"fmt ",4) ){
\r
71 myerr="Not a WAV file";
\r
75 /* skip other crap */
\r
77 _mm_fseek(fp,wh.fLen-16,SEEK_CUR);
\r
78 _mm_read_str(dID,4,fp);
\r
80 if( memcmp(dID,"data",4) ){
\r
81 myerr="Not a WAV file";
\r
86 myerr="Only mono WAV's are supported";
\r
90 /* printf("wFormatTag: %x\n",wh.wFormatTag); */
\r
91 /* printf("blockalign: %x\n",wh.nBlockAlign); */
\r
92 /* prinff("nFormatSpc: %x\n",wh.nFormatSpecific); */
\r
94 if((si=(SAMPLE *)calloc(1,sizeof(SAMPLE)))==NULL){
\r
95 myerr="Out of memory";
\r
102 si->length=_mm_read_I_ULONG(fp);
\r
104 if(wh.nBlockAlign==2){
\r
105 si->flags=SF_16BITS|SF_SIGNED;
\r
109 si->handle=MD_SampleLoad(fp,si->length,0,si->length,si->flags);
\r
120 SAMPLE *MW_LoadWavFN(char *filename)
\r
125 if((fp=fopen(filename,"rb"))==NULL){
\r
126 myerr="Couldn't open wav file";
\r
130 si=MW_LoadWavFP(fp);
\r
137 void MW_FreeWav(SAMPLE *si)
\r
140 MD_SampleUnLoad(si->handle);
\r