1 /*--------------------------------------------------------------------------* 2 Project: Revolution SOUNDFILE dynamic link library 3 File: Wavfile.h 4 5 Copyright (C)2001-2009 Nintendo All Rights Reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: Wavfile.h,v $ 14 Revision 1.4 2009/03/31 00:16:45 aka 15 Copied from SDK_3_2_DEV_BRANCH. 16 17 Revision 1.2.40.2 2009/03/31 00:14:43 aka 18 Revised CVS log. 19 20 Revision 1.2.40.1 2009/03/30 04:39:30 aka 21 Added supporting a wav file with loop information. 22 Cleaned up. 23 24 Revision 1.2 2006/02/09 06:51:39 aka 25 Changed copyright. 26 27 *--------------------------------------------------------------------------*/ 28 29 #ifndef __WAVFILE_H__ 30 #define __WAVFILE_H__ 31 32 #include "Types.h" 33 #include "chunkname.h" 34 35 36 /*--------------------------------------------------------------------------* 37 RIFF chunk names 38 *--------------------------------------------------------------------------*/ 39 #define CHUNK_RIFF chunk_name('R','I','F','F') 40 #define CHUNK_WAVE chunk_name('W','A','V','E') 41 42 43 /*--------------------------------------------------------------------------* 44 CHUNK structs 45 *--------------------------------------------------------------------------*/ 46 typedef struct 47 { 48 char chunkId[4]; 49 u32 chunkSize; 50 51 u16 waveFormatType; 52 u16 channel; 53 u32 samplesPerSec; 54 u32 bytesPerSec; 55 u16 blockSize; 56 u16 bitsPerSample; 57 58 } FMTCHUNK; 59 60 typedef struct 61 { 62 char chunkId[4]; 63 u32 chunkSize; 64 65 } DATACHUNK; 66 67 typedef struct 68 { 69 char chunkId[4]; 70 u32 chunkSize; 71 72 char formType[4]; 73 FMTCHUNK fmt; 74 DATACHUNK data; 75 76 } WAVECHUNK; 77 78 typedef struct 79 { 80 char chunkId[4]; 81 u32 chunkSize; 82 83 u32 manufacturer; 84 u32 product; 85 u32 samplePeriod; 86 u32 midiUnityNote; 87 u32 midiPitchFraction; 88 u32 smpteFormat; 89 u32 smpteOffset; 90 u32 sampleLoops; 91 u32 samplerData; 92 93 } SMPLCHUNK; 94 95 typedef struct 96 { 97 u32 id; 98 u32 type; 99 u32 start; 100 u32 end; 101 u32 fraction; 102 u32 playCount; 103 104 } SMPLLOOP; 105 106 typedef struct 107 { 108 u32 start; 109 u32 end; 110 111 } LOOPINFO; 112 113 114 /*--------------------------------------------------------------------------* 115 Function prototypes 116 *--------------------------------------------------------------------------*/ 117 void wavCreateHeader ( WAVECHUNK *wc, 118 int channels, 119 int samples, 120 int bitsPerSample, 121 int sampleRate, 122 int loopEnd ); 123 124 void wavWriteHeader ( WAVECHUNK *wc, 125 FILE *outfile ); 126 127 void wavCreateSmplChunk ( WAVECHUNK *wc, 128 SMPLCHUNK *sc, 129 SMPLLOOP *sl, 130 u32 loopStart, 131 u32 loopEnd ); 132 133 void wavWriteSmplChunk ( SMPLCHUNK *sc, 134 SMPLLOOP *sl, 135 FILE *outfile ); 136 137 int wavReadHeader ( WAVECHUNK *wc, 138 LOOPINFO *li, 139 FILE *infile ); 140 141 u32 wavGetSamples ( WAVECHUNK *wc ); 142 u32 wavGetChannels ( WAVECHUNK *wc ); 143 u32 wavGetBitsPerSample ( WAVECHUNK *wc ); 144 u32 wavGetSampleRate ( WAVECHUNK *wc ); 145 146 #endif // __WAVFILE_H__ 147