public override void Load(DescriptorList description, AssetManager assets) { //read in sfz params CustomDescriptor sfzConfig = description.FindCustomDescriptor("sfzi"); exTarget = (int)sfzConfig.Objects[0]; exGroup = (int)sfzConfig.Objects[1]; sfzVolume = (float)sfzConfig.Objects[2]; sfzPan = new PanComponent((float)sfzConfig.Objects[3], PanFormulaEnum.Neg3dBCenter); ampKeyTrack = (float)sfzConfig.Objects[4]; ampRootKey = (byte)sfzConfig.Objects[5]; ampVelTrack = (float)sfzConfig.Objects[6]; //read in the generator info GeneratorDescriptor gdes = description.GenDescriptions[0]; if (gdes.SamplerType != WaveformEnum.SampleData) { throw new Exception("Sfz can only support sample data generators."); } this.genList[0] = gdes.ToGenerator(assets); //read in the envelope info this.envList[0] = description.EnvelopeDescriptions[0]; this.envList[1] = description.EnvelopeDescriptions[1]; this.envList[2] = description.EnvelopeDescriptions[2]; //read in the lfo info this.lfoList[0] = description.LfoDescriptions[0]; this.lfoList[1] = description.LfoDescriptions[1]; this.lfoList[2] = description.LfoDescriptions[2]; //read in the filter info this.fltrList[0] = description.FilterDescriptions[0]; }
public override void Load(DescriptorList description, AssetManager assets) { intervalList = new PatchInterval[description.CustomDescriptions.Length]; for (int x = 0; x < intervalList.Length; x++) { if (!description.CustomDescriptions[x].ID.ToLower().Equals("mpat")) { throw new Exception(string.Format("The patch: {0} has an invalid descriptor with id {1}", this.patchName, description.CustomDescriptions[x].ID)); } string patchName = (string)description.CustomDescriptions[x].Objects[0]; PatchAsset pAsset = assets.FindPatch(patchName); if (pAsset == null) { throw new Exception(string.Format("The patch: {0} could not be found. For multi patches all sub patches must be loaded first.", patchName)); } byte sChan = (byte)description.CustomDescriptions[x].Objects[1]; byte eChan = (byte)description.CustomDescriptions[x].Objects[2]; byte sKey = (byte)description.CustomDescriptions[x].Objects[3]; byte eKey = (byte)description.CustomDescriptions[x].Objects[4]; byte sVel = (byte)description.CustomDescriptions[x].Objects[5]; byte eVel = (byte)description.CustomDescriptions[x].Objects[6]; intervalList[x] = new PatchInterval(pAsset.Patch, sChan, eChan, sKey, eKey, sVel, eVel); } DetermineIntervalType(); }
public void LoadSfz(SfzRegion[] regions, AssetManager assets, string directory) { //Load sub instruments first intervalList = new PatchInterval[regions.Length]; for (int x = 0; x < intervalList.Length; x++) { SfzRegion r = regions[x]; DescriptorList descList = new DescriptorList(r); assets.LoadSampleAsset(descList.GenDescriptions[0].AssetName, patchName, directory); SfzPatch sfzPatch = new SfzPatch(patchName + "_" + x); sfzPatch.Load(descList, assets); intervalList[x] = new PatchInterval(sfzPatch, r.loChan, r.hiChan, r.loKey, r.hiKey, r.loVel, r.hiVel); } DetermineIntervalType(); }
public override void Load(DescriptorList description, AssetManager assets) { CustomDescriptor fmConfig = description.FindCustomDescriptor("fm2c"); cIndex = (double)fmConfig.Objects[0]; mIndex = (double)fmConfig.Objects[1]; feedBack = (double)fmConfig.Objects[2]; sync = GetSyncModeFromString((string)fmConfig.Objects[3]); if (description.GenDescriptions[0].LoopMethod != LoopModeEnum.Continuous || description.GenDescriptions[1].LoopMethod != LoopModeEnum.Continuous) { throw new Exception("Fm2 patches must have continuous generators with wrapping bounds."); } genList[0] = description.GenDescriptions[0].ToGenerator(assets); genList[1] = description.GenDescriptions[1].ToGenerator(assets); envList[0] = description.EnvelopeDescriptions[0]; envList[1] = description.EnvelopeDescriptions[1]; lfoList[0] = description.LfoDescriptions[0]; }
private static int LoadSfz(PatchInfo pInfo) { SfzReader sfz; using (FileStream fs = File.Open(patchPath + pInfo.Name, FileMode.Open, FileAccess.Read)) { sfz = new SfzReader(fs, pInfo.Name); } PatchInfo[] pInfos = new PatchInfo[sfz.Regions.Length]; int nameLen = sfz.Name.Length + 1 + sfz.Regions.Length.ToString().Length; if (nameLen > 20) { sfz.Name = sfz.Name.Remove(0, nameLen - 20); } for (int i = 0; i < pInfos.Length; i++) { pInfos[i] = new PatchInfo(sfz.Name + "_" + i, new PatchInterval(-1, 0, 0)); pInfos[i].Type = "sfz "; pInfos[i].Description = new DescriptorList(sfz.Regions[i]); } DescriptorList multiDesc = new DescriptorList(); multiDesc.CustomDescriptions = new CustomDescriptor[sfz.Regions.Length]; for (int i = 0; i < multiDesc.CustomDescriptions.Length; i++) { SfzRegion r = sfz.Regions[i]; multiDesc.CustomDescriptions[i] = new CustomDescriptor("mpat", pInfos[i].Name.Length + 14, new object[] { pInfos[i].Name, r.loChan, r.hiChan, r.loKey, r.hiKey, r.loVel, r.hiVel }); } pInfo.Type = "mult"; pInfo.Description = multiDesc; multiPatches.Add(pInfo); patches.Remove(pInfo); patches.InsertRange(0, pInfos); return(pInfos.Length - 1); }
public override void Load(DescriptorList description, AssetManager assets) { gen = description.GenDescriptions[0].ToGenerator(assets); env = description.EnvelopeDescriptions[0]; lfo = description.LfoDescriptions[0]; }
public override void Load(DescriptorList description, AssetManager assets) { genList[0] = description.GenDescriptions[0].ToGenerator(assets); envList[0] = description.EnvelopeDescriptions[0]; lfoList[0] = description.LfoDescriptions[0]; }
public override void Load(DescriptorList description, AssetManager assets) { throw new Exception("Sf2 does not load from patch descriptions."); }
public abstract void Load(DescriptorList description, AssetManager assets);
private void LoadPatchData() { for (int x = 0; x < patches.Count; x++) { switch (Path.GetExtension(patches[x].Name).ToLower()) { case ".patch": using (StreamReader reader = new StreamReader(patchPath + patches[x].Name)) { string str = reader.ReadLine(); if (PatchBank.BankVersion != float.Parse(str.Substring(str.IndexOf("v") + 1))) { throw new Exception("The patch " + patches[x].Name + " has an incorrect version."); } patches[x].Type = reader.ReadLine().Trim().ToLower(); patches[x].Description = new DescriptorList(reader); } if (patches[x].Type.Equals("multi")) { PatchInfo pInfo = patches[x]; patches.RemoveAt(x); x--; multiPatches.Add(pInfo); //load sub patches for (int i = 0; i < pInfo.Description.CustomDescriptions.Length; x++) { if (!pInfo.Description.CustomDescriptions[i].ID.Equals("mpat")) { throw new Exception("Invalid multi patch: " + pInfo.Name); } string subPatchName = (string)pInfo.Description.CustomDescriptions[i].Objects[0]; if (ContainsPatch(subPatchName, patches) == false) { PatchInfo subPatch = new PatchInfo(subPatchName, new PatchInterval(-1, 0, 0)); patches.Add(subPatch); } } } break; case ".sfz": { SfzReader sfz = new SfzReader(patchPath + patches[x].Name); PatchInfo[] pInfos = new PatchInfo[sfz.Regions.Length]; int nameLen = sfz.Name.Length + 1 + sfz.Regions.Length.ToString().Length; if (nameLen > 20) { sfz.Name = sfz.Name.Remove(0, nameLen - 20); } for (int i = 0; i < pInfos.Length; i++) { pInfos[i] = new PatchInfo(sfz.Name + "_" + i, new PatchInterval(-1, 0, 0)); pInfos[i].Type = "sfz "; pInfos[i].Description = new DescriptorList(sfz.Regions[i]); } DescriptorList multiDesc = new DescriptorList(); multiDesc.CustomDescriptions = new CustomDescriptor[sfz.Regions.Length]; for (int i = 0; i < multiDesc.CustomDescriptions.Length; i++) { SfzRegion r = sfz.Regions[i]; multiDesc.CustomDescriptions[i] = new CustomDescriptor("mpat", pInfos[i].Name.Length + 14, new object[] { pInfos[i].Name, r.loChan, r.hiChan, r.loKey, r.hiKey, r.loVel, r.hiVel }); } patches[x].Type = "mult"; patches[x].Description = multiDesc; multiPatches.Add(patches[x]); patches.RemoveAt(x); patches.InsertRange(0, pInfos); x += pInfos.Length - 1; } break; } } }
public override void Load(DescriptorList description, AssetManager assets) { //read in sfz params CustomDescriptor sfzConfig = description.FindCustomDescriptor("sfzi"); exTarget = (int)sfzConfig.Objects[0]; exGroup = (int)sfzConfig.Objects[1]; sfzVolume = (float)sfzConfig.Objects[2]; sfzPan = new PanComponent((float)sfzConfig.Objects[3], PanFormulaEnum.Neg3dBCenter); ampKeyTrack = (float)sfzConfig.Objects[4]; ampRootKey = (byte)sfzConfig.Objects[5]; ampVelTrack = (float)sfzConfig.Objects[6]; //read in the generator info GeneratorDescriptor gdes = description.GenDescriptions[0]; if (gdes.SamplerType != WaveformEnum.SampleData) throw new Exception("Sfz can only support sample data generators."); gen = gdes.ToGenerator(assets); //read in the envelope info ptch_env = description.EnvelopeDescriptions[0]; fltr_env = description.EnvelopeDescriptions[1]; amp_env = description.EnvelopeDescriptions[2]; //read in the lfo info ptch_lfo = description.LfoDescriptions[0]; fltr_lfo = description.LfoDescriptions[1]; amp_lfo = description.LfoDescriptions[2]; //read in the filter info fltr = description.FilterDescriptions[0]; }
public override void Load(DescriptorList description, AssetManager assets) { intervalList = new PatchInterval[description.CustomDescriptions.Length]; for (int x = 0; x < intervalList.Length; x++) { if (!description.CustomDescriptions[x].ID.ToLower().Equals("mpat")) throw new Exception(string.Format("The patch: {0} has an invalid descriptor with id {1}", this.patchName, description.CustomDescriptions[x].ID)); string patchName = (string)description.CustomDescriptions[x].Objects[0]; PatchAsset pAsset = assets.FindPatch(patchName); if(pAsset == null) throw new Exception(string.Format("The patch: {0} could not be found. For multi patches all sub patches must be loaded first.", patchName)); byte sChan = (byte)description.CustomDescriptions[x].Objects[1]; byte eChan = (byte)description.CustomDescriptions[x].Objects[2]; byte sKey = (byte)description.CustomDescriptions[x].Objects[3]; byte eKey = (byte)description.CustomDescriptions[x].Objects[4]; byte sVel = (byte)description.CustomDescriptions[x].Objects[5]; byte eVel = (byte)description.CustomDescriptions[x].Objects[6]; intervalList[x] = new PatchInterval(pAsset.Patch, sChan, eChan, sKey, eKey, sVel, eVel); } DetermineIntervalType(); }
public override void Load(DescriptorList description, AssetManager assets) { CustomDescriptor fmConfig = description.FindCustomDescriptor("fm2c"); cIndex = (double)fmConfig.Objects[0]; mIndex = (double)fmConfig.Objects[1]; feedBack = (double)fmConfig.Objects[2]; sync = GetSyncModeFromString((string)fmConfig.Objects[3]); if (description.GenDescriptions[0].LoopMethod != LoopModeEnum.Continuous || description.GenDescriptions[1].LoopMethod != LoopModeEnum.Continuous) throw new Exception("Fm2 patches must have continuous generators with wrapping bounds."); cGen = description.GenDescriptions[0].ToGenerator(assets); mGen = description.GenDescriptions[1].ToGenerator(assets); cEnv = description.EnvelopeDescriptions[0]; mEnv = description.EnvelopeDescriptions[1]; lfo = description.LfoDescriptions[0]; }