public int GetLength() { int length = 5; if (SettingsObject != null) { length += SettingsObject.GetLength(); } else if (SoundSFXObject != null) { length += SoundSFXObject.GetLength(); } else if (EventAction != null) { length += EventAction.GetLength(); } else if (Event != null) { length += Event.GetLength(); } else if (RandomContainer != null) { length += RandomContainer.GetLength(); } else if (SwitchContainer != null) { length += SwitchContainer.GetLength(); } else if (ActorMixer != null) { length += ActorMixer.GetLength(); } else if (AudioBus != null) { length += AudioBus.GetLength(); } else if (BlendContainer != null) { length += BlendContainer.GetLength(); } else if (MusicSegment != null) { length += MusicSegment.GetLength(); } else if (MusicTrack != null) { length += MusicTrack.GetLength(); } else if (MusicSwitchContainer != null) { length += MusicSwitchContainer.GetLength(); } else if (MusicSequence != null) { length += MusicSequence.GetLength(); } else if (Attenuation != null) { length += Attenuation.GetLength(); } else if (FeedbackNode != null) { length += FeedbackNode.GetLength(); } else if (FxShareSet != null) { length += FxShareSet.GetLength(); } else if (FxCustom != null) { length += FxCustom.GetLength(); } else if (AuxiliaryBus != null) { length += AuxiliaryBus.GetLength(); } else if (LFO != null) { length += LFO.GetLength(); } else if (Envelope != null) { length += Envelope.GetLength(); } else if (FeedbackBus != null) { length += FeedbackBus.GetLength(); } else { if (Data != null) { length += Data.Length; } else { length = -1; } } return(length); }
public HIRCObject(BNK mainBnk, BinaryReader br) { Bnk = mainBnk; if (!hircError.errorOccured) { int type = br.ReadByte(); LastPos = br.BaseStream.Position; switch (type) { case 1: SettingsObject = new Settings(br, type); break; case 2: SoundSFXObject = new SoundSFX(this, br, type); break; case 3: EventAction = new EventAction(this, br, type); break; case 4: Event = new Event(this, br, type); break; case 5: RandomContainer = new RandomContainer(this, br, type); break; case 6: SwitchContainer = new SwitchContainer(this, br, type); break; case 7: ActorMixer = new ActorMixer(this, br, type); break; case 8: AudioBus = new AudioBus(this, br, type); break; case 9: BlendContainer = new BlendContainer(this, br, type); break; case 10: MusicSegment = new MusicSegment(this, br, type); break; case 11: MusicTrack = new MusicTrack(this, br, type); break; case 12: MusicSwitchContainer = new MusicSwitchContainer(this, br, type); break; case 13: MusicSequence = new MusicSequence(this, br, type); break; case 14: Attenuation = new Attenuation(br, type); break; case 16: FeedbackBus = new FeedbackBus(this, br, type); break; case 17: FeedbackNode = new FeedbackNode(this, br, type); break; case 18: FxShareSet = new FxShareSet(this, br, type); break; case 19: FxCustom = new FxCustom(this, br, type); break; case 20: AuxiliaryBus = new AuxiliaryBus(this, br, type); break; case 21: LFO = new LFO(br, type); break; case 22: Envelope = new Envelope(br, type); break; default: int length = br.ReadInt32(); br.BaseStream.Position -= 5; Data = br.ReadBytes(length + 5); System.Windows.MessageBox.Show("Detected unkown HIRC Object type at: " + (LastPos - 1).ToString("X"), "Toolkit"); break; } } }
public static MusicSwitchContainer ParseMusicSwitchContainer(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { var musicSwitchContainer = new MusicSwitchContainer(data.Length); musicSwitchContainer.Id = reader.ReadUInt32(); musicSwitchContainer.MidiBehavior = (MidiInteractiveMusicBehavior)reader.ReadByte(); musicSwitchContainer.Properties = reader.ReadAudioProperties(); musicSwitchContainer.ChildCount = reader.ReadUInt32(); musicSwitchContainer.ChildIds = new uint[musicSwitchContainer.ChildCount]; for (var i = 0; i < musicSwitchContainer.ChildCount; i++) { musicSwitchContainer.ChildIds[i] = reader.ReadUInt32(); } musicSwitchContainer.GridPeriodTime = reader.ReadDouble(); musicSwitchContainer.GridOffsetTime = reader.ReadDouble(); musicSwitchContainer.Tempo = reader.ReadSingle(); musicSwitchContainer.TimeSignatureUpper = reader.ReadByte(); musicSwitchContainer.TimeSignatureLower = reader.ReadByte(); musicSwitchContainer.Unknown_1 = reader.ReadByte(); musicSwitchContainer.StingerCount = reader.ReadUInt32(); musicSwitchContainer.Stingers = new Stinger[musicSwitchContainer.StingerCount]; for (var i = 0; i < musicSwitchContainer.StingerCount; i++) { Stinger stinger = default; stinger.TriggerId = reader.ReadUInt32(); stinger.SegmentId = reader.ReadUInt32(); stinger.PlayAt = (StingerKeyPoint)reader.ReadUInt32(); stinger.CueId = reader.ReadUInt32(); stinger.DoNotRepeatIn = reader.ReadUInt32(); stinger.AllowPlayingInNextSegment = reader.ReadBoolean(); musicSwitchContainer.Stingers[i] = stinger; } musicSwitchContainer.TransitionCount = reader.ReadUInt32(); musicSwitchContainer.Transitions = new Transition[musicSwitchContainer.TransitionCount]; for (var i = 0; i < musicSwitchContainer.TransitionCount; i++) { Transition transition = default; transition.Unknown_1 = reader.ReadUInt32(); transition.SourceId = reader.ReadUInt32(); transition.Unknown_2 = reader.ReadUInt32(); transition.DestinationId = reader.ReadUInt32(); transition.FadeOutDuration = reader.ReadUInt32(); transition.FadeOutCurveShape = (BlendCurveShape)reader.ReadUInt32(); transition.FadeOutOffset = reader.ReadInt32(); transition.ExitSourceAt = (InteractiveMusicKeyPoint)reader.ReadUInt32(); transition.ExitSourceAtCueId = reader.ReadUInt32(); transition.PlayPostExit = reader.ReadByte() == 0xFF; transition.FadeInDuration = reader.ReadUInt32(); transition.FadeInCurveShape = (BlendCurveShape)reader.ReadUInt32(); transition.FadeInOffset = reader.ReadInt32(); transition.CustomCueFilterId = reader.ReadUInt32(); transition.JumpToPlaylistItemId = reader.ReadUInt32(); transition.DestinationSyncTo = (DestinationSyncTarget)reader.ReadUInt16(); transition.PlayPreEntry = reader.ReadByte() == 0xFF; transition.MatchSourceCueName = reader.ReadBoolean(); transition.UseTransitionSegment = reader.ReadBoolean(); if (transition.UseTransitionSegment) { transition.TransitionSegmentId = reader.ReadUInt32(); transition.TransitionFadeInDuration = reader.ReadUInt32(); transition.TransitionFadeInCurveShape = (BlendCurveShape)reader.ReadUInt32(); transition.TransitionFadeInOffset = reader.ReadInt32(); transition.TransitionFadeOutDuration = reader.ReadUInt32(); transition.TransitionFadeOutCurveShape = (BlendCurveShape)reader.ReadUInt32(); transition.TransitionFadeOutOffset = reader.ReadInt32(); transition.PlayTransitionPreEntry = reader.ReadByte() == 0xFF; transition.PlayTransitionPostExit = reader.ReadByte() == 0xFF; } musicSwitchContainer.Transitions[i] = transition; } musicSwitchContainer.ContinueOnSwitchChange = reader.ReadBoolean(); musicSwitchContainer.GroupCount = reader.ReadUInt32(); musicSwitchContainer.GroupIds = new uint[musicSwitchContainer.GroupCount]; for (var i = 0; i < musicSwitchContainer.GroupCount; i++) { musicSwitchContainer.GroupIds[i] = reader.ReadUInt32(); } musicSwitchContainer.GroupTypes = new GroupType[musicSwitchContainer.GroupCount]; for (var i = 0; i < musicSwitchContainer.GroupCount; i++) { musicSwitchContainer.GroupTypes[i] = (GroupType)reader.ReadByte(); } musicSwitchContainer.PathSectionLength = reader.ReadUInt32(); musicSwitchContainer.AssociationMode = (AssociationMode)reader.ReadByte(); musicSwitchContainer.Paths = reader.ReadPaths(musicSwitchContainer.PathSectionLength, musicSwitchContainer.ChildIds); return(musicSwitchContainer); } }