1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_StreamSoundFileReader.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: 19484 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_SND_STREAM_SOUND_FILE_READER_H_
17 #define NW_SND_STREAM_SOUND_FILE_READER_H_
18 
19 #include <nw/snd/snd_StreamSoundFile.h>
20 #include <nw/snd/snd_Global.h>
21 
22 namespace nw {
23 namespace snd {
24 namespace internal {
25 
26 class StreamSoundFileReader
27 {
28 public:
29     struct TrackInfo
30     {
31         u8 volume;
32         u8 pan;
33         u8 channelCount;
34         u8 globalChannelIndex[ WAVE_CHANNEL_MAX ];
35     };
36 
37     StreamSoundFileReader();
38     void Initialize( const void* streamSoundFile );
39     void Finalize();
IsAvailable()40     bool IsAvailable() const { return m_pHeader != NULL; }
41 
42     bool IsValidFileHeader( const void* streamSoundFile ) const;
43 
44     bool ReadStreamSoundInfo( StreamSoundFile::StreamSoundInfo* strmInfo ) const;
45     bool ReadStreamTrackInfo( TrackInfo* trackInfo, int trackIndex ) const;
46     bool ReadDspAdpcmChannelInfo(
47             DspAdpcmParam* param,
48             DspAdpcmLoopParam* loopParam,
49             int channelIndex ) const;
50 
GetChannelCount()51     NW_INLINE u32 GetChannelCount() const
52     {
53         NW_NULL_ASSERT( m_pInfoBlockBody );
54         return m_pInfoBlockBody->GetChannelInfoTable()->GetChannelCount();
55     }
56 
GetTrackCount()57     NW_INLINE u32 GetTrackCount() const
58     {
59         NW_NULL_ASSERT( m_pInfoBlockBody );
60         return m_pInfoBlockBody->GetTrackInfoTable()->GetTrackCount();
61     }
62 
GetSeekBlockOffset()63     NW_INLINE u32 GetSeekBlockOffset() const
64     {
65         if ( IsAvailable() )
66         {
67             return m_pHeader->GetSeekBlockOffset();
68         }
69         return 0;
70     }
71 
GetDataBlockOffset()72     NW_INLINE u32 GetDataBlockOffset() const
73     {
74         if ( IsAvailable() )
75         {
76             return m_pHeader->GetDataBlockOffset();
77         }
78         return 0;
79     }
80 private:
81     const StreamSoundFile::FileHeader*      m_pHeader;
82     const StreamSoundFile::InfoBlockBody*   m_pInfoBlockBody;
83 };
84 
85 } // namespace nw::snd::internal
86 } // namespace nw::snd
87 } // namespace nw
88 
89 
90 #endif /* NW_SND_STREAM_SOUND_FILE_READER_H_ */
91 
92