1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: snd_OutputCapture.h 4 5 Copyright (C)2009 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: 29256 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_SND_CTR_OUTPUT_CAPTURE_H_ 17 #define NN_SND_CTR_OUTPUT_CAPTURE_H_ 18 19 #include <nn/snd.h> 20 21 #ifdef __cplusplus 22 23 namespace nn { 24 namespace snd { 25 namespace CTR { 26 27 class Dspsnd; 28 29 /*! 30 @brief DSP の最終出力を取得するためのクラスです。 31 */ 32 class OutputCapture 33 { 34 friend class Dspsnd; // Dspsnd のみが OutputCapture::Write が可能です。 35 36 private: 37 /*! :private 38 @brief DSP からデータを取得します。 39 @param[in] pData データバッファ 40 @param[in] length データのサンプル長 41 */ 42 void Write(s16* pData, s32 length = NN_SND_SAMPLES_PER_FRAME); 43 44 public: 45 /*! :private 46 @name コンストラクタ/デストラクタ 47 @{ 48 */ 49 /*! :private 50 @brief コンストラクタです。 51 */ 52 OutputCapture(); 53 54 /*! :private 55 @brief デストラクタです。 56 */ 57 ~OutputCapture(); 58 /*! :private 59 @} 60 */ 61 62 /*! 63 @name 初期化/終了処理 64 @{ 65 */ 66 /*! 67 @brief 指定されたサウンドフレーム数から、必要なバッファサイズを計算します。 68 @param[in] frames サウンドフレーム数 69 @return バッファサイズを返します。 70 */ GetRequiredMemorySize(s32 frames)71 static inline size_t GetRequiredMemorySize(s32 frames) 72 { 73 return NN_SND_SAMPLES_PER_FRAME * sizeof(s16) * 2 * frames; 74 } 75 76 /*! 77 @brief 初期化します。 78 @param[in] buffer バッファアドレス 79 @param[in] size バッファサイズ 80 */ 81 void Initialize(void* buffer, size_t size); 82 83 /*! 84 @brief 終了処理を行います。 85 */ 86 void Finalize(); 87 /*! 88 @} 89 */ 90 91 /*! 92 @name データ取得 93 @{ 94 */ 95 /*! 96 @brief DSP からのデータ取得を有効 / 無効にします。 97 @param[in] enable 有効 / 無効フラグ 98 */ 99 void Enable(bool enable = true); 100 101 /*! 102 @brief DSP からのデータ取得を無効にします。 103 */ Disable()104 void Disable() { Enable(false); } 105 106 /*! 107 @brief DSP からのデータ取得が有効かどうかを取得します。 108 @return 有効なら true を、無効なら false を返します。 109 */ IsEnabled()110 bool IsEnabled() const { return m_IsEnabled; } 111 112 /*! 113 @brief DSP から取得したデータを指定バッファにコピーします。 114 @param[out] pData データバッファ 115 @param[in] length 取得するデータのサンプル長 116 @return 実際に取得したデータのサンプル長を返します。 117 */ 118 s32 Read(s16* pData, s32 length = NN_SND_SAMPLES_PER_FRAME); 119 120 /*! 121 @brief すべての取得済みデータを破棄します。 122 */ 123 void Reset(); 124 /*! 125 @} 126 */ 127 128 private: 129 static const size_t UNIT_SIZE = sizeof(s16) * 2; // 16bit, stereo 130 131 uptr m_BufferAddress; // 取得するデータを格納するバッファアドレス 132 s32 m_BufferLength; // バッファ長 133 s32 m_ReadPos; // リード位置 134 s32 m_WritePos; // ライト位置 135 bool m_IsEnabled; // 有効 / 無効フラグ 136 NN_PADDING3; 137 }; // class OutputCapture 138 139 /*! 140 @name DSP 最終出力取得 141 @{ 142 */ 143 /*! 144 @brief DSP 最終出力を取得するためのキャプチャを設定します。 145 @param[in] pCapture キャプチャ 146 */ 147 void SetOutputCapture(OutputCapture* pCapture); 148 /*! 149 @} 150 */ 151 152 } // namespace CTR 153 } // namespace snd 154 } // namespace nn 155 156 #endif // __cplusplus 157 158 #endif // NN_SND_CTR_OUTPUT_CAPTURE_H_ 159