public static SynthErrorCodes NewConvStream( float[] ImpulseResponse, int ImpulseResponseLength, bool LatencySpecified, int Latency, int lOversampling, SynthErrorInfoRec errorInfo, out IConvolution convolveStream) { convolveStream = null; if (LatencySpecified) { if (convolveStreamExplicitLatencyAvailable.HasValue && !convolveStreamExplicitLatencyAvailable.Value) { errorInfo.ErrorEx = SynthErrorSubCodes.eSynthErrorExConvolverExplicitLatencyNotAvailable; return(SynthErrorCodes.eSynthErrorEx); } if (convolveStreamExplicitLatencyCreator == null) { Type type = null; // TODO: the ConvolveStreamExplicitLatency should be signed so that other plugins can't mask it foreach (Assembly plugin in Program.PluginAssemblies) { foreach (Type candidateType in plugin.GetTypes()) { if (candidateType.IsClass && candidateType.Name == "ConvolveStreamExplicitLatency") { type = candidateType; goto Found; } } } // if you get here - not found convolveStreamExplicitLatencyAvailable = false; errorInfo.ErrorEx = SynthErrorSubCodes.eSynthErrorExConvolverExplicitLatencyNotAvailable; return(SynthErrorCodes.eSynthErrorEx); Found: convolveStreamExplicitLatencyCreator = type.GetMethod("NewConvStream", BindingFlags.Static | BindingFlags.Public); } convolveStream = (IConvolution)convolveStreamExplicitLatencyCreator.Invoke(null, new object[] { (float[])ImpulseResponse, (int)ImpulseResponseLength, (int)Latency, (int)lOversampling }); } else { convolveStream = new ConvolveStreamSimple( ImpulseResponse, ImpulseResponseLength, Latency, lOversampling); } return(SynthErrorCodes.eSynthDone); }
/** Select the proper method for a certain number n of convolutions */ internal void SelectMethod(MethodType method, double n) { int montecarloIts = (int)(maxIt / (double)n); switch (method) { case MethodType.Combinatory: convCalc = new CombinatoryConv(maxClasses, maxCombError); convCalc.LoadHistogram(hist.Min, hist.Max, hist.TotFreqs, hist.Range, hist.MaxClasses, hist.Freqs, n); break; case MethodType.Montecarlo: convCalc = new MontecarloConv(montecarloIts); convCalc.LoadHistogram(hist.Min, hist.Max, hist.TotFreqs, hist.Range, hist.MaxClasses, hist.Freqs, n); break; case MethodType.Normal: convCalc = new NormalConv(); convCalc.LoadHistogram(hist.Min, hist.Max, hist.TotFreqs, hist.Range, hist.MaxClasses, hist.Freqs, n); break; } }
/** Method: Load data for calculation * data - data from time series * n - number of convolutions * method can be set before loading data to force a particular calculation method */ internal void LoadData(List <double> data, double n) { this.data = data; this.n = n; this.method = SelectMethod(n); switch (method) { case MethodType.Combinatory: convCalc = new CombinatoryConv(maxClasses, maxCombError); break; case MethodType.Montecarlo: convCalc = new MontecarloConv(maxIt); break; case MethodType.Normal: convCalc = new NormalConv(); break; } if (!convCalc.IsValid()) { convCalc = new MontecarloConv(maxIt); method = MethodType.Montecarlo; convCalc.LoadData(data, n); } }
/// <summary> /// Filtro complejo que suaviza los bordes de una imagen. /// </summary> /// <param name="name">Nombre del objeto</param> public FilterBlurConvolution(IConvolution matriz) { this.matriz = matriz; }