Example #1
0
        public bool WriteFXP(string filePath)
        {
            FXP fxp = GenerateFXP(false);

            fxp.Write(filePath);
            return(true);
        }
Example #2
0
        public static bool Convert2ReaEQ(REWEQFilters filters, string filePath)
        {
            List <ReaEQBand> ReaEqBands = new List <ReaEQBand>();

            foreach (REWEQBand filter in filters)
            {
                ReaEQBand band = new ReaEQBand();
                band.LogScaleAutoFreq = true;
                band.FilterFreq       = filter.FilterFreq;
                band.FilterGain       = filter.FilterGain;
                band.FilterBWOct      = filter.FilterBWOct;
                band.Enabled          = filter.Enabled;
                switch (filter.FilterType)
                {
                case REWEQFilterType.PK:
                    band.FilterType = ReaEQFilterType.Band;
                    break;

                case REWEQFilterType.LP:
                    band.FilterType = ReaEQFilterType.LowPass;
                    break;

                case REWEQFilterType.HP:
                    band.FilterType = ReaEQFilterType.HighPass;
                    break;

                case REWEQFilterType.LS:
                    band.FilterType = ReaEQFilterType.LowShelf;
                    break;

                case REWEQFilterType.HS:
                    band.FilterType = ReaEQFilterType.HighShelf;
                    break;

                default:
                    band.FilterType = ReaEQFilterType.Band;
                    break;
                }
                ReaEqBands.Add(band);
            }

            // store to file
            FXP fxp = new FXP();

            FXP.FxProgramSet fxpContent = new FXP.FxProgramSet();
            fxp.Content            = fxpContent;
            fxpContent.ChunkMagic  = "CcnK";
            fxpContent.ByteSize    = 0;      // will be set correctly by FXP class
            fxpContent.FxMagic     = "FPCh"; // FPCh = FXP (preset), FBCh = FXB (bank)
            fxpContent.Version     = 1;      // Format Version (should be 1)
            fxpContent.FxID        = "reeq";
            fxpContent.FxVersion   = 1100;
            fxpContent.NumPrograms = 1;
            fxpContent.Name        = "";

            using (MemoryStream memStream = new MemoryStream(10))
            {
                BinaryFile binFile = new BinaryFile(memStream, BinaryFile.ByteOrder.LittleEndian);
                binFile.Write((int)33);
                binFile.Write((int)ReaEqBands.Count);
                foreach (ReaEQBand band in ReaEqBands)
                {
                    binFile.Write((int)band.FilterType);
                    binFile.Write((int)(band.Enabled ? 1 : 0));
                    binFile.Write((double)band.FilterFreq);
                    binFile.Write((double)Decibel2AmplitudeRatio(band.FilterGain));
                    binFile.Write((double)band.FilterBWOct);
                    binFile.Write((byte)1);
                }

                binFile.Write((int)1);
                binFile.Write((int)1);

                binFile.Write((double)Decibel2AmplitudeRatio(0.00));
                binFile.Write((int)0);

                memStream.Flush();
                byte[] chunkData = memStream.GetBuffer();
                fxpContent.ChunkSize = chunkData.Length;
                fxpContent.ChunkData = chunkData;
            }

            fxp.Write(filePath);
            return(true);
        }