1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     snd_Adpcm.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_SND_CTR_COMMON_SND_ADPCM_H_
17 #define NN_SND_CTR_COMMON_SND_ADPCM_H_
18 
19 #if !defined(_I386)
20 #include <nn/dsp/CTR/Common/dsp_Types.h>
21 #endif // #if !defined(_I386))
22 
23 #ifndef CTR_DSP
24 namespace nn  { namespace snd { namespace CTR {
25 #endif // CTR_DSP
26 
27 #define NN_SND_ADPCM_DOL_PS_SIZE_IN_NIB    (2)
28 #define NN_SND_ADPCM_DOL_DATA_NUM_IN_BLOCK (14)
29 #define NN_SND_ADPCM_DOL_NIBL_NUM_IN_BLOCK (16)
30 
31 // Constants that depend on the operating environment.
32 #ifdef NN_PROCESSOR_ARM11MPCORE
33 #define NN_SND_ADPCM_DOL_BLOCK_SIZE   (8) //
34 #else  // #ifdef NN_PROCESSOR_ARM11MPCORE
35 #define NN_SND_ADPCM_DOL_BLOCK_SIZE   (4) //
36 #endif // #ifdef NN_PROCESSOR_ARM11MPCORE
37 
38 typedef struct
39 {
40     s16 a[8][2];
41 
42     u16 gain;
43     u16 pred_scale;
44     s16 yn1;
45     s16 yn2;
46 
47     // Loop context
48     u16 loop_pred_scale;
49     s16 loop_yn1;
50     s16 loop_yn2;
51 
52     u16 pad[1];
53 } DspsndAdpcmState;
54 
55 typedef struct
56 {
57     u32 num_samples;
58     u32 num_adpcm_nibbles;
59     u32 sample_rate;
60 
61     u16 loop_flag;
62     u16 format;
63     u32 sa;     // loop start address
64     u32 ea;     // loop end address
65     u32 ca;     // current address
66 
67     DspsndAdpcmState state;
68 
69     u16 pad[10];
70 
71 } DspsndAdpcmHeader;
72 
73 /* Please see man pages for details
74 
75 */
76 struct AdpcmParam
77 {
78     u16 coef[16]; //
79 }; // AdpcmParam
80 
81 
82 /* Please see man pages for details
83 
84 */
85 struct AdpcmContext
86 {
87     u16 pred_scale; //
88     s16 yn1;        //
89     s16 yn2;        //
90 };
91 
92 #ifndef CTR_DSP
93 }}} // namespace nn::snd::CTR
94 #endif // CTR_DSP
95 
96 #endif // #ifndef NN_SND_CTR_COMMON_SND_ADPCM_H_
97