1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_BankFile.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_BANK_FILE_H_ 19 #define NW_SND_BANK_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 25 namespace nw { 26 namespace snd { 27 namespace internal { 28 29 /* 30 バンクファイル (.bcbnk) の構造 31 32 bcbnk 33 | 34 +-- FileHeader 35 +-- InfoBlock 36 | 37 +-- ut::BinaryBlockHeader 38 +-- InfoBlockBody 39 | 40 +-- reference to Table of InnerWave 41 | | 42 | +-> Table<InnerWave> 43 | | 44 | +-- s32 count 45 | +-- InnerWave[0] 46 | +-- InnerWave[1] 47 | +-- ... 48 | 49 +-- reference to Table of [reference to Instrument] 50 | 51 +-> Table<reference to Instrument> 52 | 53 +-- s32 count 54 +-- Reference to Instrument[0] --+ ← このインデックスが 55 +-- Reference to Instrument[1] | prg No として扱われる。 56 +-- ... | 57 +-----------------------------------------------------+ 58 | 59 +-> Instrument 60 | 61 +-- reference to KeyRegionChunk 62 | 63 typeId ? 64 | 65 +-- Direct --> DirectChunk ← キーリージョンの分割数によって 66 +-- Range --> RangeChunk 格納されるデータ構造が異なる 67 +-- Index --> IndexChunk 68 | 69 +-> KeyRegion を取得する 70 | 71 +------------------------------+ 72 | 73 +-- KeyRegion 74 | 75 +-- reference to VelocityRegionChunk 76 | 77 typeId ? 78 +-- Direct --> DirectChunk 79 +-- Range --> RangeChunk 80 +-- Index --> IndexChunk 81 | 82 +-> VelocityRegion を取得する 83 */ 84 85 struct BankFile 86 { 87 //----------------------------------------------------------------- 88 // ファイルヘッダー 89 90 struct InfoBlock; 91 92 struct FileHeader : public Util::SoundFileHeader 93 { 94 const InfoBlock* GetInfoBlock() const; 95 }; 96 97 //----------------------------------------------------------------- 98 // 情報ブロック 99 100 struct Instrument; 101 102 struct InfoBlockBody 103 { 104 // データ 105 Util::Reference toWaveIdTable; // "バンク内波形 ID" テーブル 106 Util::Reference toInstrumentReferenceTable; // "インストへの参照" テーブル 107 108 // "バンク内波形 ID" テーブルアクセサ 109 110 // アクセサ 111 // (テーブル取得) 112 const Util::WaveIdTable& GetWaveIdTable() const; 113 const Util::ReferenceTable& GetInstrumentReferenceTable() const; 114 115 // (テーブルアイテム数取得) GetWaveIdCountBankFile::InfoBlockBody116 NW_INLINE u32 GetWaveIdCount() const 117 { 118 return GetWaveIdTable().GetCount(); 119 } GetInstrumentCountBankFile::InfoBlockBody120 NW_INLINE s32 GetInstrumentCount() const 121 { 122 return GetInstrumentReferenceTable().count; 123 } 124 125 // (テーブルアイテム取得) GetWaveIdBankFile::InfoBlockBody126 NW_INLINE const Util::WaveId* GetWaveId( u32 index ) const 127 { 128 return GetWaveIdTable().GetWaveId( index ); 129 } 130 const Instrument* GetInstrument( int programNo ) const; 131 }; 132 133 struct InfoBlock 134 { 135 ut::BinaryBlockHeader header; 136 InfoBlockBody body; 137 }; 138 139 140 struct KeyRegion; 141 struct Instrument 142 { 143 // データ 144 Util::Reference toKeyRegionChunk; 145 146 // アクセサ 147 const KeyRegion* GetKeyRegion( u32 key ) const; 148 }; 149 150 struct VelocityRegion; 151 struct KeyRegion 152 { 153 // データ 154 Util::Reference toVelocityRegionChunk; 155 156 // アクセサ 157 const VelocityRegion* GetVelocityRegion( u32 velocity ) const; 158 }; 159 160 struct RegionParameter; 161 struct VelocityRegion 162 { 163 // データ 164 nw::ut::ResU32 waveIdTableIndex; 165 Util::BitFlag optionParameter; 166 167 // アクセサ 168 u8 GetOriginalKey() const; 169 u8 GetVolume() const; 170 u8 GetPan() const; 171 #ifdef NW_PLATFORM_RVL 172 u8 GetSurroundPan() const; 173 #endif /* NW_PLATFORM_RVL */ 174 f32 GetPitch() const; 175 bool IsIgnoreNoteOff() const; 176 u8 GetKeyGroup() const; 177 u8 GetInterpolationType() const; 178 const AdshrCurve& GetAdshrCurve() const; 179 180 const RegionParameter* GetRegionParameter() const; 181 }; 182 183 // VelocityRegion::optionParameter に格納されている値 184 struct RegionParameter 185 { 186 // -------------------------------------------- 187 // VELOCITY_REGION_KEY 188 u8 originalKey; 189 u8 padding1[3]; // ignore 190 // -------------------------------------------- 191 // VELOCITY_REGION_VOLUME 192 u8 volume; 193 u8 padding2[3]; // ignore 194 // -------------------------------------------- 195 // VELOCITY_REGION_PAN 196 u8 pan; 197 s8 surroundPan; // for RVL 198 u8 padding3[2]; // ignore 199 // -------------------------------------------- 200 // VELOCITY_REGION_PITCH 201 f32 pitch; 202 // -------------------------------------------- 203 // VELOCITY_REGION_INSTRUMENT_NOTE_PARAM 204 bool isIgnoreNoteOff; 205 u8 keyGroup; 206 u8 interpolationType; 207 u8 padding4[1]; // ignore 208 // -------------------------------------------- 209 // VELOCITY_REGION_ENVELOPE 210 u32 offset; // ignore 211 Util::Reference refToAdshrCurve; // ignore 212 AdshrCurve adshrCurve; 213 }; 214 }; 215 216 } // namespace nw::snd::internal 217 } // namespace nw::snd 218 } // namespace nw 219 220 221 #endif /* NW_SND_BANK_FILE_H_ */ 222 223