/*--------------------------------------------------------------------------* Project: Revolution SOUNDFILE dynamic link library File: Wavfile.h Copyright (C)2001-2009 Nintendo All Rights Reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: Wavfile.h,v $ Revision 1.4 2009/03/31 00:16:45 aka Copied from SDK_3_2_DEV_BRANCH. Revision 1.2.40.2 2009/03/31 00:14:43 aka Revised CVS log. Revision 1.2.40.1 2009/03/30 04:39:30 aka Added supporting a wav file with loop information. Cleaned up. Revision 1.2 2006/02/09 06:51:39 aka Changed copyright. *--------------------------------------------------------------------------*/ #ifndef __WAVFILE_H__ #define __WAVFILE_H__ #include "Types.h" #include "chunkname.h" /*--------------------------------------------------------------------------* RIFF chunk names *--------------------------------------------------------------------------*/ #define CHUNK_RIFF chunk_name('R','I','F','F') #define CHUNK_WAVE chunk_name('W','A','V','E') /*--------------------------------------------------------------------------* CHUNK structs *--------------------------------------------------------------------------*/ typedef struct { char chunkId[4]; u32 chunkSize; u16 waveFormatType; u16 channel; u32 samplesPerSec; u32 bytesPerSec; u16 blockSize; u16 bitsPerSample; } FMTCHUNK; typedef struct { char chunkId[4]; u32 chunkSize; } DATACHUNK; typedef struct { char chunkId[4]; u32 chunkSize; char formType[4]; FMTCHUNK fmt; DATACHUNK data; } WAVECHUNK; typedef struct { char chunkId[4]; u32 chunkSize; u32 manufacturer; u32 product; u32 samplePeriod; u32 midiUnityNote; u32 midiPitchFraction; u32 smpteFormat; u32 smpteOffset; u32 sampleLoops; u32 samplerData; } SMPLCHUNK; typedef struct { u32 id; u32 type; u32 start; u32 end; u32 fraction; u32 playCount; } SMPLLOOP; typedef struct { u32 start; u32 end; } LOOPINFO; /*--------------------------------------------------------------------------* Function prototypes *--------------------------------------------------------------------------*/ void wavCreateHeader ( WAVECHUNK *wc, int channels, int samples, int bitsPerSample, int sampleRate, int loopEnd ); void wavWriteHeader ( WAVECHUNK *wc, FILE *outfile ); void wavCreateSmplChunk ( WAVECHUNK *wc, SMPLCHUNK *sc, SMPLLOOP *sl, u32 loopStart, u32 loopEnd ); void wavWriteSmplChunk ( SMPLCHUNK *sc, SMPLLOOP *sl, FILE *outfile ); int wavReadHeader ( WAVECHUNK *wc, LOOPINFO *li, FILE *infile ); u32 wavGetSamples ( WAVECHUNK *wc ); u32 wavGetChannels ( WAVECHUNK *wc ); u32 wavGetBitsPerSample ( WAVECHUNK *wc ); u32 wavGetSampleRate ( WAVECHUNK *wc ); #endif // __WAVFILE_H__