BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
BrawlLib.SSBB.ResourceNodes.RSTMNode Class Reference
Inheritance diagram for BrawlLib.SSBB.ResourceNodes.RSTMNode:
BrawlLib.SSBB.ResourceNodes.RSARFileNode BrawlLib.Internal.Audio.IAudioSource BrawlLib.SSBB.ResourceNodes.NW4RNode BrawlLib.SSBB.ResourceNodes.ResourceNode

Public Member Functions

IAudioStream[] CreateStreams ()
 
override bool OnInitialize ()
 
override void Export (string outPath)
 
override void Replace (string fileName)
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.RSARFileNode
virtual void GetName ()
 
void AddSoundRef (RSARSoundNode n)
 
void RemoveSoundRef (RSARSoundNode n)
 
override bool OnInitialize ()
 
override void Export (string outPath)
 
override bool OnInitialize ()
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void OnRenamed ()
 
List< ResourceNodeGetChildrenRecursive ()
 Used primarily to get bone lists. Kept for all resource nodes for utility. More...
 
virtual void SignalPropertyChange ()
 
virtual void Dispose ()
 
void SelectChildAtIndex (int index)
 
void UpdateProperties ()
 
void UpdateCurrentControl ()
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual void OnMoved ()
 
virtual void DoMoveDown ()
 
virtual void DoMoveDown (bool select)
 
virtual void DoMoveUp ()
 
virtual void DoMoveUp (bool select)
 
virtual bool AddUp ()
 
virtual bool AddDown ()
 
virtual bool ToParent ()
 
void Populate (int levels=-1)
 
virtual void OnPopulate ()
 
void Initialize (ResourceNode parent, FileMap source)
 
void Initialize (ResourceNode parent, VoidPtr address, int length)
 
void Initialize (ResourceNode parent, DataSource origSource)
 
virtual void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
virtual bool OnInitialize ()
 
virtual void Restore ()
 
virtual void Remove ()
 
virtual void RemoveChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child, bool change)
 
virtual void InsertChild (ResourceNode child, int index)
 
virtual void InsertChild (ResourceNode child, bool change, int index)
 
void SetSizeInternal (int size)
 
virtual void Replace (string fileName)
 
virtual void Replace (ResourceNode node)
 
virtual void Replace (string fileName, FileMapProtect prot, FileOptions options)
 
virtual void ReplaceRaw (VoidPtr address, int length)
 
virtual void ReplaceRaw (FileMap map)
 
virtual void Export (string outPath)
 
void Export (FileStream outStream)
 
virtual void ExportUncompressed (string outPath)
 
void ExportUncompressed (FileStream outStream)
 
virtual void Rebuild ()
 
virtual void Rebuild (bool force)
 
virtual void Rebuild (VoidPtr address, int length, bool force)
 
virtual void OnRebuild (VoidPtr address, int length, bool force)
 
virtual int CalculateSize (bool force)
 
virtual int OnCalculateSize (bool force)
 
void Merge ()
 
void Merge (bool forceBuild)
 
ResourceNode FindChildByType (string path, bool searchChildren, params ResourceType[] types)
 
ResourceNode FindChildByType (string path, bool searchChildren, StringComparison compare, params ResourceType[] types)
 
ResourceNode FindChild (string path)
 
ResourceNode FindChild (string path, bool searchChildren)
 
ResourceNode FindChild (string path, StringComparison compare)
 
ResourceNode FindChild (string path, bool searchChildren, StringComparison compare)
 
ResourceNode[] FindChildrenByClassType (string path, Type type)
 
ResourceNode[] FindChildrenByType (string path, ResourceType type)
 
ResourceNode[] FindChildrenByTypeInGroup (string path, ResourceType type, byte group)
 
ResourceNode[] FindChildrenByName (string name)
 
unsafe string FindName (string name)
 
ResourceNode FindEmbeddedIndex (int index)
 
virtual unsafe byte[] MD5 ()
 Find the MD5 checksum of this node's data. If this node doesn't have any data (BRESGroupNode, for example), this method will return null. More...
 
string MD5Str ()
 Get the result of the MD5() function as a string of hexadecimal digits. If MD5() returns null, this method will return an empty string. More...
 
ResourceNode PrevSibling ()
 
ResourceNode NextSibling ()
 
override string ToString ()
 
virtual void SortChildren ()
 
IAudioStream[] CreateStreams ()
 

Static Public Member Functions

static void ShowADPCMConversionWarning ()
 
- Static Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
static ResourceNode[] FindAllSubNodes (ResourceNode root)
 
static ResourceNode FindNode (ResourceNode root, string path, bool searchChildren, StringComparison compare)
 

Static Public Attributes

static bool ADPCMConversionWarningShown
 

Properties

override ResourceType ResourceFileType [get]
 
override int FileNodeIndex [get]
 
override string AudioLength [get]
 
override string DataLength [get]
 
override string[] GroupRefs [get]
 
override string[] EntryRefs [get]
 
WaveEncoding Encoding [get]
 
int Channels [get]
 
bool IsLooped [get]
 
int SampleRate [get]
 
int LoopStartSample [get]
 
int NumSamples [get]
 
int NumBlocks [get]
 
int BlockSize [get]
 
int BitsPerSample [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.RSARFileNode
string ClosestMatching [get]
 
RSARGroupNode[] GroupRefNodes [get]
 
virtual string[] GroupRefs [get]
 
virtual string[] EntryRefs [get]
 
RSARSoundNode[] Sounds [get]
 
virtual int FileNodeIndex [get]
 
int EntryNumber [get]
 
virtual string InfoHeaderOffset [get]
 
virtual string AudioLength [get]
 
virtual string AudioOffset [get]
 
virtual string DataLength [get]
 
virtual string DataOffset [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.NW4RNode
byte VersionMajor [get]
 
byte VersionMinor [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
string FilePath [get]
 
string FileName [get]
 
string DirectoryName [get]
 
ResourceNode RootNode [get]
 
DataSource OriginalSource [get]
 
DataSource UncompressedSource [get]
 
DataSource WorkingSource [get]
 
DataSource WorkingUncompressed [get]
 
virtual bool HasChildren [get]
 
virtual ResourceType ResourceFileType [get]
 
string NodeType [get]
 
virtual string TreePathAbsolute [get]
 
virtual string TreePath [get]
 
virtual int Level [get]
 
virtual int MaxNameLength [get]
 
virtual bool AllowDuplicateNames [get]
 
virtual bool AllowNullNames [get]
 
virtual string Name [get, set]
 
ResourceNode Parent [get, set]
 
List< ResourceNodeChildren [get]
 
int Index [get]
 
int HexIndex [get]
 
bool IsCompressed [get]
 
bool HasChanged [get, set]
 
bool IsBranch [get]
 
bool HasMerged [get]
 
virtual bool AllowSaving [get, set]
 
virtual bool IsDirty [get, set]
 
virtual uint UncompressedSize [get]
 
virtual Type[] AllowedChildTypes [get]
 
virtual string Compression [get, set]
 
virtual bool RetainChildrenOnReplace [get]
 
virtual bool supportsCompression [get]
 
static MD5CryptoServiceProvider MD5Provider [get]
 
- Properties inherited from BrawlLib.Internal.Audio.IAudioSource
bool IsLooped [get]
 

Additional Inherited Members

- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.RSARFileNode
DataSource _audioSource
 
List< RSARGroupNode_groupRefs = new List<RSARGroupNode>()
 
List< string > _references = new List<string>()
 
List< RSARSoundNode_rsarSoundEntries = new List<RSARSoundNode>()
 
VoidPtr _infoHdr
 
VoidPtr _rebuildAudioAddr = null
 
int _headerLen = 0
 
int _audioLen = 0
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
Form _mainForm
 
string _name
 
string _origPath
 
ResourceNode _parent
 
List< ResourceNode_children = new List<ResourceNode>()
 
int _calcSize
 
EventHandler UpdateControl
 
MoveEventHandler MovedDown
 
ResourceEventHandler Renamed
 
ResourceEventHandler PropertyChanged
 
ResourceEventHandler Replaced
 
ResourceEventHandler Restored
 
ResourceChildEventHandler ChildRemoved
 
bool _isPopulating
 
bool _replaced
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.RSARFileNode
virtual void GetStrings (LabelBuilder builder)
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Function Documentation

◆ CreateStreams()

IAudioStream[] BrawlLib.SSBB.ResourceNodes.RSTMNode.CreateStreams ( )
inline

Implements BrawlLib.Internal.Audio.IAudioSource.

58 {
59 if (Header == null)
60 {
61 return null;
62 }
63
64 StrmDataInfo* info = Header->HEADData->Part1;
65 if (Header != null)
66 {
67 switch ((WaveEncoding) info->_format._encoding)
68 {
69 case WaveEncoding.ADPCM:
70 return ADPCMStream.GetStreams(Header, _audioSource.Address);
71 case WaveEncoding.PCM16:
72 return PCMStream.GetStreams(Header, _audioSource.Address);
73 }
74 }
75
76 return new IAudioStream[] {null};
77 }
Definition: PCMStream.cs:11
DataSource _audioSource
Definition: RSARFileNode.cs:15
Definition: IAudioStream.cs:6
WaveEncoding
Definition: RWAV.cs:176
VoidPtr Address
Definition: ResourceNode.cs:31

◆ Export()

override void BrawlLib.SSBB.ResourceNodes.RSTMNode.Export ( string  outPath)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

146 {
147 if (outPath.EndsWith(".wav"))
148 {
149 WAV.ToFile(CreateStreams()[0], outPath);
150 }
151 else
152 {
153 if (_audioSource != DataSource.Empty)
154 {
155 int size = WorkingUncompressed.Length + _audioSource.Length;
156 using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
157 FileShare.None))
158 {
159 stream.SetLength(size);
160 using (FileMap map = FileMap.FromStreamInternal(stream, FileMapProtect.ReadWrite, 0, size))
161 {
162 VoidPtr addr = map.Address;
163
164 //Write header
166
167 //Set the offset to the audio samples (_dataLocation)
168 RSTMHeader* hdr = (RSTMHeader*) addr;
169 hdr->_header._length = WorkingUncompressed.Length + _audioSource.Length;
170 hdr->DATAData->Set(_audioSource.Length + 0x20);
171
173
174 //Append audio samples to the end
176
177 if (outPath.EndsWith(".bcstm"))
178 {
180 byte[] bcstm_temp = CSTMConverter.FromRSTM(hdr);
181 fixed (byte* ptr = bcstm_temp)
182 {
183 Memory.Move(map.Address, ptr, (uint) bcstm_temp.Length);
184 }
185 }
186 else if (outPath.EndsWith(".bfstm"))
187 {
189 byte[] bfstm_temp = FSTMConverter.FromRSTM(hdr);
190 fixed (byte* ptr = bfstm_temp)
191 {
192 Memory.Move(map.Address, ptr, (uint) bfstm_temp.Length);
193 }
194 }
195 }
196 }
197 }
198 else
199 {
200 base.Export(outPath);
201 }
202 }
203 }
Definition: WAV.cs:212
static void ToFile(IAudioStream source, string path, int samplePosition=0, int maxSampleCount=int.MaxValue)
Definition: WAV.cs:218
Definition: FileMap.cs:10
static FileMap FromStreamInternal(FileStream stream, FileMapProtect prot, int offset, int length)
Definition: FileMap.cs:152
VoidPtr Address
Definition: FileMap.cs:16
Definition: Memory.cs:8
static void Move(VoidPtr dst, VoidPtr src, uint size)
Definition: Memory.cs:9
static void ShowADPCMConversionWarning()
Definition: RSTMNode.cs:135
IAudioStream[] CreateStreams()
Definition: RSTMNode.cs:57
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
Definition: CSTMConverter.cs:8
static unsafe byte[] FromRSTM(byte[] rstm)
Definition: CSTMConverter.cs:9
Definition: FSTMConverter.cs:8
static unsafe byte[] FromRSTM(byte[] rstm)
Definition: FSTMConverter.cs:9
FileMapProtect
Definition: FileMap.cs:175
Definition: VoidPtr.cs:9
int Length
Definition: ResourceNode.cs:32
static readonly DataSource Empty
Definition: ResourceNode.cs:29

◆ OnInitialize()

override bool BrawlLib.SSBB.ResourceNodes.RSTMNode.OnInitialize ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.NW4RNode.

80 {
81 if (_name == null && _origPath != null)
82 {
83 _name = Path.GetFileNameWithoutExtension(_origPath);
84 }
85
86 base.OnInitialize();
87
88 if (Header->_header._tag == CSTMHeader.Tag)
89 {
91 byte[] brstm_temp = CSTMConverter.ToRSTM((CSTMHeader*) Header);
92 fixed (byte* ptr = brstm_temp)
93 {
94 ReplaceRaw(ptr, brstm_temp.Length);
95 return false;
96 }
97 }
98
99 if (Header->_header._tag == FSTMHeader.Tag)
100 {
102 byte[] brstm_temp = FSTMConverter.ToRSTM((FSTMHeader*) Header);
103 fixed (byte* ptr = brstm_temp)
104 {
105 ReplaceRaw(ptr, brstm_temp.Length);
106 return false;
107 }
108 }
109
110 StrmDataInfo* part1 = Header->HEADData->Part1;
111
112 _encoding = part1->_format._encoding;
113 _channels = part1->_format._channels;
114 _looped = part1->_format._looped != 0;
115 _sampleRate = part1->_sampleRate;
116 _loopStart = part1->_loopStartSample;
117 _numSamples = part1->_numSamples;
118 _dataOffset = part1->_dataOffset;
119 _numBlocks = part1->_numBlocks;
120 _blockSize = part1->_blockSize;
121 _bps = part1->_bitsPerSample;
122
123 int offset = Header->DATAData->Data - Header;
124 if (offset < WorkingUncompressed.Length)
125 {
126 _audioSource = new DataSource(Header->DATAData->Data, WorkingUncompressed.Length - offset);
127 SetSizeInternal(offset);
128 }
129
130 return false;
131 }
void SetSizeInternal(int size)
Definition: ResourceNode.cs:799
virtual void ReplaceRaw(VoidPtr address, int length)
Definition: ResourceNode.cs:847
string _origPath
Definition: ResourceNode.cs:139
string _name
Definition: ResourceNode.cs:139
static unsafe byte[] ToRSTM(byte[] cstm)
Definition: CSTMConverter.cs:77
static unsafe byte[] ToRSTM(byte[] fstm)
Definition: FSTMConverter.cs:77

◆ Replace()

override void BrawlLib.SSBB.ResourceNodes.RSTMNode.Replace ( string  fileName)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

206 {
207 IAudioStream stream = null;
208
209 if (fileName.EndsWith(".wav"))
210 {
211 stream = WAV.FromFile(fileName);
212 }
213 else
214 {
215 base.Replace(fileName);
216 }
217
218 if (stream != null)
219 {
220 try
221 {
222 ReplaceRaw(RSTMConverter.Encode(stream, null));
223 }
224 finally
225 {
226 stream.Dispose();
227 }
228 }
229
230 if (Header->_header._tag == CSTMHeader.Tag || Header->_header._tag == FSTMHeader.Tag)
231 {
232 throw new NotImplementedException();
233 }
234
235 int offset = (int) Header->DATAData->Data - (int) Header;
236 if (offset < WorkingUncompressed.Length)
237 {
238 _audioSource = new DataSource(Header->DATAData->Data, WorkingUncompressed.Length - offset);
239 SetSizeInternal(offset);
240 }
241 }
static IAudioStream FromFile(string path)
Definition: WAV.cs:213
Definition: RSTMConverter.cs:12
static unsafe FileMap Encode(IAudioStream stream, IProgressTracker progress, WaveEncoding encoding=WaveEncoding.ADPCM)
Definition: RSTMConverter.cs:13

◆ ShowADPCMConversionWarning()

static void BrawlLib.SSBB.ResourceNodes.RSTMNode.ShowADPCMConversionWarning ( )
inlinestatic
136 {
138 {
140 System.Windows.Forms.MessageBox.Show(
141 "Note: FSTM and CSTM support is still in beta. Playback and output files might not be completely accurate.");
142 }
143 }
static bool ADPCMConversionWarningShown
Definition: RSTMNode.cs:133

Member Data Documentation

◆ ADPCMConversionWarningShown

bool BrawlLib.SSBB.ResourceNodes.RSTMNode.ADPCMConversionWarningShown
static

Property Documentation

◆ AudioLength

override string BrawlLib.SSBB.ResourceNodes.RSTMNode.AudioLength
get

◆ BitsPerSample

int BrawlLib.SSBB.ResourceNodes.RSTMNode.BitsPerSample
get

◆ BlockSize

int BrawlLib.SSBB.ResourceNodes.RSTMNode.BlockSize
get

◆ Channels

int BrawlLib.SSBB.ResourceNodes.RSTMNode.Channels
get

◆ DataLength

override string BrawlLib.SSBB.ResourceNodes.RSTMNode.DataLength
get

◆ Encoding

WaveEncoding BrawlLib.SSBB.ResourceNodes.RSTMNode.Encoding
get

◆ EntryRefs

override string [] BrawlLib.SSBB.ResourceNodes.RSTMNode.EntryRefs
get

◆ FileNodeIndex

override int BrawlLib.SSBB.ResourceNodes.RSTMNode.FileNodeIndex
get

◆ GroupRefs

override string [] BrawlLib.SSBB.ResourceNodes.RSTMNode.GroupRefs
get

◆ IsLooped

bool BrawlLib.SSBB.ResourceNodes.RSTMNode.IsLooped
get

◆ LoopStartSample

int BrawlLib.SSBB.ResourceNodes.RSTMNode.LoopStartSample
get

◆ NumBlocks

int BrawlLib.SSBB.ResourceNodes.RSTMNode.NumBlocks
get

◆ NumSamples

int BrawlLib.SSBB.ResourceNodes.RSTMNode.NumSamples
get

◆ ResourceFileType

override ResourceType BrawlLib.SSBB.ResourceNodes.RSTMNode.ResourceFileType
get

◆ SampleRate

int BrawlLib.SSBB.ResourceNodes.RSTMNode.SampleRate
get

The documentation for this class was generated from the following file: