mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
- fixed a feature that automatically resizes asset Type and Size columns by content - fixed sorting issue when loading a new file/folder - asset list is now sorted by 2 columns, first by the column you click, then by the column you previously clicked
157 lines
5.3 KiB
C#
157 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Unity_Studio
|
|
{
|
|
class AudioClip
|
|
{
|
|
public string m_Name;
|
|
public int m_Format = 0;
|
|
public int m_Type;
|
|
public bool m_3D;
|
|
public bool m_UseHardware;
|
|
|
|
//Unity 5
|
|
public int m_LoadType;
|
|
public int m_Channels;
|
|
public int m_Frequency;
|
|
public int m_BitsPerSample;
|
|
public float m_Length;
|
|
public bool m_IsTrackerFormat;
|
|
public int m_SubsoundIndex;
|
|
public bool m_PreloadAudioData;
|
|
public bool m_LoadInBackground;
|
|
public bool m_Legacy3D;
|
|
public int m_CompressionFormat;
|
|
|
|
public string m_Source;
|
|
public long m_Offset;
|
|
public long m_Size;
|
|
public byte[] m_AudioData;
|
|
|
|
public string extension;
|
|
|
|
public AudioClip(AssetPreloadData preloadData, bool readSwitch)
|
|
{
|
|
var sourceFile = preloadData.sourceFile;
|
|
var a_Stream = preloadData.sourceFile.a_Stream;
|
|
a_Stream.Position = preloadData.Offset;
|
|
|
|
if (sourceFile.platform == -2)
|
|
{
|
|
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
|
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
|
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
|
}
|
|
|
|
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
|
|
|
if (sourceFile.version[0] < 5)
|
|
{
|
|
|
|
m_Format = a_Stream.ReadInt32(); //channels?
|
|
m_Type = a_Stream.ReadInt32();
|
|
m_3D = a_Stream.ReadBoolean();
|
|
m_UseHardware = a_Stream.ReadBoolean();
|
|
a_Stream.Position += 2; //4 byte alignment
|
|
|
|
if (sourceFile.version[0] >= 4 || (sourceFile.version[0] == 3 && sourceFile.version[1] >= 2)) //3.2.0 to 5
|
|
{
|
|
int m_Stream = a_Stream.ReadInt32();
|
|
m_Size = a_Stream.ReadInt32();
|
|
|
|
if (m_Stream > 1)
|
|
{
|
|
m_Offset = a_Stream.ReadInt32();
|
|
m_Source = sourceFile.filePath + ".resS";
|
|
}
|
|
}
|
|
else { m_Size = a_Stream.ReadInt32(); }
|
|
}
|
|
else
|
|
{
|
|
m_LoadType = a_Stream.ReadInt32();
|
|
m_Type = m_LoadType;
|
|
m_Channels = a_Stream.ReadInt32();
|
|
m_Frequency = a_Stream.ReadInt32();
|
|
m_BitsPerSample = a_Stream.ReadInt32();
|
|
m_Length = a_Stream.ReadSingle();
|
|
m_IsTrackerFormat = a_Stream.ReadBoolean();
|
|
a_Stream.Position += 3;
|
|
m_SubsoundIndex = a_Stream.ReadInt32();
|
|
m_PreloadAudioData = a_Stream.ReadBoolean();
|
|
m_LoadInBackground = a_Stream.ReadBoolean();
|
|
m_Legacy3D = a_Stream.ReadBoolean();
|
|
a_Stream.Position += 1;
|
|
m_3D = m_Legacy3D;
|
|
|
|
m_Source = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
|
//m_Source = Path.GetFileName(m_Source);
|
|
m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/",""));
|
|
m_Offset = a_Stream.ReadInt64();
|
|
m_Size = a_Stream.ReadInt64();
|
|
m_CompressionFormat = a_Stream.ReadInt32();
|
|
}
|
|
|
|
#region Info Text & extension
|
|
preloadData.InfoText = "Format: " + m_Format + "\nType: ";
|
|
|
|
switch (m_Type)
|
|
{
|
|
case 1:
|
|
extension = ".fsb";
|
|
preloadData.InfoText += "FSB";
|
|
break;
|
|
case 2://FSB5
|
|
extension = ".fsb";
|
|
preloadData.InfoText += "FSB";
|
|
break;
|
|
case 13:
|
|
extension = ".mp3";
|
|
preloadData.InfoText += "MP3";
|
|
break;
|
|
case 14:
|
|
extension = ".ogg";
|
|
preloadData.InfoText += "Ogg Vorbis";
|
|
break;
|
|
case 20:
|
|
extension = ".wav";
|
|
preloadData.InfoText += "WAV";
|
|
break;
|
|
case 22: //xbox encoding
|
|
extension = ".wav";
|
|
preloadData.InfoText += "Xbox360 WAV";
|
|
break;
|
|
default:
|
|
preloadData.InfoText += "Unknown type " + m_Type;
|
|
break;
|
|
}
|
|
|
|
preloadData.InfoText += "\n3D: " + m_3D.ToString();
|
|
#endregion
|
|
|
|
if (readSwitch)
|
|
{
|
|
m_AudioData = new byte[m_Size];
|
|
|
|
if (m_Source == null)
|
|
{
|
|
a_Stream.Read(m_AudioData, 0, (int)m_Size);
|
|
}
|
|
else if (File.Exists(m_Source))
|
|
{
|
|
using (BinaryReader reader = new BinaryReader(File.OpenRead(m_Source)))
|
|
{
|
|
reader.BaseStream.Position = m_Offset;
|
|
reader.Read(m_AudioData, 0, (int)m_Size);
|
|
reader.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|