1 /*---------------------------------------------------------------------------* 2 Project: Revolution THP Audio Library 3 File: thpaudio.h 4 5 Copyright (C)2002-2006 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: thpaudio.h,v $ 14 Revision 1.3 2006/12/21 07:03:12 aka 15 Removed THP_GC_OUTPUT_RATE. 16 Removed THPAudioResampleParameter. 17 Arranged THPAudioHandle. 18 19 Revision 1.2 2006/03/20 11:22:56 hiratsu 20 Fixed unsafe macro. 21 22 Revision 1.1 2006/02/08 02:52:42 aka 23 Imported from Dolphin Tree. 24 25 26 10 03/09/15 9:33a Akagi 27 28 9 03/07/03 10:56a Akagi 29 Renamed some functions. 30 31 8 03/07/01 3:09p Akagi 32 Modified to divide old THPConv.exe into 2 LIBs and 1 EXE by 33 Ohki-san@NTSC. 34 35 7 03/07/01 2:59p Akagi 36 Moved from build/tools/THPConv/include. 37 38 6 03/07/01 9:19a Akagi 39 Moved from securebuild/tools. 40 41 5 02/05/08 2:30p Akagi 42 modified [-trk] option By Tsuji (IRD) 43 44 1 02/01/16 4:56p Akagi 45 Initial revision made by Tsuji-san (IRD). 46 47 $NoKeywords: $ 48 49 *---------------------------------------------------------------------------*/ 50 51 #ifndef __THPAUDIO_H__ 52 #define __THPAUDIO_H__ 53 54 #include <revolution/types.h> 55 #include <revolution/thpfile.h> 56 #include <win32/dsptool.h> 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 #define THP_TAP_SIZE 16 63 64 //#define THP_NTSC_RATE (59.94) 65 #define THP_OVERLAP_FRAME (50) 66 #define THP_OVERLAP_SAMPLE (14 * THP_OVERLAP_FRAME) 67 #define THP_ENCODE_SAMPLE (3600 * 14) 68 #define THP_SAMPLE_BUFFER_SIZE (THP_ENCODE_SAMPLE + THP_OVERLAP_SAMPLE) 69 #define THP_ADPCM_BUFFER_SIZE ((THP_SAMPLE_BUFFER_SIZE / 14) * 8) 70 71 #define THPADPCMSampleToByte(x) (u32)(((x) / 14) * 8) 72 #define THPGetEncDataPtr(x, y) (u8 *)((u32)(x) + THPADPCMSampleToByte(y)) 73 #define THPGetDecDataPtr(x, y) (s16 *)((u32)(x) + (y) * 2) 74 75 typedef struct 76 { 77 char fileName[_MAX_PATH]; 78 FILE* fileHandle; 79 u32 frequency; 80 u32 channel; 81 u32 bitPerSample; 82 u32 totalSampleSize; 83 u32 dataBlockOffset; 84 u32 curFileOffset; 85 s32 formatType; 86 s32 type; 87 88 } THPAudioFileInfo; 89 90 typedef struct 91 { 92 u32 offsetNextChannel; 93 u32 sampleSize; 94 u16 lCoef[16]; 95 u16 rCoef[16]; 96 u16 lYn1; 97 u16 lYn2; 98 u16 rYn1; 99 u16 rYn2; 100 101 } THPAudioRecordHeader; 102 103 typedef struct 104 { 105 THPAudioFileInfo audioInfo; 106 u32 restEncodedSample; 107 u32 currentFrameNumber; 108 f64 frameRate; 109 s16* leftDecodedPtr; 110 s16* rightDecodedPtr; 111 u8* leftADPCMPtr; 112 u8* rightADPCMPtr; 113 ADPCMINFO leftADPCMInfo; 114 ADPCMINFO rightADPCMInfo; 115 THPAudioRecordHeader recordHeader; 116 s16 leftSampleBuffer [THP_SAMPLE_BUFFER_SIZE]; 117 s16 rightSampleBuffer [THP_SAMPLE_BUFFER_SIZE]; 118 s16 leftDecodedBuffer [THP_SAMPLE_BUFFER_SIZE]; 119 s16 rightDecodedBuffer[THP_SAMPLE_BUFFER_SIZE]; 120 u8 leftADPCMBuffer [THP_ADPCM_BUFFER_SIZE]; 121 u8 rightADPCMBuffer [THP_ADPCM_BUFFER_SIZE]; 122 u32 readSample; 123 124 } THPAudioHandle; 125 126 extern s32 THPAudioInit( void ); 127 extern s32 THPAudioQuit( void ); 128 129 extern THPAudioHandle* THPAudioCreateHandle( char* fileName, f32 framerate ); 130 extern void THPAudioFreeHandle ( THPAudioHandle* handle ); 131 132 extern s32 THPAudioGetInfo ( THPAudioHandle* handle, THPAudioInfo* audioInfo ); 133 extern u32 THPAudioGetTotalSamples ( THPAudioHandle* handle, s32 frame ); 134 extern u32 THPAudioGetFrameSize ( THPAudioHandle* handle, u32 frame ); 135 extern u32 THPAudioGetMaxFrameSize ( THPAudioHandle* handle, s32 frame ); 136 extern u32 THPAudioGetMaxFrameSamples( THPAudioHandle* handle, s32 frame ); 137 138 extern s32 THPAudioWriteFrame( THPAudioHandle* handle, FILE* output, s32 flag ); 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif //__THPAUDIO_H__ 145