66/* PCM型 - ファイルのビット深度如何によらず、メモリ上では全て符号付き32bitで取り扱う */
77typedef int32_t WAVPcmData ;
88
9- /* WAVデータのフォーマット */
10- typedef enum WAVDataFormatTag {
11- WAV_DATA_FORMAT_PCM /* PCMのみ対応 */
12- } WAVDataFormat ;
9+ /* WAVファイルフォーマット */
10+ typedef enum {
11+ WAV_FILEFORMAT_PCMWAVEFORMAT = 0 , /* PCMWAVEFORMAT */
12+ WAV_FILEFORMAT_WAVEFORMATEXTENSIBLE , /* WAVEFORMATEXTENSIBLE */
13+ WAV_FILEFORMAT_AIFF , /* AIFF */
14+ WAV_FILEFORMAT_INVALID , /* 無効 */
15+ } WAVFileFormat ;
1316
1417/* API結果型 */
15- typedef enum WAVApiResultTag {
16- WAV_APIRESULT_OK = 0 ,
17- WAV_APIRESULT_NG ,
18- WAV_APIRESULT_INVALID_FORMAT , /* フォーマットが不正 */
19- WAV_APIRESULT_IOERROR , /* ファイル入出力エラー */
20- WAV_APIRESULT_INVALID_PARAMETER /* 引数が不正 */
18+ typedef enum {
19+ WAV_APIRESULT_OK = 0 , /* 成功 */
20+ WAV_APIRESULT_NG , /* 分類不能なエラー */
21+ WAV_APIRESULT_UNSUPPORTED_FORMAT , /* サポートしていないフォーマット */
22+ WAV_APIRESULT_INVALID_FORMAT , /* フォーマットが不正 */
23+ WAV_APIRESULT_IOERROR , /* ファイル入出力エラー */
24+ WAV_APIRESULT_INVALID_PARAMETER /* 引数が不正 */
2125} WAVApiResult ;
2226
23- /* WAVファイルフォーマット */
24- struct WAVFileFormat {
25- WAVDataFormat data_format ; /* データフォーマット */
26- uint32_t num_channels ; /* チャンネル数 */
27- uint32_t sampling_rate ; /* サンプリングレート */
28- uint32_t bits_per_sample ; /* 量子化ビット数 */
29- uint32_t num_samples ; /* サンプル数 */
27+ /* WAVフォーマット */
28+ struct WAVFormat {
29+ WAVFileFormat file_format ; /* ファイルフォーマット */
30+ uint32_t num_channels ; /* チャンネル数 */
31+ uint32_t sampling_rate ; /* サンプリングレート */
32+ uint32_t bits_per_sample ; /* 量子化ビット数 */
33+ uint32_t num_samples ; /* サンプル数 */
34+ union {
35+ /* WAVEFORMATEXTENSIBLEの拡張情報 */
36+ struct {
37+ uint16_t sample_information ;
38+ uint32_t channel_mask ;
39+ char guid [16 ];
40+ } wav_extensible ;
41+ struct {
42+ uint8_t key ;
43+ int16_t gain ;
44+ uint32_t loop_begin ;
45+ uint32_t loop_end ;
46+ } aiff_instrument ;
47+ } u ;
3048};
3149
3250/* WAVファイルハンドル */
3351struct WAVFile {
34- struct WAVFileFormat format ; /* フォーマット */
35- WAVPcmData * * data ; /* 実データ */
52+ struct WAVFormat format ; /* フォーマット */
53+ WAVPcmData * * data ; /* PCM配列 */
3654};
3755
3856/* アクセサ */
@@ -46,7 +64,7 @@ extern "C" {
4664struct WAVFile * WAV_CreateFromFile (const char * filename );
4765
4866/* フォーマットを指定して新規にWAVファイルハンドルを作成 */
49- struct WAVFile * WAV_Create (const struct WAVFileFormat * format );
67+ struct WAVFile * WAV_Create (const struct WAVFormat * format );
5068
5169/* WAVファイルハンドルを破棄 */
5270void WAV_Destroy (struct WAVFile * wavfile );
@@ -57,7 +75,7 @@ WAVApiResult WAV_WriteToFile(
5775
5876/* ファイルからWAVファイルフォーマットだけ読み取り */
5977WAVApiResult WAV_GetWAVFormatFromFile (
60- const char * filename , struct WAVFileFormat * format );
78+ const char * filename , struct WAVFormat * format );
6179
6280#ifdef __cplusplus
6381}
0 commit comments