public void ReadFXP(BinaryFile bf) { ChunkMagic = bf.ReadString(4); if (ChunkMagic != "CcnK") { Console.Out.WriteLine("Error reading file. Missing preset header information."); } ByteSize = bf.ReadInt32(); FxMagic = bf.ReadString(4); if (FxMagic == "FBCh") { // Bank with Chunk Data Version = bf.ReadInt32(); FxID = bf.ReadString(4); FxVersion = bf.ReadInt32(); ProgramCount = bf.ReadInt32(); Future = bf.ReadString(128); ChunkSize = bf.ReadInt32(); // Even though the main FXP is BigEndian format the preset chunk is saved in LittleEndian format chunkDataByteArray = new byte[ChunkSize]; chunkDataByteArray = bf.ReadBytes(0, ChunkSize, BinaryFile.ByteOrder.LittleEndian); chunkData = BinaryFile.ByteArrayToString(chunkDataByteArray); } else if (FxMagic == "FPCh") { // Preset with Chunk Data Version = bf.ReadInt32(); FxID = bf.ReadString(4); FxVersion = bf.ReadInt32(); ProgramCount = bf.ReadInt32(); Name = bf.ReadString(28); ChunkSize = bf.ReadInt32(); // Even though the main FXP is BigEndian format the preset chunk is saved in LittleEndian format chunkDataByteArray = new byte[ChunkSize]; chunkDataByteArray = bf.ReadBytes(0, ChunkSize, BinaryFile.ByteOrder.LittleEndian); chunkData = BinaryFile.ByteArrayToString(chunkDataByteArray); } else if (FxMagic == "FxCk") { // For Preset (Program) (.fxp) without chunk (magic = 'FxCk') Version = bf.ReadInt32(); FxID = bf.ReadString(4); FxVersion = bf.ReadInt32(); ParameterCount = bf.ReadInt32(); Name = bf.ReadString(28); // variable no. of parameters Parameters = new float[ParameterCount]; for (int i = 0; i < ParameterCount; i++) { Parameters[i] = bf.ReadSingle(); } } bf.Close(); }
public static string PluginIdNumberToIdString(int pluginUniqueID) { byte[] fxIdArray = BitConverter.GetBytes(pluginUniqueID); Array.Reverse(fxIdArray); string fxIdString = BinaryFile.ByteArrayToString(fxIdArray); return(fxIdString); }