diff --git a/Assets/Scripts/AudioSynthesis/Bank/PatchBank.cs b/Assets/Scripts/AudioSynthesis/Bank/PatchBank.cs index cd232685f3..ad2f57ede7 100644 --- a/Assets/Scripts/AudioSynthesis/Bank/PatchBank.cs +++ b/Assets/Scripts/AudioSynthesis/Bank/PatchBank.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Collections.Generic; using DaggerfallWorkshop.AudioSynthesis.Bank.Patches; @@ -192,14 +192,14 @@ private void LoadMyBank(Stream stream) //read riff chunk string id = IOHelper.Read8BitString(reader, 4).ToLower(); int size = reader.ReadInt32(); - if(!id.Equals("riff")) + if(!id.Equals("riff", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The riff header is missing."); - if(!new RiffTypeChunk(id, size, reader).TypeId.ToLower().Equals("bank")) + if(!new RiffTypeChunk(id, size, reader).TypeId.Equals("bank", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The riff type is incorrect."); //read info chunk id = IOHelper.Read8BitString(reader, 4).ToLower(); size = reader.ReadInt32(); - if (!id.Equals("info")) + if (!id.Equals("info", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The INFO chunk is missing."); if (reader.ReadSingle() != BankVersion) throw new Exception(string.Format("Invalid bank file. The bank version is incorrect, the correct version is {0:0.000}.", BankVersion)); @@ -207,36 +207,36 @@ private void LoadMyBank(Stream stream) //read asset list chunk id = IOHelper.Read8BitString(reader, 4).ToLower(); size = reader.ReadInt32(); - if (!id.Equals("list")) + if (!id.Equals("list", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The ASET LIST chunk is missing."); long readTo = reader.BaseStream.Position + size; id = IOHelper.Read8BitString(reader, 4).ToLower(); - if (!id.Equals("aset")) + if (!id.Equals("aset", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The LIST chunk is not of type ASET."); //--read assets while(reader.BaseStream.Position < readTo) { id = IOHelper.Read8BitString(reader, 4).ToLower(); size = reader.ReadInt32(); - if (!id.Equals("smpl")) + if (!id.Equals("smpl", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. Only SMPL chunks are allowed in the asset list chunk."); assets.SampleAssetList.Add(new SampleDataAsset(size, reader)); } //read instrument list chunk id = IOHelper.Read8BitString(reader, 4).ToLower(); size = reader.ReadInt32(); - if (!id.Equals("list")) + if (!id.Equals("list", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The INST LIST chunk is missing."); readTo = reader.BaseStream.Position + size; id = IOHelper.Read8BitString(reader, 4).ToLower(); - if (!id.Equals("inst")) + if (!id.Equals("inst", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. The LIST chunk is not of type INST."); //--read instruments while (reader.BaseStream.Position < readTo) { id = IOHelper.Read8BitString(reader, 4).ToLower(); size = reader.ReadInt32(); - if (!id.Equals("ptch")) + if (!id.Equals("ptch", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid bank file. Only PTCH chunks are allowed in the instrument list chunk."); string patchName = IOHelper.Read8BitString(reader, 20); string patchType = IOHelper.Read8BitString(reader, 4); diff --git a/Assets/Scripts/AudioSynthesis/Bank/Patches/MultiPatch.cs b/Assets/Scripts/AudioSynthesis/Bank/Patches/MultiPatch.cs index 46c0630b44..437622f62e 100644 --- a/Assets/Scripts/AudioSynthesis/Bank/Patches/MultiPatch.cs +++ b/Assets/Scripts/AudioSynthesis/Bank/Patches/MultiPatch.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using DaggerfallWorkshop.AudioSynthesis.Synthesis; using DaggerfallWorkshop.AudioSynthesis.Sf2; @@ -123,7 +123,7 @@ public override void Load(DescriptorList description, AssetManager assets) intervalList = new PatchInterval[description.CustomDescriptions.Length]; for (int x = 0; x < intervalList.Length; x++) { - if (!description.CustomDescriptions[x].ID.ToLower().Equals("mpat")) + if (!description.CustomDescriptions[x].ID.Equals("mpat", StringComparison.InvariantCultureIgnoreCase)) throw new Exception(string.Format("The patch: {0} has an invalid descriptor with id {1}", this.patchName, description.CustomDescriptions[x].ID)); string patchName = (string)description.CustomDescriptions[x].Objects[0]; PatchAsset pAsset = assets.FindPatch(patchName); diff --git a/Assets/Scripts/AudioSynthesis/Midi/MidiFile.cs b/Assets/Scripts/AudioSynthesis/Midi/MidiFile.cs index a0fecca9f7..477aceeea7 100644 --- a/Assets/Scripts/AudioSynthesis/Midi/MidiFile.cs +++ b/Assets/Scripts/AudioSynthesis/Midi/MidiFile.cs @@ -1,4 +1,4 @@ -namespace DaggerfallWorkshop.AudioSynthesis.Midi +namespace DaggerfallWorkshop.AudioSynthesis.Midi { using System; using System.IO; @@ -164,7 +164,7 @@ private static MidiTrack ReadTrack(BinaryReader reader) int channelList = 0; int noteOnCount = 0; int totalTime = 0; - while (!new string(IOHelper.Read8BitChars(reader, 4)).Equals("MTrk")) + while (!new string(IOHelper.Read8BitChars(reader, 4)).Equals("MTrk", StringComparison.InvariantCultureIgnoreCase)) { int length = BigEndianHelper.ReadInt32(reader); while (length > 0) diff --git a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontInfo.cs b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontInfo.cs index 346d729e0b..1645452b68 100644 --- a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontInfo.cs +++ b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontInfo.cs @@ -1,6 +1,7 @@ -namespace DaggerfallWorkshop.AudioSynthesis.Sf2 +namespace DaggerfallWorkshop.AudioSynthesis.Sf2 { using System; + using System.Globalization; using System.IO; using DaggerfallWorkshop.AudioSynthesis.Util; @@ -41,17 +42,17 @@ public SoundFontInfo(BinaryReader reader) { string id = new string(IOHelper.Read8BitChars(reader, 4)); int size = reader.ReadInt32(); - if(!id.ToLower().Equals("list")) + if(!id.Equals("list", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid soundfont. Could not find INFO LIST chunk."); long readTo = reader.BaseStream.Position + size; id = new string(IOHelper.Read8BitChars(reader, 4)); - if (!id.ToLower().Equals("info")) + if (!id.Equals("info", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid soundfont. The LIST chunk is not of type INFO."); while (reader.BaseStream.Position < readTo) { id = new string(IOHelper.Read8BitChars(reader, 4)); size = reader.ReadInt32(); - switch (id.ToLower()) + switch (id.ToLower(CultureInfo.InvariantCulture)) { case "ifil": verMajorSF = reader.ReadInt16(); diff --git a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontPresets.cs b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontPresets.cs index 9c4cec13a0..9f7c49ced2 100644 --- a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontPresets.cs +++ b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontPresets.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.IO; using DaggerfallWorkshop.AudioSynthesis.Util; using DaggerfallWorkshop.AudioSynthesis.Sf2.Chunks; +using System.Globalization; namespace DaggerfallWorkshop.AudioSynthesis.Sf2 { @@ -28,11 +29,11 @@ public SoundFontPresets(BinaryReader reader) { string id = new string(IOHelper.Read8BitChars(reader, 4)); int size = reader.ReadInt32(); - if(!id.ToLower().Equals("list")) + if(!id.Equals("list", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid soundfont. Could not find pdta LIST chunk."); long readTo = reader.BaseStream.Position + size; id = new string(IOHelper.Read8BitChars(reader, 4)); - if (!id.ToLower().Equals("pdta")) + if (!id.Equals("pdta", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("Invalid soundfont. The LIST chunk is not of type pdta."); Modulator[] presetModulators = null; @@ -50,7 +51,7 @@ public SoundFontPresets(BinaryReader reader) id = new string(IOHelper.Read8BitChars(reader, 4)); size = reader.ReadInt32(); - switch (id.ToLower()) + switch (id.ToLower(CultureInfo.InvariantCulture)) { case "phdr": phdr = new PresetHeaderChunk(id, size, reader); diff --git a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontSampleData.cs b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontSampleData.cs index 50f1505e54..465f821146 100644 --- a/Assets/Scripts/AudioSynthesis/Sf2/SoundFontSampleData.cs +++ b/Assets/Scripts/AudioSynthesis/Sf2/SoundFontSampleData.cs @@ -1,6 +1,7 @@ -namespace DaggerfallWorkshop.AudioSynthesis.Sf2 +namespace DaggerfallWorkshop.AudioSynthesis.Sf2 { using System; + using System.Globalization; using System.IO; using DaggerfallWorkshop.AudioSynthesis.Util; @@ -21,11 +22,11 @@ public byte[] SampleData //--Methods public SoundFontSampleData(BinaryReader reader) { - if (new string(IOHelper.Read8BitChars(reader, 4)).ToLower().Equals("list") == false) + if (new string(IOHelper.Read8BitChars(reader, 4)).Equals("list", StringComparison.InvariantCultureIgnoreCase) == false) throw new Exception("Invalid soundfont. Could not find SDTA LIST chunk."); long readTo = reader.ReadInt32(); readTo += reader.BaseStream.Position; - if (new string(IOHelper.Read8BitChars(reader, 4)).Equals("sdta") == false) + if (new string(IOHelper.Read8BitChars(reader, 4)).Equals("sdta", StringComparison.InvariantCultureIgnoreCase) == false) throw new Exception("Invalid soundfont. List is not of type sdta."); bitsPerSample = 0; byte[] rawSampleData = null; @@ -33,7 +34,7 @@ public SoundFontSampleData(BinaryReader reader) { string subID = new string(IOHelper.Read8BitChars(reader, 4)); int size = reader.ReadInt32(); - switch (subID.ToLower()) + switch (subID.ToLower(CultureInfo.InvariantCulture)) { case "smpl": bitsPerSample = 16; diff --git a/Assets/Scripts/AudioSynthesis/Sfz/SfzReader.cs b/Assets/Scripts/AudioSynthesis/Sfz/SfzReader.cs index 9eb565f228..d572b6c1c6 100644 --- a/Assets/Scripts/AudioSynthesis/Sfz/SfzReader.cs +++ b/Assets/Scripts/AudioSynthesis/Sfz/SfzReader.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System.Collections.Generic; +using System; using System.Text; using System.IO; using DaggerfallWorkshop.AudioSynthesis.Bank.Components; @@ -162,7 +163,7 @@ private void ToRegion(string regionText, SfzRegion region) region.offBy = int.Parse(parameter); break; case "off_mode": - region.offMode = parameter.Equals("fast") ? SfzRegion.OffModeEnum.Fast : SfzRegion.OffModeEnum.Normal; + region.offMode = parameter.Equals("fast", StringComparison.InvariantCultureIgnoreCase) ? SfzRegion.OffModeEnum.Fast : SfzRegion.OffModeEnum.Normal; break; case "delay": region.delay = float.Parse(parameter); diff --git a/Assets/Scripts/AudioSynthesis/Wave/WaveFileReader.cs b/Assets/Scripts/AudioSynthesis/Wave/WaveFileReader.cs index 385888fc79..9345fcd36a 100644 --- a/Assets/Scripts/AudioSynthesis/Wave/WaveFileReader.cs +++ b/Assets/Scripts/AudioSynthesis/Wave/WaveFileReader.cs @@ -1,10 +1,11 @@ -namespace DaggerfallWorkshop.AudioSynthesis.Wave +namespace DaggerfallWorkshop.AudioSynthesis.Wave { using System; using System.IO; using System.Collections.Generic; using DaggerfallWorkshop.AudioSynthesis.Util; using DaggerfallWorkshop.AudioSynthesis.Util.Riff; + using System.Globalization; public sealed class WaveFileReader : IDisposable { @@ -53,7 +54,7 @@ internal static Chunk[] ReadAllChunks(BinaryReader reader) long offset = reader.BaseStream.Position + 8; List chunks = new List(); RiffTypeChunk head = new RiffTypeChunk(new string(IOHelper.Read8BitChars(reader, 4)), reader.ReadInt32(), reader); - if (!head.ChunkId.ToLower().Equals("riff") || !head.TypeId.ToLower().Equals("wave")) + if (!head.ChunkId.Equals("riff", StringComparison.InvariantCultureIgnoreCase) || !head.TypeId.Equals("wave", StringComparison.InvariantCultureIgnoreCase)) throw new Exception("The asset could not be loaded because the RIFF chunk was missing or was not of type WAVE."); while (reader.BaseStream.Position - offset < head.ChunkSize) { @@ -67,7 +68,7 @@ internal static Chunk ReadNextChunk(BinaryReader reader) { string id = new string(IOHelper.Read8BitChars(reader, 4)); int size = reader.ReadInt32(); - switch (id.ToLower()) + switch (id.ToLower(CultureInfo.InvariantCulture)) { case "riff": return new RiffTypeChunk(id, size, reader);