private byte[] GetBandsContent() { var memStream = new MemoryStream(); using (BinaryFile binFile = new BinaryFile(memStream, BinaryFile.ByteOrder.LittleEndian, Encoding.ASCII)) { binFile.Write((int)Bands.Count * 7 + 12); // How many bands are enabled? var enabledBandCount = Bands.Count(b => b.Enabled); binFile.Write((float)enabledBandCount); for (int i = 0; i < 24; i++) { if (i < Bands.Count) { binFile.Write((float)FabfilterProQ.FreqConvert(Bands[i].Frequency)); binFile.Write((float)Bands[i].Gain); binFile.Write((float)FabfilterProQ.QConvert(Bands[i].Q)); binFile.Write((float)Bands[i].Shape); binFile.Write((float)Bands[i].LPHPSlope); binFile.Write((float)Bands[i].StereoPlacement); binFile.Write((float)1); } else { binFile.Write((float)FabfilterProQ.FreqConvert(1000)); binFile.Write((float)0); binFile.Write((float)FabfilterProQ.QConvert(1)); binFile.Write((float)ProQShape.Bell); binFile.Write((float)ProQLPHPSlope.Slope24dB_oct); binFile.Write((float)ProQStereoPlacement.Stereo); binFile.Write((float)1); } } binFile.Write((float)OutputGain); // -1 to 1 (- Infinity to +36 dB , 0 = 0 dB) binFile.Write((float)OutputPan); // -1 to 1 (0 = middle) binFile.Write((float)DisplayRange); // 0 = 6dB, 1 = 12dB, 2 = 30dB, 3 = 3dB binFile.Write((float)ProcessMode); // 0 = zero latency, 1 = lin.phase.low - medium - high - maximum binFile.Write((float)ChannelMode); // 0 = Left/Right, 1 = Mid/Side binFile.Write((float)Bypass); // 0 = No bypass binFile.Write((float)ReceiveMidi); // 0 = Enabled? binFile.Write((float)Analyzer); // 0 = Off, 1 = Pre, 2 = Post, 3 = Pre+Post binFile.Write((float)AnalyzerResolution); // float ; // 0 - 3 : low - medium[x] - high - maximum binFile.Write((float)AnalyzerSpeed); // 0 - 3 : very slow, slow, medium[x], fast binFile.Write((float)SoloBand); // -1 } return(memStream.ToArray()); }
public static FabfilterProQ ToFabfilterProQ(this REWEQFilters filters) { var preset = new FabfilterProQ(); preset.Version = 2; preset.Bands = new List <ProQBand>(); foreach (REWEQBand filter in filters) { var band = new ProQBand(); band.Frequency = filter.FilterFreq; band.Gain = filter.FilterGain; band.Q = filter.FilterQ; band.Enabled = filter.Enabled; switch (filter.FilterType) { case REWEQFilterType.PK: band.Shape = ProQShape.Bell; break; case REWEQFilterType.LP: band.Shape = ProQShape.HighCut; break; case REWEQFilterType.HP: band.Shape = ProQShape.LowCut; break; case REWEQFilterType.LS: band.Shape = ProQShape.LowShelf; break; case REWEQFilterType.HS: band.Shape = ProQShape.HighShelf; break; default: band.Shape = ProQShape.Bell; break; } band.LPHPSlope = ProQLPHPSlope.Slope24dB_oct; band.StereoPlacement = ProQStereoPlacement.Stereo; preset.Bands.Add(band); } // Add empty bands for (int i = preset.Bands.Count; i < 24; i++) { var band = new ProQBand(); band.Frequency = FabfilterProQ.FreqConvert(1000); band.Gain = 0; band.Q = FabfilterProQ.QConvert(1); band.Enabled = true; band.Shape = ProQShape.Bell; band.LPHPSlope = ProQLPHPSlope.Slope24dB_oct; band.StereoPlacement = ProQStereoPlacement.Stereo; preset.Bands.Add(band); } preset.OutputGain = 0; // -1 to 1 (- Infinity to +36 dB , 0 = 0 dB) preset.OutputPan = 0; // -1 to 1 (0 = middle) preset.DisplayRange = 2; // 0 = 6dB, 1 = 12dB, 2 = 30dB, 3 = 3dB preset.ProcessMode = 0; // 0 = zero latency, 1 = lin.phase.low - medium - high - maximum preset.ChannelMode = 0; // 0 = Left/Right, 1 = Mid/Side preset.Bypass = 0; // 0 = No bypass preset.ReceiveMidi = 0; // 0 = Enabled? preset.Analyzer = 3; // 0 = Off, 1 = Pre, 2 = Post, 3 = Pre+Post preset.AnalyzerResolution = 1; // 0 - 3 : low - medium[x] - high - maximum preset.AnalyzerSpeed = 2; // 0 - 3 : very slow, slow, medium[x], fast preset.SoloBand = -1; // -1 return(preset); }