Skip to content

Commit 91ec76b

Browse files
committed
additional sound metadata
1 parent cb87f50 commit 91ec76b

4 files changed

Lines changed: 24 additions & 19 deletions

File tree

CathodeLib/Scripts/CATHODE/SoundEnvironmentData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace CATHODE
1313
/* DATA/ENV/PRODUCTION/x/WORLD/SOUNDENVIRONMENTDATA.DAT */
1414
public class SoundEnvironmentData : CathodeFile
1515
{
16+
//This stores the reverbs that are used within the level. Similar to SoundLoadZones, these can be stored with spatial zones, but this feature is unused.
17+
1618
public List<string> Entries = new List<string>();
1719
public static new Implementation Implementation = Implementation.CREATE | Implementation.LOAD | Implementation.SAVE;
1820
public SoundEnvironmentData(string path) : base(path) { }
@@ -22,7 +24,7 @@ override protected bool LoadInternal()
2224
{
2325
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
2426
{
25-
reader.BaseStream.Position += 4;
27+
reader.BaseStream.Position += 4; //version
2628
int entryCount = reader.ReadInt32();
2729
for (int i = 0; i < entryCount; i++)
2830
{
@@ -32,6 +34,7 @@ override protected bool LoadInternal()
3234
Entries.Add(Utilities.ReadString(contentReader));
3335
}
3436
}
37+
reader.BaseStream.Position += 4; //zone count - always zero
3538
}
3639
return true;
3740
}
@@ -45,11 +48,8 @@ override protected bool SaveInternal()
4548
writer.Write(Entries.Count);
4649
for (int i = 0; i < Entries.Count; i++)
4750
{
48-
writer.Write(new byte[100]);
49-
long resetPos = writer.BaseStream.Position;
50-
writer.BaseStream.Position -= 100;
5151
Utilities.WriteString(Entries[i], writer);
52-
writer.BaseStream.Position = resetPos;
52+
writer.Write(new byte[100 - Entries[i].Length]);
5353
}
5454
writer.Write(0);
5555
}

CathodeLib/Scripts/CATHODE/SoundEventData.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace CATHODE
1313
/* DATA/ENV/PRODUCTION/x/WORLD/SOUNDEVENTDATA.DAT */
1414
public class SoundEventData : CathodeFile
1515
{
16+
//This stores all available sound events within soundbanks, along with their associated max attenuation and metadata (parameters)
17+
1618
public List<Soundbank> Entries = new List<Soundbank>();
1719
public static new Implementation Implementation = Implementation.CREATE | Implementation.LOAD | Implementation.SAVE;
1820
public SoundEventData(string path) : base(path) { }
@@ -22,17 +24,17 @@ override protected bool LoadInternal()
2224
{
2325
using (BinaryReader reader = new BinaryReader(File.OpenRead(_filepath)))
2426
{
25-
reader.BaseStream.Position += 4;
27+
reader.BaseStream.Position += 4; //version
2628
int entryCount = reader.ReadInt32();
2729
for (int i = 0; i < entryCount; i++)
2830
{
2931
Soundbank.Event e = new Soundbank.Event();
3032
int length = reader.ReadInt32();
3133
for (int x = 0; x < length; x++) e.name += reader.ReadChar();
3234
length = reader.ReadInt32();
33-
for (int x = 0; x < length; x++) e.args += reader.ReadChar();
34-
reader.BaseStream.Position += 2;
35-
e.unknown = reader.ReadInt16();
35+
for (int x = 0; x < length; x++) e.metadata += reader.ReadChar();
36+
37+
e.max_attenuation = reader.ReadSingle();
3638

3739
uint soundbankID = reader.ReadUInt32();
3840
Soundbank soundbank = Entries.FirstOrDefault(o => o.id == soundbankID);
@@ -53,20 +55,23 @@ override protected bool SaveInternal()
5355
{
5456
writer.BaseStream.SetLength(0);
5557
writer.Write(0);
56-
writer.Write(Entries.Count);
58+
writer.Write(0);
59+
int count = 0;
5760
for (int i = 0; i < Entries.Count; i++)
5861
{
5962
for (int x = 0; x < Entries[i].events.Count; x++)
6063
{
6164
writer.Write(Entries[i].events[x].name.Length);
6265
Utilities.WriteString(Entries[i].events[x].name, writer);
63-
writer.Write(Entries[i].events[x].args.Length);
64-
Utilities.WriteString(Entries[i].events[x].args, writer);
65-
writer.Write((Int16)0);
66-
writer.Write(Entries[i].events[x].unknown);
66+
writer.Write(Entries[i].events[x].metadata.Length);
67+
Utilities.WriteString(Entries[i].events[x].metadata, writer);
68+
writer.Write(Entries[i].events[x].max_attenuation);
6769
writer.Write(Entries[i].id);
70+
count++;
6871
}
6972
}
73+
writer.BaseStream.Position = 4;
74+
writer.Write(count);
7075
}
7176
return true;
7277
}
@@ -80,10 +85,9 @@ public class Soundbank
8085

8186
public class Event
8287
{
83-
public string name;
84-
public string args;
85-
86-
public int unknown;
88+
public string name = "";
89+
public string metadata = "";
90+
public float max_attenuation = 1024.0f;
8791
}
8892
};
8993
#endregion

CathodeLib/Scripts/CATHODE/SoundFlashModels.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ override protected bool SaveInternal()
4444
for (int i = 0; i < Entries.Count; i++)
4545
{
4646
writer.Write(Entries[i].flash_texture_id);
47+
writer.Write(Entries[i].model_indexes.Count);
4748
for (int x = 0; x < Entries[i].model_indexes.Count; x++)
4849
writer.Write(Entries[i].model_indexes[x]);
4950
}

CathodeLib/Scripts/CATHODE/SoundLoadZones.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CATHODE
1313
/* DATA/ENV/PRODUCTION/x/WORLD/SOUNDLOADZONES.DAT */
1414
public class SoundLoadZones : CathodeFile
1515
{
16-
//This seems to specify all the sound banks that are loaded within the level. They can be specified via spatial zones, but this feature is never used.
16+
//This specifies all the sound banks that are loaded within the level. They can be specified via spatial zones, but this feature is never used.
1717

1818
public List<string> Entries = new List<string>();
1919
public static new Implementation Implementation = Implementation.CREATE | Implementation.LOAD | Implementation.SAVE;

0 commit comments

Comments
 (0)