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 WhiteNoiseGenerator(GeneratorDescriptor description) : base(description) { if (EndPhase < 0) { EndPhase = 1; } if (StartPhase < 0) { StartPhase = 0; } if (LoopEndPhase < 0) { LoopEndPhase = EndPhase; } if (LoopStartPhase < 0) { LoopStartPhase = StartPhase; } if (Period < 0) { Period = 1; } if (RootKey < 0) { RootKey = 69; } Frequency = 440; }
//--Methods public SquareGenerator(GeneratorDescriptor description) : base(description) { if (end < 0) { end = Synthesizer.TwoPi; } if (start < 0) { start = 0; } if (loopEnd < 0) { loopEnd = end; } if (loopStart < 0) { loopStart = start; } if (genPeriod < 0) { genPeriod = Synthesizer.TwoPi; } if (root < 0) { root = 69; } freq = 440; }
//--Methods public WhiteNoiseGenerator(GeneratorDescriptor description) : base(description) { if (end < 0) { end = 1; } if (start < 0) { start = 0; } if (loopEnd < 0) { loopEnd = end; } if (loopStart < 0) { loopStart = start; } if (genPeriod < 0) { genPeriod = 1; } if (root < 0) { root = 69; } freq = 440; }
private static void LoadAssetData() { for (int x = 0; x < patches.Count; x++) { for (int y = 0; y < patches[x].Description.GenDescriptions.Length; y++) { GeneratorDescriptor genDesc = patches[x].Description.GenDescriptions[y]; string assetName = genDesc.AssetName; string extension = Path.GetExtension(assetName).ToLower(); if (genDesc.SamplerType == WaveformEnum.SampleData && !assetName.Equals("null") && ContainsAsset(assetName, assets) == false) { switch (extension) { case ".wav": using (WaveFileReader wr = new WaveFileReader(File.Open(assetPath + assetName, FileMode.Open, FileAccess.Read))) { assets.Add(new SampleAsset(assetName, wr.ReadWaveFile())); } break; default: throw new Exception(string.Format("Unknown format ({0}), AssetName: {1}, PatchName: {2}", extension, assetName, patches[x].Name)); } } } } }
public SineGenerator(GeneratorDescriptor description) : base(description) { if (EndPhase < 0) { EndPhase = SynthConstants.TwoPi; } if (StartPhase < 0) { StartPhase = 0; } if (LoopEndPhase < 0) { LoopEndPhase = EndPhase; } if (LoopStartPhase < 0) { LoopStartPhase = StartPhase; } if (Period < 0) { Period = SynthConstants.TwoPi; } if (RootKey < 0) { RootKey = 69; } Frequency = 440; }
/// <summary> /// Internals the process. /// </summary> /// <remarks> /// </remarks> protected override void InternalProcess() { foreach (var sf in Context.SourceFileXml.Values) { foreach (var e in sf.Elements("register").ToArray()) { if (null == e.Attribute("compile")) { continue; } var code = e.Id(); var type = e.Describe().Name; var gendesc = new GeneratorDescriptor(code, type); Context.Generators[code] = gendesc; try { gendesc.PrepareType(); } catch (Exception ex) { var message = "error processing generator regestering of " + code + ":" + type; if (Context.Project.NonResolvedGeneratorIsError) { AddError(ErrorLevel.Error, message, "TE0201", ex, e.Describe().File, e.Describe().Line); UserLog.Error(message); return; } AddError(ErrorLevel.Warning, message, "TW0201", ex, e.Describe().File, e.Describe().Line); UserLog.Warn(message); } } } }
/// <summary>Refreshes the property grid.</summary> /// <param name="assemblyScope">The assembly scope.</param> public void RefreshPropertyGrid(AssemblyScope assemblyScope) { // Set the generate with some new data GeneratorDescriptor = new GeneratorDescriptor(assemblyScope.Name); // Update the property grid item values Pg_MemberType.SelectedObject = GeneratorDescriptor; }
/// <summary>Handles the PropertyValueChanged event of the Pg_MemberType control.</summary> /// <param name="s">The source of the event.</param> /// <param name="e">The <see cref="PropertyValueChangedEventArgs"/> instance containing the event data.</param> private void Pg_MemberType_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { GeneratorDescriptor = (GeneratorDescriptor)((PropertyGrid)s).SelectedObject; if (!string.IsNullOrEmpty(GeneratorDescriptor.Name)) { Btn_Generate.Enabled = true; } else { Btn_Generate.Enabled = false; } }
/// <summary>Initializes a new instance of the <see cref="DescriptionGeneratorControl"/> class.</summary> public DescriptionGeneratorControl() { InitializeComponent(); // Initialize variables Btn_Copy.Enabled = false; Btn_Generate.Enabled = false; Tb_Inheritance.Enabled = false; Cb_Inherit.Checked = true; Cb_GenerateMemberType.DataSource = Enum.GetNames(typeof(MemberInfoTypes)); AssemblyScope = new AssemblyScope(string.Empty, string.Empty, string.Empty); GeneratorDescriptor = new GeneratorDescriptor(string.Empty, typeof(string).Name.ToLower()); RefreshPropertyGrid(AssemblyScope); }
//--Methods public Generator(GeneratorDescriptor description) { loopMethod = description.LoopMethod; loopStart = description.LoopStartPhase; loopEnd = description.LoopEndPhase; start = description.StartPhase; end = description.EndPhase; startOffset = description.Offset; genPeriod = description.Period; root = description.Rootkey; noteTrack = description.KeyTrack; velTrack = description.VelTrack; tuneCents = description.Tune; }
protected Generator(GeneratorDescriptor description) { LoopMode = description.LoopMethod; LoopStartPhase = description.LoopStartPhase; LoopEndPhase = description.LoopEndPhase; StartPhase = description.StartPhase; EndPhase = description.EndPhase; Offset = description.Offset; Period = description.Period; Frequency = 0; RootKey = description.RootKey; KeyTrack = description.KeyTrack; VelocityTrack = description.VelTrack; Tune = description.Tune; }
private void LoadSfzGens(SfzRegion region) { GenDescriptions = new GeneratorDescriptor[1]; GenDescriptions[0] = new GeneratorDescriptor(); GenDescriptions[0].SamplerType = Components.WaveformEnum.SampleData; GenDescriptions[0].AssetName = region.sample; //deal with end point if (region.end == -1) //-1 is silent region, so set end to 0 and let the generator figure it out later { GenDescriptions[0].EndPhase = 0; } else if (region.end == 0) //set end out of range and let the descriptor default it to the proper end value { GenDescriptions[0].EndPhase = -1; } else //add one to the value because its inclusive { GenDescriptions[0].EndPhase = region.end + 1; } GenDescriptions[0].KeyTrack = region.pitchKeyTrack; //deal with loop end if (region.loopEnd < 0) { GenDescriptions[0].LoopEndPhase = -1; } else { GenDescriptions[0].LoopEndPhase = region.loopEnd + 1; } GenDescriptions[0].LoopMethod = region.loopMode; if (region.loopStart < 0) { GenDescriptions[0].LoopStartPhase = -1; } else { GenDescriptions[0].LoopStartPhase = region.loopStart; } GenDescriptions[0].Offset = region.offset; GenDescriptions[0].Rootkey = region.pitchKeyCenter; GenDescriptions[0].Tune = (short)(region.tune + region.transpose * 100); GenDescriptions[0].VelTrack = region.pitchVelTrack; }
private void LoadAssetData() { for (int x = 0; x < patches.Count; x++) { for (int y = 0; y < patches[x].Description.GenDescriptions.Length; y++) { GeneratorDescriptor genDesc = patches[x].Description.GenDescriptions[y]; string assetName = genDesc.AssetName; if (genDesc.SamplerType == WaveformEnum.SampleData && !assetName.Equals("null") && ContainsAsset(assetName, assets) == false) { switch (Path.GetExtension(assetName).ToLower()) { case ".wav": using (WaveFileReader wr = new WaveFileReader(assetPath + assetName)) { assets.Add(new SampleAsset(assetName, wr.ReadWaveFile())); } break; } } } } }
public SampleGenerator(GeneratorDescriptor description, AssetManager assets) : base(description) { SampleDataAsset sample = assets.FindSample(Path.GetFileNameWithoutExtension(description.AssetName)); if (sample == null) { throw new Exception("Could not find asset: (" + description.AssetName + ")."); } data = sample.SampleData; freq = sample.SampleRate; if (end < 0) { end = sample.End; } if (start < 0) { start = sample.Start; } if (loopEnd < 0) { if (sample.LoopEnd < 0) { loopEnd = end; } else { loopEnd = sample.LoopEnd; } } if (loopStart < 0) { if (sample.LoopStart < 0) { loopStart = start; } else { loopStart = sample.LoopStart; } } if (genPeriod < 0) { genPeriod = 1; } if (root < 0) { root = sample.RootKey; if (tuneCents == 0) { tuneCents = sample.Tune; } } //check sample end and loop end for consistency if (end > data.Length) { end = data.Length; } if (loopEnd > end) { loopEnd = end; } }
public DescriptorList(StreamReader reader) { List <EnvelopeDescriptor> envList = new List <EnvelopeDescriptor>(); List <FilterDescriptor> fltrList = new List <FilterDescriptor>(); List <LfoDescriptor> lfoList = new List <LfoDescriptor>(); List <GeneratorDescriptor> genList = new List <GeneratorDescriptor>(); List <CustomDescriptor> cList = new List <CustomDescriptor>(); List <string> descList = new List <string>(); while (!reader.EndOfStream) { string tag = ReadNextTag(reader, descList); switch (tag) { case "envelope": { EnvelopeDescriptor env = new EnvelopeDescriptor(); env.Read(descList.ToArray()); envList.Add(env); break; } case "generator": { GeneratorDescriptor gen = new GeneratorDescriptor(); gen.Read(descList.ToArray()); genList.Add(gen); break; } case "filter": { FilterDescriptor fltr = new FilterDescriptor(); fltr.Read(descList.ToArray()); fltrList.Add(fltr); break; } case "lfo": { LfoDescriptor lfo = new LfoDescriptor(); lfo.Read(descList.ToArray()); lfoList.Add(lfo); break; } default: if (!tag.Equals(string.Empty)) { CustomDescriptor cus = new CustomDescriptor(tag, 0); cus.Read(descList.ToArray()); cList.Add(cus); } break; } descList.Clear(); } EnvelopeDescriptions = envList.ToArray(); FilterDescriptions = fltrList.ToArray(); LfoDescriptions = lfoList.ToArray(); GenDescriptions = genList.ToArray(); CustomDescriptions = cList.ToArray(); }
public DescriptorList(BinaryReader reader) { List <EnvelopeDescriptor> envList = new List <EnvelopeDescriptor>(); List <FilterDescriptor> fltrList = new List <FilterDescriptor>(); List <LfoDescriptor> lfoList = new List <LfoDescriptor>(); List <GeneratorDescriptor> genList = new List <GeneratorDescriptor>(); List <CustomDescriptor> cList = new List <CustomDescriptor>(); int count = reader.ReadInt16(); for (int x = 0; x < count; x++) { string id = new string(IOHelper.Read8BitChars(reader, 4)); int size = reader.ReadInt32(); switch (id.ToLower()) { case EnvelopeDescriptor.ID: { EnvelopeDescriptor env = new EnvelopeDescriptor(); env.Read(reader); envList.Add(env); break; } case GeneratorDescriptor.ID: { GeneratorDescriptor gen = new GeneratorDescriptor(); gen.Read(reader); genList.Add(gen); break; } case FilterDescriptor.ID: { FilterDescriptor fltr = new FilterDescriptor(); fltr.Read(reader); fltrList.Add(fltr); break; } case LfoDescriptor.ID: { LfoDescriptor lfo = new LfoDescriptor(); lfo.Read(reader); lfoList.Add(lfo); break; } default: { CustomDescriptor cus = new CustomDescriptor(id, size); cus.Read(reader); cList.Add(cus); break; } } } EnvelopeDescriptions = envList.ToArray(); FilterDescriptions = fltrList.ToArray(); LfoDescriptions = lfoList.ToArray(); GenDescriptions = genList.ToArray(); CustomDescriptions = cList.ToArray(); }