public override void Read(AssetReader reader) { base.Read(reader); if (IsReadLoadType(reader.Version)) { LoadType = (AudioClipLoadType)reader.ReadInt32(); Channels = reader.ReadInt32(); Frequency = reader.ReadInt32(); BitsPerSample = reader.ReadInt32(); Length = reader.ReadSingle(); if (IsReadIsTrackerFormat(reader.Version)) { IsTrackerFormat = reader.ReadBoolean(); } if (IsReadAmbisonic(reader.Version)) { Ambisonic = reader.ReadBoolean(); } if (IsAlignTrackerFormat(reader.Version)) { reader.AlignStream(AlignType.Align4); } if (IsReadAudioClipFlags(reader.Version)) { AudioClipFlags = reader.ReadInt32(); } if (IsReadFSBResourceFirst(reader.Version)) { FSBResource.Read(reader); } SubsoundIndex = reader.ReadInt32(); PreloadAudioData = reader.ReadBoolean(); LoadInBackground = reader.ReadBoolean(); Legacy3D = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); if (!IsReadFSBResourceFirst(reader.Version)) { FSBResource.Read(reader); } if (IsReadType(reader.Version)) { Type = (FMODSoundType)reader.ReadInt32(); } if (IsReadCompressionFormat(reader.Version)) { CompressionFormat = (AudioCompressionFormat)reader.ReadInt32(); } reader.AlignStream(AlignType.Align4); #if UNIVERSAL if (IsReadEditorResource(reader.Flags)) { EditorResource.Read(reader); if (IsReadCompressionFormat(reader.Version)) { EditorCompressionFormat = (AudioCompressionFormat)reader.ReadInt32(); } } #endif } else { if (IsReadDecompressOnLoadFirst(reader.Version)) { DecompressOnLoad = reader.ReadBoolean(); } Format = (FMODSoundFormat)reader.ReadInt32(); if (IsReadType(reader.Version)) { Type = (FMODSoundType)reader.ReadInt32(); } if (IsReadLength(reader.Version)) { Length = reader.ReadSingle(); Frequency = reader.ReadInt32(); Size = reader.ReadInt32(); } if (IsReadDecompressOnLoadSecond(reader.Version)) { DecompressOnLoad = reader.ReadBoolean(); } if (IsRead3D(reader.Version)) { Legacy3D = reader.ReadBoolean(); } if (IsReadUseHardware(reader.Version)) { UseHardware = reader.ReadBoolean(); } if (IsAlignBools(reader.Version)) { reader.AlignStream(AlignType.Align4); } if (IsStreamInt32(reader.Version)) { LoadType = (AudioClipLoadType)reader.ReadInt32(); } if (IsReadStreamingInfo(reader.Version)) { bool isInnerData = true; if (LoadType == AudioClipLoadType.Streaming) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, StreamingFileName)) { isInnerData = res == null; } } if (isInnerData) { m_audioData = reader.ReadByteArray(); reader.AlignStream(AlignType.Align4); } else { StreamingInfo.Read(reader, StreamingFileName); } } else { m_audioData = reader.ReadByteArray(); if (IsAlignAudioData(reader.Version)) { reader.AlignStream(AlignType.Align4); } } if (IsReadDecompressOnLoadThird(reader.Version)) { DecompressOnLoad = reader.ReadBoolean(); } if (IsReadStream(reader.Version)) { if (!IsStreamInt32(reader.Version)) { LoadType = reader.ReadBoolean() ? AudioClipLoadType.CompressedInMemory : AudioClipLoadType.DecompressOnLoad; } } } }
public override void Read(AssetStream stream) { base.Read(stream); if (IsReadLoadType(stream.Version)) { LoadType = (AudioClipLoadType)stream.ReadInt32(); Channels = stream.ReadInt32(); Frequency = stream.ReadInt32(); BitsPerSample = stream.ReadInt32(); Length = stream.ReadSingle(); if (IsReadIsTrackerFormat(stream.Version)) { IsTrackerFormat = stream.ReadBoolean(); } if (IsReadAmbisonic(stream.Version)) { Ambisonic = stream.ReadBoolean(); } if (IsAlignTrackerFormat(stream.Version)) { stream.AlignStream(AlignType.Align4); } if (IsReadAudioClipFlags(stream.Version)) { AudioClipFlags = stream.ReadInt32(); } if (IsReadFSBResourceFirst(stream.Version)) { FSBResource.Read(stream); } SubsoundIndex = stream.ReadInt32(); PreloadAudioData = stream.ReadBoolean(); LoadInBackground = stream.ReadBoolean(); Legacy3D = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); if (!IsReadFSBResourceFirst(stream.Version)) { FSBResource.Read(stream); } if (IsReadType(stream.Version)) { Type = (FMODSoundType)stream.ReadInt32(); } if (IsReadCompressionFormat(stream.Version)) { CompressionFormat = (AudioCompressionFormat)stream.ReadInt32(); } stream.AlignStream(AlignType.Align4); } else { if (IsReadDecompressOnLoadFirst(stream.Version)) { DecompressOnLoad = stream.ReadBoolean(); } Format = (FMODSoundFormat)stream.ReadInt32(); if (IsReadType(stream.Version)) { Type = (FMODSoundType)stream.ReadInt32(); } if (IsReadLength(stream.Version)) { Length = stream.ReadSingle(); Frequency = stream.ReadInt32(); Size = stream.ReadInt32(); } if (IsReadDecompressOnLoadSecond(stream.Version)) { DecompressOnLoad = stream.ReadBoolean(); } if (IsRead3D(stream.Version)) { Legacy3D = stream.ReadBoolean(); } if (IsReadUseHardware(stream.Version)) { UseHardware = stream.ReadBoolean(); } if (IsAlignBools(stream.Version)) { stream.AlignStream(AlignType.Align4); } if (IsStreamInt32(stream.Version)) { Stream = stream.ReadInt32(); } if (IsReadStreamingInfo(stream.Version)) { if (Stream == 2) { string resImageName = $"{File.Name}.resS"; StreamingInfo.Read(stream, resImageName); } else { m_audioData = stream.ReadByteArray(); stream.AlignStream(AlignType.Align4); } } else { m_audioData = stream.ReadByteArray(); if (IsAlignAudioData(stream.Version)) { stream.AlignStream(AlignType.Align4); } } if (IsReadDecompressOnLoadThird(stream.Version)) { DecompressOnLoad = stream.ReadBoolean(); } if (IsReadStream(stream.Version)) { if (!IsStreamInt32(stream.Version)) { Stream = stream.ReadBoolean() ? 1 : 0; } } } }
public override void Read(AssetReader reader) { base.Read(reader); if (HasLoadType(reader.Version)) { LoadType = (AudioClipLoadType)reader.ReadInt32(); Channels = reader.ReadInt32(); Frequency = reader.ReadInt32(); BitsPerSample = reader.ReadInt32(); Length = reader.ReadSingle(); if (HasIsTrackerFormat(reader.Version)) { IsTrackerFormat = reader.ReadBoolean(); } if (HasAmbisonic(reader.Version)) { Ambisonic = reader.ReadBoolean(); } if (IsAlignTrackerFormat(reader.Version)) { reader.AlignStream(); } if (HasAudioClipFlags(reader.Version)) { AudioClipFlags = reader.ReadInt32(); } if (IsFSBResourceFirst(reader.Version)) { FSBResource.Read(reader); } SubsoundIndex = reader.ReadInt32(); PreloadAudioData = reader.ReadBoolean(); LoadInBackground = reader.ReadBoolean(); Legacy3D = reader.ReadBoolean(); reader.AlignStream(); if (!IsFSBResourceFirst(reader.Version)) { FSBResource.Read(reader); } if (HasType(reader.Version)) { Type = (FMODSoundType)reader.ReadInt32(); } if (HasCompressionFormat(reader.Version)) { CompressionFormat = (AudioCompressionFormat)reader.ReadInt32(); } reader.AlignStream(); #if UNIVERSAL if (HasEditorResource(reader.Flags)) { EditorResource.Read(reader); if (HasCompressionFormat(reader.Version)) { EditorCompressionFormat = (AudioCompressionFormat)reader.ReadInt32(); } } #endif } else { int decompressionOrder = GetDecompressOnLoadOrder(reader.Version); if (decompressionOrder == 1) { DecompressOnLoad = reader.ReadBoolean(); } Format = (FMODSoundFormat)reader.ReadInt32(); if (HasType(reader.Version)) { Type = (FMODSoundType)reader.ReadInt32(); } if (HasLength(reader.Version)) { Length = reader.ReadSingle(); Frequency = reader.ReadInt32(); Size = reader.ReadInt32(); } if (decompressionOrder == 2) { DecompressOnLoad = reader.ReadBoolean(); } if (Has3D(reader.Version)) { Legacy3D = reader.ReadBoolean(); } if (HasUseHardware(reader.Version)) { UseHardware = reader.ReadBoolean(); } if (IsAlignBools(reader.Version)) { reader.AlignStream(); } if (IsStreamInt32(reader.Version)) { LoadType = (AudioClipLoadType)reader.ReadInt32(); } if (HasStreamingInfo(reader.Version)) { bool isInnerData = LoadType == AudioClipLoadType.Streaming ? File.Collection.FindResourceFile(StreamingFileName) == null : true; if (isInnerData) { AudioData = reader.ReadByteArray(); reader.AlignStream(); } else { StreamingInfo.Read(reader, StreamingFileName); } } else { AudioData = reader.ReadByteArray(); if (IsAlignAudioData(reader.Version)) { reader.AlignStream(); } } if (decompressionOrder == 3) { DecompressOnLoad = reader.ReadBoolean(); } if (HasStream(reader.Version)) { if (!IsStreamInt32(reader.Version)) { LoadType = reader.ReadBoolean() ? AudioClipLoadType.CompressedInMemory : AudioClipLoadType.DecompressOnLoad; } } } }