Beispiel #1
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.ChunkMagic = "CcnK";
            fxp.ByteSize = 0; // will be set correctly by FXP class
            fxp.FxMagic = "FPCh"; // FPCh = FXP (preset), FBCh = FXB (bank)
            fxp.Version = 1; // Format Version (should be 1)
            fxp.FxID = "reeq";
            fxp.FxVersion = 1100;
            fxp.ProgramCount = 1;
            fxp.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();
                fxp.ChunkSize = chunkData.Length;
                fxp.ChunkDataByteArray = chunkData;
            }
            fxp.WriteFile(filePath);
            return true;
        }
Beispiel #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.ChunkMagic   = "CcnK";
            fxp.ByteSize     = 0;        // will be set correctly by FXP class
            fxp.FxMagic      = "FPCh";   // FPCh = FXP (preset), FBCh = FXB (bank)
            fxp.Version      = 1;        // Format Version (should be 1)
            fxp.FxID         = "reeq";
            fxp.FxVersion    = 1100;
            fxp.ProgramCount = 1;
            fxp.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();
                fxp.ChunkSize          = chunkData.Length;
                fxp.ChunkDataByteArray = chunkData;
            }
            fxp.WriteFile(filePath);
            return(true);
        }