public byte[] GetHeader(uint assetID, AssetType assetType)
        {
            List <EntrySoundInfo_GCN_V1> entries;

            if (assetType == AssetType.SND)
            {
                entries = Entries_SND.ToList();
            }
            else
            {
                entries = Entries_SNDS.ToList();
            }

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].SoundAssetID == assetID)
                {
                    return(entries[i].SoundHeader);
                }
            }

            entries = Entries_Sound_CIN.ToList();

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].SoundAssetID == assetID)
                {
                    return(entries[i].SoundHeader);
                }
            }

            throw new Exception($"Error: SNDI asset does not contain {assetType} sound header for asset [{assetID:X8}]");
        }
        public void RemoveEntry(uint assetID, AssetType assetType)
        {
            List <EntrySoundInfo_GCN_V1> entries;

            if (assetType == AssetType.SND)
            {
                entries = Entries_SND.ToList();
            }
            else
            {
                entries = Entries_SNDS.ToList();
            }

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].SoundAssetID == assetID)
                {
                    entries.Remove(entries[i--]);
                }
            }

            if (assetType == AssetType.SND)
            {
                Entries_SND = entries.ToArray();
            }
            else
            {
                Entries_SNDS = entries.ToArray();
            }
        }
        public void AddEntry(byte[] soundData, uint assetID, AssetType assetType, out byte[] finalData)
        {
            List <EntrySoundInfo_GCN_V1> entries;

            if (assetType == AssetType.SND)
            {
                entries = Entries_SND.ToList();
            }
            else
            {
                entries = Entries_SNDS.ToList();
            }

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].SoundAssetID == assetID)
                {
                    entries.Remove(entries[i--]);
                }
            }

            entries.Add(new EntrySoundInfo_GCN_V1(soundData.Take(0x60).ToArray(), assetID));

            finalData = soundData.Skip(0x60).ToArray();

            if (assetType == AssetType.SND)
            {
                Entries_SND = entries.ToArray();
            }
            else
            {
                Entries_SNDS = entries.ToArray();
            }
        }
 public void Clean(IEnumerable <uint> assetIDs)
 {
     {
         // SND
         var entriesSND = Entries_SND.ToList();
         for (int i = 0; i < entriesSND.Count; i++)
         {
             if (!assetIDs.Contains(entriesSND[i].SoundAssetID))
             {
                 entriesSND.RemoveAt(i--);
             }
         }
         Entries_SND = entriesSND.ToArray();
     }
     {
         // SNDS
         var entriesSNDS = Entries_SNDS.ToList();
         for (int i = 0; i < entriesSNDS.Count; i++)
         {
             if (!assetIDs.Contains(entriesSNDS[i].SoundAssetID))
             {
                 entriesSNDS.RemoveAt(i--);
             }
         }
         Entries_SNDS = entriesSNDS.ToArray();
     }
 }
        public void AddEntry(byte[] soundData, uint assetID, AssetType assetType, out byte[] finalData)
        {
            RemoveEntry(assetID, assetType);

            List <EntrySoundInfo_PS2> entries;

            if (assetType == AssetType.SND)
            {
                entries = Entries_SND.ToList();
            }
            else
            {
                entries = Entries_SNDS.ToList();
            }

            entries.Add(new EntrySoundInfo_PS2(soundData.Take(EntrySoundInfo_PS2.StructSize).ToArray())
            {
                SoundAssetID = assetID
            });

            finalData = soundData.Skip(EntrySoundInfo_PS2.StructSize).ToArray();

            if (assetType == AssetType.SND)
            {
                Entries_SND = entries.ToArray();
            }
            else
            {
                Entries_SNDS = entries.ToArray();
            }
        }
        public void Merge(AssetSNDI_GCN_V1 assetSNDI)
        {
            {
                // SND
                var entries = Entries_SND.ToList();
                var assetIDsAlreadyPresent = (from entry in entries select(uint) entry.SoundAssetID).ToList();

                foreach (var entry in assetSNDI.Entries_SND)
                {
                    if (!assetIDsAlreadyPresent.Contains(entry.SoundAssetID))
                    {
                        entries.Add(entry);
                    }
                }

                Entries_SND = entries.ToArray();
            }
            {
                // SNDS
                var entries = Entries_SNDS.ToList();
                var assetIDsAlreadyPresent = (from entry in entries select(uint) entry.SoundAssetID).ToList();

                foreach (var entry in assetSNDI.Entries_SNDS)
                {
                    if (!assetIDsAlreadyPresent.Contains(entry.SoundAssetID))
                    {
                        entries.Add(entry);
                    }
                }

                Entries_SNDS = entries.ToArray();
            }
            {
                // Sound_CIN
                var entries = Entries_Sound_CIN.ToList();
                var assetIDsAlreadyPresent = (from entry in entries select(uint) entry.SoundAssetID).ToList();

                foreach (var entry in assetSNDI.Entries_Sound_CIN)
                {
                    if (!assetIDsAlreadyPresent.Contains(entry.SoundAssetID))
                    {
                        entries.Add(entry);
                    }
                }

                Entries_Sound_CIN = entries.ToArray();
            }
        }
 public void Merge(AssetSNDI_PS2 assetSNDI)
 {
     {
         // SND
         List <EntrySoundInfo_PS2> entriesSND  = Entries_SND.ToList();
         List <uint> assetIDsAlreadyPresentSND = new List <uint>();
         foreach (EntrySoundInfo_PS2 entrySND in entriesSND)
         {
             assetIDsAlreadyPresentSND.Add(entrySND.SoundAssetID);
         }
         foreach (EntrySoundInfo_PS2 entrySND in assetSNDI.Entries_SND)
         {
             if (!assetIDsAlreadyPresentSND.Contains(entrySND.SoundAssetID))
             {
                 entriesSND.Add(entrySND);
             }
         }
         Entries_SND = entriesSND.ToArray();
     }
     {
         // SNDS
         List <EntrySoundInfo_PS2> entriesSNDS  = Entries_SNDS.ToList();
         List <uint> assetIDsAlreadyPresentSNDS = new List <uint>();
         foreach (EntrySoundInfo_PS2 entrySNDS in entriesSNDS)
         {
             assetIDsAlreadyPresentSNDS.Add(entrySNDS.SoundAssetID);
         }
         foreach (EntrySoundInfo_PS2 entrySNDS in assetSNDI.Entries_SNDS)
         {
             if (!assetIDsAlreadyPresentSNDS.Contains(entrySNDS.SoundAssetID))
             {
                 entriesSNDS.Add(entrySNDS);
             }
         }
         Entries_SNDS = entriesSNDS.ToArray();
     }
 }