mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-15 13:46:44 +00:00
Port PlayJ to new printing
This commit is contained in:
200
BinaryObjectScanner.Printing/PlayJAudioFile.cs
Normal file
200
BinaryObjectScanner.Printing/PlayJAudioFile.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.PlayJ;
|
||||
|
||||
namespace BinaryObjectScanner.Printing
|
||||
{
|
||||
public static class PlayJAudioFile
|
||||
{
|
||||
public static void Print(StringBuilder builder, AudioFile audio)
|
||||
{
|
||||
builder.AppendLine("PlayJ Audio File Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
Print(builder, audio.Header);
|
||||
Print(builder, audio.UnknownBlock1);
|
||||
|
||||
if (audio.Header?.Version == 0x00000000)
|
||||
{
|
||||
Print(builder, audio.UnknownValue2);
|
||||
Print(builder, audio.UnknownBlock3);
|
||||
}
|
||||
else if (audio.Header?.Version == 0x0000000A)
|
||||
{
|
||||
Print(builder, audio.DataFilesCount, audio.DataFiles);
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, AudioHeader header)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, AudioHeader? header)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Audio Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No audio header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.Version, " Version");
|
||||
if (header.Version == 0x00000000 && header is AudioHeaderV1 headerV1)
|
||||
{
|
||||
builder.AppendLine(headerV1.TrackID, " Track ID");
|
||||
builder.AppendLine(headerV1.UnknownOffset1, " Unknown offset 1");
|
||||
builder.AppendLine(headerV1.UnknownOffset2, " Unknown offset 2");
|
||||
builder.AppendLine(headerV1.UnknownOffset3, " Unknown offset 3");
|
||||
builder.AppendLine(headerV1.Unknown1, " Unknown 1");
|
||||
builder.AppendLine(headerV1.Unknown2, " Unknown 2");
|
||||
builder.AppendLine(headerV1.Year, " Year");
|
||||
builder.AppendLine(headerV1.TrackNumber, " Track number");
|
||||
builder.AppendLine($" Subgenre: {headerV1.Subgenre} (0x{headerV1.Subgenre:X})");
|
||||
builder.AppendLine(headerV1.Duration, " Duration in seconds");
|
||||
}
|
||||
else if (header.Version == 0x0000000A && header is AudioHeaderV2 headerV2)
|
||||
{
|
||||
builder.AppendLine(headerV2.Unknown1, " Unknown 1");
|
||||
builder.AppendLine(headerV2.Unknown2, " Unknown 2");
|
||||
builder.AppendLine(headerV2.Unknown3, " Unknown 3");
|
||||
builder.AppendLine(headerV2.Unknown4, " Unknown 4");
|
||||
builder.AppendLine(headerV2.Unknown5, " Unknown 5");
|
||||
builder.AppendLine(headerV2.Unknown6, " Unknown 6");
|
||||
builder.AppendLine(headerV2.UnknownOffset1, " Unknown Offset 1");
|
||||
builder.AppendLine(headerV2.Unknown7, " Unknown 7");
|
||||
builder.AppendLine(headerV2.Unknown8, " Unknown 8");
|
||||
builder.AppendLine(headerV2.Unknown9, " Unknown 9");
|
||||
builder.AppendLine(headerV2.UnknownOffset2, " Unknown Offset 2");
|
||||
builder.AppendLine(headerV2.Unknown10, " Unknown 10");
|
||||
builder.AppendLine(headerV2.Unknown11, " Unknown 11");
|
||||
builder.AppendLine(headerV2.Unknown12, " Unknown 12");
|
||||
builder.AppendLine(headerV2.Unknown13, " Unknown 13");
|
||||
builder.AppendLine(headerV2.Unknown14, " Unknown 14");
|
||||
builder.AppendLine(headerV2.Unknown15, " Unknown 15");
|
||||
builder.AppendLine(headerV2.Unknown16, " Unknown 16");
|
||||
builder.AppendLine(headerV2.Unknown17, " Unknown 17");
|
||||
builder.AppendLine(headerV2.TrackID, " Track ID");
|
||||
builder.AppendLine(headerV2.Year, " Year");
|
||||
builder.AppendLine(headerV2.TrackNumber, " Track number");
|
||||
builder.AppendLine(headerV2.Unknown18, " Unknown 18");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(" Unrecognized version, not parsed...");
|
||||
}
|
||||
|
||||
builder.AppendLine(header.TrackLength, " Track length");
|
||||
builder.AppendLine(header.Track, " Track");
|
||||
builder.AppendLine(header.ArtistLength, " Artist length");
|
||||
builder.AppendLine(header.Artist, " Artist");
|
||||
builder.AppendLine(header.AlbumLength, " Album length");
|
||||
builder.AppendLine(header.Album, " Album");
|
||||
builder.AppendLine(header.WriterLength, " Writer length");
|
||||
builder.AppendLine(header.Writer, " Writer");
|
||||
builder.AppendLine(header.PublisherLength, " Publisher length");
|
||||
builder.AppendLine(header.Publisher, " Publisher");
|
||||
builder.AppendLine(header.LabelLength, " Label length");
|
||||
builder.AppendLine(header.Label, " Label");
|
||||
builder.AppendLine(header.CommentsLength, " Comments length");
|
||||
builder.AppendLine(header.Comments, " Comments");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownBlock1 block)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownBlock1? block)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 1 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (block == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(block.Length, " Length");
|
||||
builder.AppendLine(block.Data, " Data");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, uint value)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, uint? value)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Value 2 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
builder.AppendLine(value, " Value");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, UnknownBlock3 block)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, UnknownBlock3? block)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 3 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (block == null)
|
||||
{
|
||||
builder.AppendLine(" No unknown block 1r");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(block.Data, " Data");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
private static void Print(StringBuilder builder, uint count, DataFile[] entries)
|
||||
#else
|
||||
private static void Print(StringBuilder builder, uint count, DataFile?[]? entries)
|
||||
#endif
|
||||
{
|
||||
builder.AppendLine(" Data Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine(count, " Data files count");
|
||||
if (count == 0 || entries == null || entries.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No data files");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
builder.AppendLine($" Data File {i}:");
|
||||
if (entry == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.FileNameLength, " File name length");
|
||||
builder.AppendLine(entry.FileName, " File name");
|
||||
builder.AppendLine(entry.DataLength, " Data length");
|
||||
builder.AppendLine(entry.Data, " Data");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
@@ -388,164 +387,10 @@ namespace BinaryObjectScanner.Wrappers
|
||||
public override StringBuilder PrettyPrint()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.AppendLine("PlayJ Audio File Information:");
|
||||
builder.AppendLine("-------------------------");
|
||||
builder.AppendLine();
|
||||
|
||||
PrintAudioHeader(builder);
|
||||
PrintUnknownBlock1(builder);
|
||||
|
||||
if (Version == 0x00000000)
|
||||
{
|
||||
PrintUnknownValue2(builder);
|
||||
PrintUnknownBlock3(builder);
|
||||
}
|
||||
else if (Version == 0x0000000A)
|
||||
{
|
||||
PrintDataFiles(builder);
|
||||
}
|
||||
|
||||
Printing.PlayJAudioFile.Print(builder, _model);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print audio header information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintAudioHeader(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Audio Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Signature: {Signature} (0x{Signature:X})");
|
||||
builder.AppendLine($" Version: {Version} (0x{Version:X})");
|
||||
if (Version == 0x00000000)
|
||||
{
|
||||
builder.AppendLine($" Track ID: {V1_TrackID} (0x{V1_TrackID:X})");
|
||||
builder.AppendLine($" Unknown offset 1: {V1_UnknownOffset1} (0x{V1_UnknownOffset1:X})");
|
||||
builder.AppendLine($" Unknown offset 2: {V1_UnknownOffset2} (0x{V1_UnknownOffset2:X})");
|
||||
builder.AppendLine($" Unknown offset 3: {V1_UnknownOffset3} (0x{V1_UnknownOffset3:X})");
|
||||
builder.AppendLine($" Unknown 1: {V1_Unknown1} (0x{V1_Unknown1:X})");
|
||||
builder.AppendLine($" Unknown 2: {V1_Unknown2} (0x{V1_Unknown2:X})");
|
||||
builder.AppendLine($" Year: {V1_Year} (0x{V1_Year:X})");
|
||||
builder.AppendLine($" Track number: {V1_TrackNumber} (0x{V1_TrackNumber:X})");
|
||||
builder.AppendLine($" Subgenre: {V1_Subgenre} (0x{V1_Subgenre:X})");
|
||||
builder.AppendLine($" Duration in seconds: {V1_Duration} (0x{V1_Duration:X})");
|
||||
}
|
||||
else if (Version == 0x0000000A)
|
||||
{
|
||||
builder.AppendLine($" Unknown 1: {V2_Unknown1} (0x{V2_Unknown1:X})");
|
||||
builder.AppendLine($" Unknown 2: {V2_Unknown2} (0x{V2_Unknown2:X})");
|
||||
builder.AppendLine($" Unknown 3: {V2_Unknown3} (0x{V2_Unknown3:X})");
|
||||
builder.AppendLine($" Unknown 4: {V2_Unknown4} (0x{V2_Unknown4:X})");
|
||||
builder.AppendLine($" Unknown 5: {V2_Unknown5} (0x{V2_Unknown5:X})");
|
||||
builder.AppendLine($" Unknown 6: {V2_Unknown6} (0x{V2_Unknown6:X})");
|
||||
builder.AppendLine($" Unknown Offset 1: {V2_UnknownOffset1} (0x{V2_UnknownOffset1:X})");
|
||||
builder.AppendLine($" Unknown 7: {V2_Unknown7} (0x{V2_Unknown7:X})");
|
||||
builder.AppendLine($" Unknown 8: {V2_Unknown8} (0x{V2_Unknown8:X})");
|
||||
builder.AppendLine($" Unknown 9: {V2_Unknown9} (0x{V2_Unknown9:X})");
|
||||
builder.AppendLine($" Unknown Offset 2: {V2_UnknownOffset2} (0x{V2_UnknownOffset2:X})");
|
||||
builder.AppendLine($" Unknown 10: {V2_Unknown10} (0x{V2_Unknown10:X})");
|
||||
builder.AppendLine($" Unknown 11: {V2_Unknown11} (0x{V2_Unknown11:X})");
|
||||
builder.AppendLine($" Unknown 12: {V2_Unknown12} (0x{V2_Unknown12:X})");
|
||||
builder.AppendLine($" Unknown 13: {V2_Unknown13} (0x{V2_Unknown13:X})");
|
||||
builder.AppendLine($" Unknown 14: {V2_Unknown14} (0x{V2_Unknown14:X})");
|
||||
builder.AppendLine($" Unknown 15: {V2_Unknown15} (0x{V2_Unknown15:X})");
|
||||
builder.AppendLine($" Unknown 16: {V2_Unknown16} (0x{V2_Unknown16:X})");
|
||||
builder.AppendLine($" Unknown 17: {V2_Unknown17} (0x{V2_Unknown17:X})");
|
||||
builder.AppendLine($" Track ID: {V2_TrackID} (0x{V2_TrackID:X})");
|
||||
builder.AppendLine($" Year: {V2_Year} (0x{V2_Year:X})");
|
||||
builder.AppendLine($" Track number: {V2_TrackNumber} (0x{V2_TrackNumber:X})");
|
||||
builder.AppendLine($" Unknown 18: {V2_Unknown18} (0x{V2_Unknown18:X})");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine($" Unrecognized version, not parsed...");
|
||||
}
|
||||
builder.AppendLine($" Track length: {TrackLength} (0x{TrackLength:X})");
|
||||
builder.AppendLine($" Track: {Track ?? "[NULL]"}");
|
||||
builder.AppendLine($" Artist length: {ArtistLength} (0x{ArtistLength:X})");
|
||||
builder.AppendLine($" Artist: {Artist ?? "[NULL]"}");
|
||||
builder.AppendLine($" Album length: {AlbumLength} (0x{AlbumLength:X})");
|
||||
builder.AppendLine($" Album: {Album ?? "[NULL]"}");
|
||||
builder.AppendLine($" Writer length: {WriterLength} (0x{WriterLength:X})");
|
||||
builder.AppendLine($" Writer: {Writer ?? "[NULL]"}");
|
||||
builder.AppendLine($" Publisher length: {PublisherLength} (0x{PublisherLength:X})");
|
||||
builder.AppendLine($" Publisher: {Publisher ?? "[NULL]"}");
|
||||
builder.AppendLine($" Label length: {LabelLength} (0x{LabelLength:X})");
|
||||
builder.AppendLine($" Label: {Label ?? "[NULL]"}");
|
||||
builder.AppendLine($" Comments length: {CommentsLength} (0x{CommentsLength:X})");
|
||||
builder.AppendLine($" Comments: {Comments ?? "[NULL]"}");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print unknown block 1 information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintUnknownBlock1(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 1 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Length: {UB1_Length} (0x{UB1_Length:X})");
|
||||
builder.AppendLine($" Data: {(UB1_Data == null ? "[NULL]" : BitConverter.ToString(UB1_Data).Replace('-', ' '))}");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print unknown value 2 information (V1 only)
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintUnknownValue2(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Unknown Value 2 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Value: {UnknownValue2} (0x{UnknownValue2:X})");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print unknown block 3 information (V1 only)
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintUnknownBlock3(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Unknown Block 3 Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Data: {(UB3_Data == null ? "[NULL]" : BitConverter.ToString(UB3_Data).Replace('-', ' '))}");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print data files information (V2 only)
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintDataFiles(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Data Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Data files count: {DataFilesCount} (0x{DataFilesCount:X})");
|
||||
if (DataFilesCount != 0 && DataFiles != null && DataFiles.Length != 0)
|
||||
{
|
||||
for (int i = 0; i < DataFiles.Length; i++)
|
||||
{
|
||||
var dataFile = DataFiles[i];
|
||||
builder.AppendLine($" Data File {i}:");
|
||||
if (dataFile == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.AppendLine($" File name length: {dataFile.FileNameLength} (0x{dataFile.FileNameLength:X})");
|
||||
builder.AppendLine($" File name: {dataFile.FileName ?? "[NULL]"}");
|
||||
builder.AppendLine($" Data length: {dataFile.DataLength} (0x{dataFile.DataLength:X})");
|
||||
builder.AppendLine($" Data: {(dataFile.Data == null ? "[NULL]" : BitConverter.ToString(dataFile.Data).Replace('-', ' '))}");
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
Reference in New Issue
Block a user