1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_StreamSound.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. 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 $Revision: 21480 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_STREAM_SOUND_H_ 17 #define NW_SND_STREAM_SOUND_H_ 18 19 #include <nw/snd/snd_SoundInstanceManager.h> 20 #include <nw/snd/snd_BasicSound.h> 21 #include <nw/snd/snd_StreamSoundPlayer.h> 22 #include <nw/snd/snd_StreamBufferPool.h> 23 #include <nw/snd/snd_Debug.h> 24 25 namespace nw { 26 namespace snd { 27 28 class StreamSoundHandle; 29 30 namespace internal { 31 32 class StreamSound; 33 34 typedef SoundInstanceManager<StreamSound, driver::StreamSoundPlayer> StreamSoundInstanceManager; 35 36 class StreamSound : public BasicSound 37 { 38 friend class StreamSoundHandle; 39 40 public: 41 NW_UT_RUNTIME_TYPEINFO; // ダウンキャスト用の実行時型情報を埋め込みます 42 43 static const int FILE_STREAM_BUFFER_SIZE = 512; 44 45 /* ------------------------------------------------------------------------ 46 class member 47 ------------------------------------------------------------------------ */ 48 public: 49 StreamSound( StreamSoundInstanceManager& manager ); 50 51 void Setup( 52 driver::StreamBufferPool* pBufferPool, 53 int allocChannelCount, 54 u16 allocTrackFlag 55 ); 56 void Prepare( 57 driver::StreamSoundPlayer::StartOffsetType startOffsetType, 58 s32 offset, 59 io::FileStream* pFileStream 60 ); 61 virtual void Initialize(); 62 virtual void Finalize(); 63 virtual bool IsPrepared() const; 64 bool IsSuspendByLoadingDelay() const; 65 GetFileStreamBuffer()66 void* GetFileStreamBuffer() { return m_FileStreamBuffer; } GetFileStreamBufferSize()67 long GetFileStreamBufferSize() { return FILE_STREAM_BUFFER_SIZE; } 68 69 // トラックパラメータ 70 void SetTrackVolume( unsigned long trackBitFlag, float volume, int frames = 0 ); 71 void SetTrackPan( unsigned long trackBitFlag, float pan ); 72 void SetTrackSurroundPan( unsigned long trackBitFlag, float span ); 73 74 // 情報取得 75 bool ReadStreamDataInfo( StreamDataInfo* info ) const; 76 long GetPlayLoopCount() const; 77 long GetPlaySamplePosition() const; 78 float GetFilledBufferPercentage() const; 79 80 // const driver::StreamSoundPlayer& GetStreamSoundPlayer() const { return m_StreamSoundPlayer; } 81 82 // デバッグ関数 GetSoundType()83 DebugSoundType GetSoundType() const { return DEBUG_SOUND_TYPE_STRMSOUND; } 84 85 protected: 86 virtual bool IsAttachedTempSpecialHandle(); 87 virtual void DetachTempSpecialHandle(); 88 virtual void UpdateMoveValue(); 89 virtual void UpdateParam(); 90 GetBasicSoundPlayerHandle()91 virtual driver::BasicSoundPlayer* GetBasicSoundPlayerHandle() { return &m_StreamSoundPlayerInstance; } 92 93 virtual void OnUpdatePlayerPriority(); 94 95 private: 96 driver::StreamSoundPlayer m_StreamSoundPlayerInstance; 97 StreamSoundHandle* m_pTempSpecialHandle; 98 StreamSoundInstanceManager& m_Manager; 99 100 MoveValue<float, int> m_TrackVolume[ driver::StreamSoundPlayer::STRM_TRACK_NUM ]; 101 102 io::FileStream* m_pFileStream; 103 int m_FileStreamBuffer[ FILE_STREAM_BUFFER_SIZE/sizeof(int) ]; 104 u16 m_AllocTrackFlag; 105 bool m_InitializeFlag; 106 }; 107 108 } // namespace nw::snd::internal 109 } // namespace nw::snd 110 } // namespace nw 111 112 113 #endif /* NW_SND_STREAM_SOUND_H_ */ 114 115