Skip to content

Commit

Permalink
Fix export position of audio instances
Browse files Browse the repository at this point in the history
  • Loading branch information
danwilkins committed Jul 19, 2023
1 parent 643f1dc commit f3d8542
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions LanternExtractor/EQ/Sound/EffSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Initialize(ILogger logger)

if (fileLength % EntryLengthInBytes != 0)
{
logger.LogError($"Incorrect .eff file - size must be multiple of {EntryLengthInBytes}");
logger.LogError($"Invalid .eff file - size must be multiple of {EntryLengthInBytes}");
return;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public void ExportSoundData(string zoneName, string rootFolder)
continue;
}

musicExport.AppendLine(string.Join(",", music.PosX, music.PosY, music.PosZ, music.Radius,
musicExport.AppendLine(string.Join(",", music.PosX, music.PosZ, music.PosY, music.Radius,
music.TrackIndexDay, music.TrackIndexNight, music.LoopCountDay, music.LoopCountNight,
music.FadeOutMs));
}
Expand All @@ -189,8 +189,8 @@ public void ExportSoundData(string zoneName, string rootFolder)
continue;
}

sound2dExport.AppendLine(string.Join(",", sound2d.PosX, sound2d.PosY,
sound2d.PosZ, sound2d.Radius, sound2d.Sound1, sound2d.Sound2,
sound2dExport.AppendLine(string.Join(",", sound2d.PosX, sound2d.PosZ,
sound2d.PosY, sound2d.Radius, sound2d.Sound1, sound2d.Sound2,
sound2d.Cooldown1, sound2d.Cooldown2, sound2d.CooldownRandom, sound2d.Volume1, sound2d.Volume2));
}
else
Expand All @@ -200,8 +200,8 @@ public void ExportSoundData(string zoneName, string rootFolder)
continue;
}

sound3dExport.AppendLine(string.Join(",", sound3d.PosX, sound3d.PosY,
sound3d.PosZ, sound3d.Radius, sound3d.Sound1, sound3d.Cooldown1, sound3d.CooldownRandom, sound3d.Volume1,
sound3dExport.AppendLine(string.Join(",", sound3d.PosX, sound3d.PosZ,
sound3d.PosY, sound3d.Radius, sound3d.Sound1, sound3d.Cooldown1, sound3d.CooldownRandom, sound3d.Volume1,
sound3d.Multiplier));
}
}
Expand Down
10 changes: 7 additions & 3 deletions LanternExtractor/EQ/Sound/SoundTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ public static class SoundTest
{
public static void OutputSingleInstance(BinaryWriter writer, int index, string fileName)
{
writer.BaseStream.Position = 0;
var memoryStream = new MemoryStream();
writer.BaseStream.CopyTo(memoryStream);
File.WriteAllBytes(fileName,
memoryStream.ToArray().Skip(index * EffSounds.EntryLengthInBytes).Take(EffSounds.EntryLengthInBytes).ToArray());
var bytes = memoryStream.ToArray().Skip(index * EffSounds.EntryLengthInBytes)
.Take(EffSounds.EntryLengthInBytes).ToArray();
File.WriteAllBytes(fileName, bytes);
}

public static void ModifyInstance(BinaryWriter writer, int index, string fileName)
public static void ModifyInstance(BinaryWriter writer, string fileName)
{
writer.BaseStream.Position = 16; // positions
writer.Write(0f);
writer.Write(0f);
writer.Write(50f);


writer.BaseStream.Position = 0;
var memoryStream = new MemoryStream();
writer.BaseStream.CopyTo(memoryStream);
File.WriteAllBytes(fileName, memoryStream.ToArray());
Expand Down

0 comments on commit f3d8542

Please sign in to comment.