rem: fseek(Stream,ChunkHdr.Size&1,SEEK_CUR); FileHdr.Size-=(((ChunkHdr.Size+1)&~1)+8); } fclose(Stream); }
add: fseek (fp, ChunkHdr.Size & 1, SEEK_CUR); FileHdr.Size -= (((ChunkHdr.Size + 1) & ~1) + 8); } fclose(fp);
context: void LoadWAVFile (char *file, uint32 *format, void **data, uint32 *size, uint32 *freq, bool *loop){	WAVChunkHdr_Struct ChunkHdr;	WAVFmtExHdr_Struct FmtExHdr;	WAVFileHdr_Struct FileHdr;	WAVSmplHdr_Struct SmplHdr;	WAVFmtHdr_Struct FmtHdr;	FILE *Stream;		*format=decoder_formats.mono16;	*data=NULL;	*size=0;	*freq=22050;	*loop=false;	if (file)	{		Stream=fopen(file,"rb");		if (Stream)		{			fread(&FileHdr,1,sizeof(WAVFileHdr_Struct),Stream);			FileHdr.Size=((FileHdr.Size+1)&~1)-4;			while ((FileHdr.Size!=0)&&(fread(&ChunkHdr,1,sizeof(WAVChunkHdr_Struct),Stream)))			{				if (!memcmp(ChunkHdr.Id,"fmt ",4))				{					fread(&FmtHdr,1,sizeof(WAVFmtHdr_Struct),Stream);					if (FmtHdr.Format==0x0001)					{						*format=(FmtHdr.Channels == 1 ?								(FmtHdr.BitsPerSample == 8 ?									decoder_formats.mono8									: decoder_formats.mono16)								: (FmtHdr.BitsPerSample == 8 ?									decoder_formats.stereo8									: decoder_formats.stereo16)								);						*freq=FmtHdr.SamplesPerSec;						fseek(Stream,ChunkHdr.Size-sizeof(WAVFmtHdr_Struct),SEEK_CUR);					} 					else					{						fread(&FmtExHdr,1,sizeof(WAVFmtExHdr_Struct),Stream);						fseek(Stream,ChunkHdr.Size-sizeof(WAVFmtHdr_Struct)-								sizeof(WAVFmtExHdr_Struct),SEEK_CUR);					}				}				else if (!memcmp(ChunkHdr.Id,"data",4))				{					if (FmtHdr.Format==0x0001)					{						*size=ChunkHdr.Size;						*data=HMalloc(ChunkHdr.Size+31);						if (*data)							fread(*data,FmtHdr.BlockAlign,									ChunkHdr.Size/FmtHdr.BlockAlign,Stream);						memset(((char *)*data)+ChunkHdr.Size,0,31);					}					else if (FmtHdr.Format==0x0011)					{						//IMA ADPCM					}					else if (FmtHdr.Format==0x0055)					{						//MP3 WAVE					}				}				else if (!memcmp(ChunkHdr.Id,"smpl",4))				{					fread(&SmplHdr,1,sizeof(WAVSmplHdr_Struct),Stream);					*loop = (SmplHdr.Loops ? true : false);					fseek(Stream,ChunkHdr.Size-sizeof(WAVSmplHdr_Struct),SEEK_CUR);				}				else					fseek(Stream,ChunkHdr.Size,SEEK_CUR);				fseek(Stream,ChunkHdr.Size&1,SEEK_CUR);				FileHdr.Size-=(((ChunkHdr.Size+1)&~1)+8);			}			fclose(Stream);		}			}}