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