1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_WaveSoundFile.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: 32399 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_SND_WAVE_SOUND_FILE_H_ 19 #define NW_SND_WAVE_SOUND_FILE_H_ 20 21 #include <nw/ut/ut_BinaryFileFormat.h> 22 #include <nw/snd/snd_Util.h> 23 #include <nw/snd/snd_Global.h> 24 #include <nw/snd/snd_CurveAdshr.h> 25 26 namespace nw { 27 namespace snd { 28 namespace internal { 29 30 /* 31 ウェーブサウンドファイル (.bcwsd) の構造 32 33 「ウェーブサウンド」ファイルと呼んでいるが、実際には、 34 「ウェーブサウンドセット」1つ分を格納するファイルとなっている。 35 36 bcwsd 37 | 38 +-- FileHeader 39 +-- InfoBlock 40 | 41 +-- ut::BinaryBlockHeader 42 +-- InfoBlockBody 43 | 44 +-- Table<ref to WaveSoundData> 45 | 46 +-- u32 count 47 +-- ref to WaveSoundData[0] --+ ← このインデックスが、ウェー 48 +-- ref to WaveSoundData[1] | ブサウンドセット内でのイン 49 +-- ... | デックスに相当する。 50 +--------------------------------------------+ 51 | 52 +-> WaveSoundData 53 | 54 +-- ref to WaveSoundInfo 55 | | 56 | +--> RawWaveSoundInfo 57 | | 58 | +-- optionParameter (パン、ピッチ、センド量、ADSR) 59 | 60 +-- ref to TrackInfoTable <-- 各トラックの楽譜情報が入る 61 | | 62 | +--> Table<ref to TrackInfo> 63 | | 64 | +-- u32 count 65 | +-- ref to TrackInfo[0] --+ 66 | +-- ref to TrackInfo[1] | 67 | +-- ... | 68 | +-------------------------------+ 69 | | 70 | +--> TrackInfo 71 | | 72 | +-- ref to Table<ref to NoteEvent> 73 | | 74 | +--> Table<ref to NoteEvent> 75 | | 76 | +-- u32 count 77 | +-- ref to NoteEvent[0] --+ 78 | +-- ref to NoteEvent[1] | 79 | +-- ... | 80 | +-------------------------------------------+ 81 | | 82 | +--> NoteEvent 83 | | 84 | +-- position 85 | +-- length 86 | +-- noteIndex <-- NoteInfoTable のノートのインデックス 87 | +-- reserved 88 | 89 +-- ref to NoteInfoTable <-- トラックで使われる全ノートの 90 | 情報が入る 91 +--> Table<ref to NoteInfo> 92 | 93 +-- u32 count 94 +-- ref to NoteInfo[0] --+ 95 +-- ref to NoteInfo[1] | 96 +-- ... | 97 +----------------------------------+ 98 | 99 +--> NoteInfo 100 | 101 +-- waveArchiveId 102 +-- waveIndex 103 +-- optionParameter 104 | 105 +-- originalKey 106 +-- volume 107 +-- pan 108 +-- (surroundPan) 109 +-- pitch 110 +-- sendValue 111 +-- adshrCurve 112 113 */ 114 115 struct WaveSoundFile 116 { 117 // 118 // ヘッダー 119 // 120 struct InfoBlock; 121 struct FileHeader : public Util::SoundFileHeader 122 { 123 // アクセサ 124 const InfoBlock* GetInfoBlock() const; 125 }; 126 127 // 128 // INFO ブロック 129 // 130 131 struct WaveSoundData; 132 133 struct InfoBlockBody 134 { 135 // データ 136 Util::Reference toWaveIdTable; 137 Util::Reference toWaveSoundDataReferenceTable; 138 139 // アクセサ 140 // (テーブル取得) 141 const Util::WaveIdTable& GetWaveIdTable() const; 142 const Util::ReferenceTable& GetWaveSoundDataReferenceTable() const; 143 144 // (テーブルアイテム数取得) GetWaveIdCountWaveSoundFile::InfoBlockBody145 NW_INLINE u32 GetWaveIdCount() const 146 { 147 return GetWaveIdTable().GetCount(); 148 } GetWaveSoundCountWaveSoundFile::InfoBlockBody149 NW_INLINE u32 GetWaveSoundCount() const 150 { 151 return GetWaveSoundDataReferenceTable().count; 152 } 153 154 // (テーブルアイテム取得) GetWaveIdWaveSoundFile::InfoBlockBody155 NW_INLINE const Util::WaveId* GetWaveId( u32 index ) const 156 { 157 return GetWaveIdTable().GetWaveId( index ); 158 } 159 const WaveSoundData& GetWaveSoundData( u32 index ) const; 160 }; 161 162 struct InfoBlock 163 { 164 ut::BinaryBlockHeader header; 165 InfoBlockBody body; 166 }; 167 168 169 struct WaveSoundInfo; 170 struct TrackInfo; 171 struct NoteInfo; 172 173 // ウェーブサウンド 1 つ分のデータ 174 struct WaveSoundData 175 { 176 // データ 177 Util::Reference toWaveSoundInfo; 178 Util::Reference toTrackInfoReferenceTable; 179 Util::Reference toNoteInfoReferenceTable; 180 181 // アクセサ 182 const WaveSoundInfo& GetWaveSoundInfo() const; 183 184 // (テーブル取得) 185 const Util::ReferenceTable& GetTrackInfoReferenceTable() const; 186 const Util::ReferenceTable& GetNoteInfoReferenceTable() const; 187 188 // (テーブルアイテム数取得) GetTrackCountWaveSoundFile::WaveSoundData189 NW_INLINE u32 GetTrackCount() const 190 { 191 return GetTrackInfoReferenceTable().count; 192 } GetNoteCountWaveSoundFile::WaveSoundData193 NW_INLINE u32 GetNoteCount() const 194 { 195 return GetNoteInfoReferenceTable().count; 196 } 197 198 // (テーブルアイテム取得) 199 const TrackInfo& GetTrackInfo( u32 index ) const; 200 const NoteInfo& GetNoteInfo( u32 index ) const; 201 }; 202 203 struct WaveSoundInfo 204 { 205 // データ 206 Util::BitFlag optionParameter; 207 208 // アクセサ 209 u8 GetPan() const; 210 s8 GetSurroundPan() const; 211 f32 GetPitch() const; 212 void GetSendValue( u8* mainSend, u8* fxSend, u8 fxSendCount ) const; 213 const AdshrCurve& GetAdshrCurve() const; 214 }; 215 216 struct NoteEvent; 217 218 struct TrackInfo 219 { 220 // データ 221 Util::Reference toNoteEventReferenceTable; 222 223 // アクセサ 224 // (テーブル取得) 225 const Util::ReferenceTable& GetNoteEventReferenceTable() const; 226 227 // (テーブルアイテム数取得) GetNoteEventCountWaveSoundFile::TrackInfo228 NW_INLINE u32 GetNoteEventCount() const 229 { 230 return GetNoteEventReferenceTable().count; 231 } 232 233 // (テーブルアイテム取得) 234 const NoteEvent& GetNoteEvent( u32 index ) const; 235 }; 236 237 struct NoteEvent 238 { 239 ut::ResF32 position; 240 ut::ResF32 length; 241 ut::ResU32 noteIndex; 242 ut::ResU32 reserved; 243 }; 244 245 struct NoteInfo 246 { 247 // データ 248 ut::ResU32 waveIdTableIndex; 249 Util::BitFlag optionParameter; 250 251 // アクセサ 252 u8 GetOriginalKey() const; 253 u8 GetVolume() const; 254 u8 GetPan() const; 255 u8 GetSurroundPan() const; 256 f32 GetPitch() const; 257 void GetSendValue( u8* mainSend, u8* fxSend[], u8 fxSendCount ) const; 258 const AdshrCurve& GetAdshrCurve() const; 259 }; 260 }; 261 262 } // namespace nw::snd::internal 263 } // namespace nw::snd 264 } // namespace nw 265 266 #endif /* NW_SND_WAVE_SOUND_FILE_H_ */ 267 268