public static void Read32BitFloat(BinaryFile wavfile, double[][] sound, int samplecount, int channels) { int i = 0; int ic = 0; #if DEBUG Console.Write("Read32BitFloat...\n"); #endif for (i = 0;i<samplecount;i++) { for (ic = 0;ic<channels;ic++) { double d = (double) wavfile.ReadSingle(); sound[ic][i] = d; } } }
public static void Read32BitFloat(BinaryFile wavfile, float[][] sound, int samplecount, int channels) { var i = new int(); var ic = new int(); #if DEBUG Console.Write("Read32BitFloat...\n"); #endif for (i = 0; i < samplecount; i++) { for (ic = 0; ic < channels; ic++) { float f = (float)wavfile.ReadSingle(); sound[ic][i] = f; } } }
public bool ReadFXP(FXP fxp, string filePath="") { var bFile = new BinaryFile(fxp.ChunkDataByteArray, BinaryFile.ByteOrder.LittleEndian); // Read UAD Preset Header information PresetHeaderVar1 = bFile.ReadInt32(); PresetHeaderVar2 = bFile.ReadInt32(); PresetName = bFile.ReadString(32).Trim('\0'); // Read Parameters Input = bFile.ReadSingle(); Phase = bFile.ReadSingle(); HPFreq = bFile.ReadSingle(); LPFreq = bFile.ReadSingle(); HP_LPDynSC = bFile.ReadSingle(); CMPRatio = bFile.ReadSingle(); CMPThresh = bFile.ReadSingle(); CMPRelease = bFile.ReadSingle(); CMPAttack = bFile.ReadSingle(); StereoLink = bFile.ReadSingle(); Select = bFile.ReadSingle(); EXPThresh = bFile.ReadSingle(); EXPRange = bFile.ReadSingle(); EXPRelease = bFile.ReadSingle(); EXPAttack = bFile.ReadSingle(); DYNIn = bFile.ReadSingle(); CompIn = bFile.ReadSingle(); ExpIn = bFile.ReadSingle(); LFGain = bFile.ReadSingle(); LFFreq = bFile.ReadSingle(); LFBell = bFile.ReadSingle(); LMFGain = bFile.ReadSingle(); LMFFreq = bFile.ReadSingle(); LMFQ = bFile.ReadSingle(); HMFQ = bFile.ReadSingle(); HMFGain = bFile.ReadSingle(); HMFFreq = bFile.ReadSingle(); HFGain = bFile.ReadSingle(); HFFreq = bFile.ReadSingle(); HFBell = bFile.ReadSingle(); EQIn = bFile.ReadSingle(); EQDynSC = bFile.ReadSingle(); PreDyn = bFile.ReadSingle(); Output = bFile.ReadSingle(); EQType = bFile.ReadSingle(); Power = bFile.ReadSingle(); return false; }
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(); // read the xml chunk into memory XmlDocument = new XmlDocument(); try { if (chunkData != null) XmlDocument.LoadXml(chunkData); } catch (XmlException) { //Console.Out.WriteLine("No XML found"); } }
private static FXP ReadFXP(BinaryFile bf) { string ChunkMagic = bf.ReadString(4); if (ChunkMagic != "CcnK") { throw new FormatException(string.Format("Error reading file. Missing preset header information {0}", ChunkMagic)); } var fxp = new FXP(); int ByteSize = bf.ReadInt32(); string FxMagic = bf.ReadString(4); if (FxMagic == "FBCh") { // Bank (.fxb) with chunk (magic = 'FBCh') var chunkSet = new FxChunkSet(); chunkSet.ChunkMagic = ChunkMagic; chunkSet.ByteSize = ByteSize; chunkSet.FxMagic = FxMagic; chunkSet.Version = bf.ReadInt32(); chunkSet.FxID = bf.ReadString(4); chunkSet.FxVersion = bf.ReadInt32(); chunkSet.NumPrograms = bf.ReadInt32(); chunkSet.Future = bf.ReadString(128).TrimEnd('\0'); chunkSet.ChunkSize = bf.ReadInt32(); // Even though the main FXP is BigEndian format the preset chunk is saved in LittleEndian format chunkSet.ChunkData = bf.ReadBytes(0, chunkSet.ChunkSize, BinaryFile.ByteOrder.LittleEndian); // read the xml chunk into memory try { if (chunkSet.ChunkData != null) { var xmlDocument = new XmlDocument(); var chunkAsString = Encoding.UTF8.GetString(chunkSet.ChunkData); xmlDocument.LoadXml(chunkAsString); fxp.XmlDocument = xmlDocument; } } catch (XmlException) { } fxp.Content = chunkSet; } else if (FxMagic == "FPCh") { // Preset (Program) (.fxp) with chunk (magic = 'FPCh') var programSet = new FxProgramSet(); programSet.ChunkMagic = ChunkMagic; programSet.ByteSize = ByteSize; programSet.FxMagic = FxMagic; programSet.Version = bf.ReadInt32(); programSet.FxID = bf.ReadString(4); programSet.FxVersion = bf.ReadInt32(); programSet.NumPrograms = bf.ReadInt32(); programSet.Name = bf.ReadString(28).TrimEnd('\0'); programSet.ChunkSize = bf.ReadInt32(); // Even though the main FXP is BigEndian format the preset chunk is saved in LittleEndian format programSet.ChunkData = bf.ReadBytes(0, programSet.ChunkSize, BinaryFile.ByteOrder.LittleEndian); // read the xml chunk into memory try { if (programSet.ChunkData != null) { var xmlDocument = new XmlDocument(); var chunkAsString = Encoding.UTF8.GetString(programSet.ChunkData); xmlDocument.LoadXml(chunkAsString); fxp.XmlDocument = xmlDocument; } } catch (XmlException) { } fxp.Content = programSet; } else if (FxMagic == "FxCk") { // For Preset (Program) (.fxp) without chunk (magic = 'FxCk') var program = new FxProgram(); program.ChunkMagic = ChunkMagic; program.ByteSize = ByteSize; program.FxMagic = FxMagic; program.Version = bf.ReadInt32(); program.FxID = bf.ReadString(4); program.FxVersion = bf.ReadInt32(); program.NumParameters = bf.ReadInt32(); program.ProgramName = bf.ReadString(28).TrimEnd('\0'); // variable no. of parameters program.Parameters = new float[program.NumParameters]; for (int i = 0; i < program.NumParameters; i++) { program.Parameters[i] = bf.ReadSingle(); } fxp.Content = program; } else if (FxMagic == "FxBk") { // For bank (.fxb) without chunk (magic = 'FxBk') var set = new FxSet(); set.ChunkMagic = ChunkMagic; set.ByteSize = ByteSize; set.FxMagic = FxMagic; set.Version = bf.ReadInt32(); set.FxID = bf.ReadString(4); set.FxVersion = bf.ReadInt32(); set.NumPrograms = bf.ReadInt32(); set.Future = bf.ReadString(128).TrimEnd('\0'); // variable no. of programs set.Programs = new FxProgram[set.NumPrograms]; for (int p = 0; p < set.NumPrograms; p++) { var content = ReadFXP(bf).Content; if (content is FxProgram) { set.Programs[p] = (FxProgram)content; } } fxp.Content = set; } return(fxp); }
public static void Read32BitFloat(BinaryFile wavfile, float[][] sound, Int32 samplecount, Int32 channels) { Int32 i = new Int32(); Int32 ic = new Int32(); #if DEBUG Console.Write("Read32BitFloat...\n"); #endif for (i = 0;i<samplecount;i++) { for (ic = 0;ic<channels;ic++) { float f = (float) wavfile.ReadSingle(); sound[ic][i] = f; } } }
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(); // read the xml chunk into memory XmlDocument = new XmlDocument(); try { if (chunkData != null) { XmlDocument.LoadXml(chunkData); } } catch (XmlException) { //Console.Out.WriteLine("No XML found"); } }