/*---------------------------------------------------------------------------* Project: Horizon File: snd_OutputCapture.h Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 29256 $ *---------------------------------------------------------------------------*/ #ifndef NN_SND_CTR_OUTPUT_CAPTURE_H_ #define NN_SND_CTR_OUTPUT_CAPTURE_H_ #include #ifdef __cplusplus namespace nn { namespace snd { namespace CTR { class Dspsnd; /*! @brief DSP の最終出力を取得するためのクラスです。 */ class OutputCapture { friend class Dspsnd; // Dspsnd のみが OutputCapture::Write が可能です。 private: /*! :private @brief DSP からデータを取得します。 @param[in] pData データバッファ @param[in] length データのサンプル長 */ void Write(s16* pData, s32 length = NN_SND_SAMPLES_PER_FRAME); public: /*! :private @name コンストラクタ/デストラクタ @{ */ /*! :private @brief コンストラクタです。 */ OutputCapture(); /*! :private @brief デストラクタです。 */ ~OutputCapture(); /*! :private @} */ /*! @name 初期化/終了処理 @{ */ /*! @brief 指定されたサウンドフレーム数から、必要なバッファサイズを計算します。 @param[in] frames サウンドフレーム数 @return バッファサイズを返します。 */ static inline size_t GetRequiredMemorySize(s32 frames) { return NN_SND_SAMPLES_PER_FRAME * sizeof(s16) * 2 * frames; } /*! @brief 初期化します。 @param[in] buffer バッファアドレス @param[in] size バッファサイズ */ void Initialize(void* buffer, size_t size); /*! @brief 終了処理を行います。 */ void Finalize(); /*! @} */ /*! @name データ取得 @{ */ /*! @brief DSP からのデータ取得を有効 / 無効にします。 @param[in] enable 有効 / 無効フラグ */ void Enable(bool enable = true); /*! @brief DSP からのデータ取得を無効にします。 */ void Disable() { Enable(false); } /*! @brief DSP からのデータ取得が有効かどうかを取得します。 @return 有効なら true を、無効なら false を返します。 */ bool IsEnabled() const { return m_IsEnabled; } /*! @brief DSP から取得したデータを指定バッファにコピーします。 @param[out] pData データバッファ @param[in] length 取得するデータのサンプル長 @return 実際に取得したデータのサンプル長を返します。 */ s32 Read(s16* pData, s32 length = NN_SND_SAMPLES_PER_FRAME); /*! @brief すべての取得済みデータを破棄します。 */ void Reset(); /*! @} */ private: static const size_t UNIT_SIZE = sizeof(s16) * 2; // 16bit, stereo uptr m_BufferAddress; // 取得するデータを格納するバッファアドレス s32 m_BufferLength; // バッファ長 s32 m_ReadPos; // リード位置 s32 m_WritePos; // ライト位置 bool m_IsEnabled; // 有効 / 無効フラグ NN_PADDING3; }; // class OutputCapture /*! @name DSP 最終出力取得 @{ */ /*! @brief DSP 最終出力を取得するためのキャプチャを設定します。 @param[in] pCapture キャプチャ */ void SetOutputCapture(OutputCapture* pCapture); /*! @} */ } // namespace CTR } // namespace snd } // namespace nn #endif // __cplusplus #endif // NN_SND_CTR_OUTPUT_CAPTURE_H_