// Use this for initialization void Start() { SpriteRenderer sprite = GetComponent <SpriteRenderer>(); sprite.color = initialColor; // TODO: give triggeredSounds its own tag // since we need GameController for other things. sb = GameObject.FindGameObjectWithTag("GameController").GetComponent <soundBank>(); this.transform.localScale = new Vector3(2, 2, 1); }
private void GatherSoundBanks(BinaryReader br) { soundBankList.Clear(); UInt32 soundBankCount = br.ReadUInt32(); for (int i = 0; i < soundBankCount; i++) { soundBank soundBank = new soundBank(); soundBank.id = br.ReadUInt32(); soundBank.idString = "0x" + soundBank.id.ToString("X8"); UInt32 soundBankOffsetMult = br.ReadUInt32(); UInt32 soundBankSize = br.ReadUInt32(); soundBank.headerOffset = br.ReadUInt32() * soundBankOffsetMult; UInt32 soundBankFolder = br.ReadUInt32(); string soundBankFolderName = (string)folderHashTable[soundBankFolder]; soundBank.relativePath = soundBankFolderName + "\\" + baseName + "\\" + "SoundBank (" + soundBank.idString + ")\\"; UInt32 soundBankTempPos = (UInt32)br.BaseStream.Position; br.BaseStream.Seek(soundBank.headerOffset, 0); br.ReadUInt32(); soundBank.headerSize = br.ReadUInt32() + 8; UInt32 firstBankSectionPos = soundBank.headerOffset + soundBank.headerSize; br.BaseStream.Seek(firstBankSectionPos, 0); string firstSectionIdent = new string(br.ReadChars(4)); if (firstSectionIdent == @"DIDX") { UInt32 didxSize = br.ReadUInt32(); UInt32 didxFilesCount = didxSize / 12; UInt32 dataFilesOffset = firstBankSectionPos + didxSize + 16; for (int j = 0; j < didxFilesCount; j++) { soundFile soundFile = new soundFile(); soundFile.id = br.ReadUInt32(); soundFile.idString = "0x" + soundFile.id.ToString("X8"); soundFile.fileOffset = br.ReadUInt32() + dataFilesOffset; soundFile.fileSize = br.ReadUInt32(); soundFile.relativePath = soundBank.relativePath; soundFileList.Add(soundFile); } br.BaseStream.Seek(firstBankSectionPos + didxSize + 12, 0); UInt32 dataSectionSize = br.ReadUInt32(); br.ReadBytes((int)dataSectionSize + 4); } soundBank.hircOffset = (UInt32)br.BaseStream.Position - 4; soundBank.hircSize = br.ReadUInt32() + 8; br.BaseStream.Seek(soundBankTempPos, 0); soundBankList.Add(soundBank); } }
private void GatherSoundBanks(BinaryReader br) { UInt32 soundBankCount = br.ReadUInt32(); for (int i = 0; i < soundBankCount; i++) { soundBank soundBank = new soundBank(); // Sound Bank info soundBank.id = br.ReadUInt32(); soundBank.idString = "0x" + soundBank.id.ToString("X8"); UInt32 soundBankOffsetMult = br.ReadUInt32(); UInt32 soundBankSize = br.ReadUInt32(); soundBank.headerOffset = br.ReadUInt32() * soundBankOffsetMult; UInt32 soundBankFolder = br.ReadUInt32(); string soundBankFolderName = (string)folderHashTable[soundBankFolder]; soundBank.relativePath = soundBankFolderName + "\\" + baseName + "\\" + "SoundBank (" + soundBank.idString + ")\\"; UInt32 soundBankTempPos = (UInt32)br.BaseStream.Position; // Actual Sound Bank, header br.BaseStream.Seek(soundBank.headerOffset, 0); br.ReadUInt32(); // Bank head Identifier soundBank.headerSize = br.ReadUInt32() + 8; // Include 0x8 head UInt32 firstBankSectionPos = soundBank.headerOffset + soundBank.headerSize; br.BaseStream.Seek(firstBankSectionPos, 0); // Check if we have a DIDX section (contains embedded *.wem files) to deal with string firstSectionIdent = new string(br.ReadChars(4)); if (firstSectionIdent == @"DIDX") { //soundBank.relativePath += "SoundBank (" + soundBank.idString + ")\\"; // Move Bank+Sound into Bank folder UInt32 didxSize = br.ReadUInt32(); UInt32 didxFilesCount = didxSize / 12; // Each file description is 0xC bytes UInt32 dataFilesOffset = firstBankSectionPos + didxSize + 16; // 16 is for the DIDX+DATA headers for (int j = 0; j < didxFilesCount; j++) { soundFile soundFile = new soundFile(); soundFile.id = br.ReadUInt32(); soundFile.idString = "0x" + soundFile.id.ToString("X8"); soundFile.fileOffset = br.ReadUInt32() + dataFilesOffset; soundFile.fileSize = br.ReadUInt32(); soundFile.relativePath = soundBank.relativePath; soundFileList.Add(soundFile); } br.BaseStream.Seek(firstBankSectionPos + didxSize + 12, 0); // Get us to the DATA section size UInt32 dataSectionSize = br.ReadUInt32(); br.ReadBytes((int)dataSectionSize + 4); // Skip to the end of DATA + 4, so we're back after HIRC Identifier } soundBank.hircOffset = (UInt32)br.BaseStream.Position - 4; // We already hit the HIRC head Identifier soundBank.hircSize = br.ReadUInt32() + 8; // Include 0x8 head // Go back to SoundBank list br.BaseStream.Seek(soundBankTempPos, 0); soundBankList.Add(soundBank); } }