1 /*--------------------------------------------------------------------------*
2   Project:  Revolution SOUNDFILE dynamic link library
3   File:     aifffile.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: aifffile.h,v $
14   Revision 1.3  2009/03/30 07:44:45  aka
15   Copied from SDK_3_2_DEV_BRANCH.
16 
17   Revision 1.2.40.1  2009/03/30 04:39:49  aka
18   Cleaned up.
19 
20   Revision 1.2  2006/02/09 06:51:39  aka
21   Changed copyright.
22 
23  *--------------------------------------------------------------------------*/
24 
25 #ifndef __AIFFFILE_H__
26 #define __AIFFFILE_H__
27 
28 #include "Types.h"
29 #include "chunkname.h"
30 
31 
32 /*--------------------------------------------------------------------------*
33     AIFF chunk names
34  *--------------------------------------------------------------------------*/
35 #define CHUNK_FORM  chunk_name('F','O','R','M')
36 #define CHUNK_AIFF  chunk_name('A','I','F','F')
37 #define CHUNK_AIFC  chunk_name('A','I','F','C')
38 #define CHUNK_FVER  chunk_name('F','V','E','R')
39 #define CHUNK_COMM  chunk_name('C','O','M','M')
40 #define CHUNK_SSND  chunk_name('S','S','N','D')
41 #define CHUNK_MARK  chunk_name('M','A','R','K')
42 #define CHUNK_COMT  chunk_name('C','O','M','T')
43 #define CHUNK_INST  chunk_name('I','N','S','T')
44 #define CHUNK_MIDI  chunk_name('M','I','D','I')
45 #define CHUNK_AESD  chunk_name('A','E','S','D')
46 #define CHUNK_APPL  chunk_name('A','P','P','L')
47 #define CHUNK_NAME  chunk_name('N','A','M','E')
48 #define CHUNK_AUTH  chunk_name('A','U','T','H')
49 #define CHUNK_COPY  chunk_name('(','c',')',' ')
50 #define CHUNK_ANNO  chunk_name('A','N','N','O')
51 
52 
53 /*--------------------------------------------------------------------------*
54     CHUNK structs
55  *--------------------------------------------------------------------------*/
56 typedef struct
57 {
58     u8        chunk[4];
59     u8        bytes[4];
60 
61     u8        channels[2];
62     u8        samples[4];
63     u8        bitsPerSample[2];
64     u8        samplesPerSec[10];
65 
66 } AIFFCOMM;
67 
68 typedef struct
69 {
70     u8        chunk[4];
71     u8        bytes[4];
72 
73     u8        normalKey;
74     u8        detune;
75     u8        lowKey;
76     u8        hiKey;
77     u8        loVel;
78     u8        hiVel;
79     u8        gain[2];
80 
81     u8        playMode0[2];
82     u8        begLoop0[2];
83     u8        endLoop0[2];
84 
85     u8        playMode1[2];
86     u8        begLoop1[2];
87     u8        endLoop1[2];
88 
89 
90 } AIFFINST;
91 
92 typedef struct
93 {
94     u8        chunk[4];
95     u8        bytes[4];
96 
97     u8        count[2];
98 
99     u8        id0[2];
100     u8        position0[4];
101     u8        ch0[10];
102 
103     u8        id1[2];
104     u8        position1[4];
105     u8        ch1[10];
106 
107 } AIFFMARK;
108 
109 typedef struct
110 {
111     AIFFCOMM  comm;
112     AIFFINST  inst;
113     AIFFMARK  mark;
114 
115 } AIFFINFO;
116 
117 
118 /*--------------------------------------------------------------------------*
119     Function prototypes
120  *--------------------------------------------------------------------------*/
121 void aiffCreateHeader     ( AIFFINFO    *aiffinfo,
122                             int         channels,
123                             int         samples,
124                             int         bitsPerSample,
125                             int         sampleRate );
126 
127 void aiffWriteHeader      ( AIFFINFO    *aiffinfo,
128                             FILE        *outfile,
129                             int         channels,
130                             int         samples,
131                             int         bitsPerSample,
132                             int         loopEnd );
133 
134 void aiffCreateMark       ( AIFFINFO    *aiffinfo,
135                             u32         loopStart,
136                             u32         loopEnd );
137 
138 void aiffWriteMark        ( AIFFINFO    *aiffinfo,
139                             FILE        *outfile );
140 
141 int  aiffReadHeader       ( AIFFINFO    *aiffinfo,
142                             FILE        *infile );
143 
144 int  aiffGetChannels      ( AIFFINFO *aiffinfo );
145 int  aiffGetSamples       ( AIFFINFO *aiffinfo );
146 int  aiffGetSampleRate    ( AIFFINFO *aiffinfo );
147 int  aiffGetBitsPerSample ( AIFFINFO *aiffinfo );
148 int  aiffGetLoopStart     ( AIFFINFO *aiffinfo );
149 int  aiffGetLoopEnd       ( AIFFINFO *aiffinfo );
150 
151 #endif  // __AIFFFILE_H__
152