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;
        }
		public bool WriteFXP(string filePath) {

			FXP fxp = new FXP();
			fxp.ChunkMagic = "CcnK";
			fxp.ByteSize = 0; // will be set correctly by FXP class
			
			// Preset (Program) (.fxp) with chunk (magic = 'FPCh')
			fxp.FxMagic = "FPCh"; // FPCh = FXP (preset), FBCh = FXB (bank)
			fxp.Version = 1; // Format Version (should be 1)
			fxp.FxID = "J9AU";
			fxp.FxVersion = 1;
			fxp.ProgramCount = 36; // I.e. nummber of parameters
			fxp.Name = PresetName;
			
			byte[] chunkData = GetChunkData();
			fxp.ChunkSize = chunkData.Length;
			fxp.ChunkDataByteArray = chunkData;
			
			fxp.WriteFile(filePath);
			return true;
		}
Beispiel #3
0
        public void SaveFXP(string filePath)
        {
            bool UseChunk = false;
            if ((PluginContext.PluginInfo.Flags & VstPluginFlags.ProgramChunks) == 0) {
                // Chunks not supported.
                UseChunk = false;
            } else {
                // Chunks supported.
                UseChunk = true;
            }

            FXP fxp = new FXP();
            fxp.ChunkMagic = "CcnK";
            fxp.ByteSize = 0; // will be set correctly by FXP class

            if (UseChunk) {
                // Preset (Program) (.fxp) with chunk (magic = 'FPCh')
                fxp.FxMagic = "FPCh"; // FPCh = FXP (preset), FBCh = FXB (bank)
                fxp.Version = 1; // Format Version (should be 1)
                fxp.FxID = PluginIDNumberToIDString(PluginContext.PluginInfo.PluginID);
                fxp.FxVersion = PluginContext.PluginInfo.PluginVersion;
                fxp.ProgramCount = PluginContext.PluginInfo.ProgramCount;
                fxp.Name = PluginContext.PluginCommandStub.GetProgramName();

                byte[] chunkData = PluginContext.PluginCommandStub.GetChunk(true);
                fxp.ChunkSize = chunkData.Length;
                fxp.ChunkDataByteArray = chunkData;
            } else {
                // Preset (Program) (.fxp) without chunk (magic = 'FxCk')
                fxp.FxMagic = "FxCk"; // FxCk = FXP (preset), FxBk = FXB (bank)
                fxp.Version = 1; // Format Version (should be 1)
                fxp.FxID = PluginIDNumberToIDString(PluginContext.PluginInfo.PluginID);
                fxp.FxVersion = PluginContext.PluginInfo.PluginVersion;
                fxp.ParameterCount = PluginContext.PluginInfo.ParameterCount;
                fxp.Name = PluginContext.PluginCommandStub.GetProgramName();

                // variable no. of parameters
                float[] parameters = new float[fxp.ParameterCount];
                for (int i = 0; i < fxp.ParameterCount; i++) {
                    parameters[i] = PluginContext.PluginCommandStub.GetParameter(i);
                }
                fxp.Parameters = parameters;
            }
            fxp.WriteFile(filePath);
        }