1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_StreamSoundFileReader.h 4 5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain proprietary 8 information of Nintendo and/or its licensed developers and are protected by 9 national and international copyright laws. They may not be disclosed to third 10 parties or copied or duplicated in any form, in whole or in part, without the 11 prior written consent of Nintendo. 12 13 The content herein is highly confidential and should be handled accordingly. 14 15 $Revision: 31311 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_SND_STREAM_SOUND_FILE_READER_H_ 19 #define NW_SND_STREAM_SOUND_FILE_READER_H_ 20 21 #include <nw/snd/snd_StreamSoundFile.h> 22 #include <nw/snd/snd_Global.h> 23 24 namespace nw { 25 namespace snd { 26 namespace internal { 27 28 class StreamSoundFileReader 29 { 30 public: 31 struct TrackInfo 32 { 33 u8 volume; 34 u8 pan; 35 u8 channelCount; 36 u8 globalChannelIndex[ WAVE_CHANNEL_MAX ]; 37 }; 38 39 StreamSoundFileReader(); 40 void Initialize( const void* streamSoundFile ); 41 void Finalize(); IsAvailable()42 bool IsAvailable() const { return m_pHeader != NULL; } 43 44 bool IsValidFileHeader( const void* streamSoundFile ) const; 45 46 bool ReadStreamSoundInfo( StreamSoundFile::StreamSoundInfo* strmInfo ) const; 47 bool ReadStreamTrackInfo( TrackInfo* trackInfo, int trackIndex ) const; 48 bool ReadDspAdpcmChannelInfo( 49 DspAdpcmParam* param, 50 DspAdpcmLoopParam* loopParam, 51 int channelIndex ) const; 52 GetChannelCount()53 NW_INLINE u32 GetChannelCount() const 54 { 55 NW_NULL_ASSERT( m_pInfoBlockBody ); 56 return m_pInfoBlockBody->GetChannelInfoTable()->GetChannelCount(); 57 } 58 GetTrackCount()59 NW_INLINE u32 GetTrackCount() const 60 { 61 NW_NULL_ASSERT( m_pInfoBlockBody ); 62 return m_pInfoBlockBody->GetTrackInfoTable()->GetTrackCount(); 63 } 64 GetSeekBlockOffset()65 NW_INLINE u32 GetSeekBlockOffset() const 66 { 67 if ( IsAvailable() ) 68 { 69 return m_pHeader->GetSeekBlockOffset(); 70 } 71 return 0; 72 } 73 GetDataBlockOffset()74 NW_INLINE u32 GetDataBlockOffset() const 75 { 76 if ( IsAvailable() ) 77 { 78 return m_pHeader->GetDataBlockOffset(); 79 } 80 return 0; 81 } 82 private: 83 const StreamSoundFile::FileHeader* m_pHeader; 84 const StreamSoundFile::InfoBlockBody* m_pInfoBlockBody; 85 }; 86 87 } // namespace nw::snd::internal 88 } // namespace nw::snd 89 } // namespace nw 90 91 92 #endif /* NW_SND_STREAM_SOUND_FILE_READER_H_ */ 93 94