/// <summary> /// Resamples a multichannel array with the quality set by the user. /// </summary> /// <param name="samples">Samples of the source channel</param> /// <param name="to">New sample count per channel</param> /// <param name="channels">Channel count</param> /// <param name="quality">Listener audio quality</param> /// <returns>Resampled version of the input</returns> public static float[] Adaptive(float[] samples, int to, int channels, QualityModes quality) { float[][] channelSplit = new float[channels][]; int splitSize = samples.Length / channels; for (int channel = 0; channel < channels; ++channel) { channelSplit[channel] = new float[splitSize]; } for (int sample = 0, outSample = 0; sample < splitSize; ++sample) { for (int channel = 0; channel < channels; ++channel, ++outSample) { channelSplit[channel][sample] = samples[outSample]; } } for (int channel = 0; channel < channels; ++channel) { channelSplit[channel] = Adaptive(channelSplit[channel], to, quality); } int newUpdateRate = channelSplit[0].Length; samples = new float[channels * newUpdateRate]; for (int sample = 0, outSample = 0; sample < newUpdateRate; ++sample) { for (int channel = 0; channel < channels; ++channel, ++outSample) { samples[outSample] = channelSplit[channel][sample]; } } return(samples); }
public override object CreateInstance(ITypeDescriptorContext context, IDictionary values) { QualityModes t = new QualityModes(); foreach (var prop in typeof(QualityModes).GetProperties()) { if (values[prop.Name] != null) { prop.SetValue(t, values[prop.Name], null); } } return(t); }
/// <summary> /// Resamples a single channel with the quality set by the user. /// </summary> /// <param name="samples">Samples of the source channel</param> /// <param name="to">New sample count</param> /// <param name="quality">Listener audio quality</param> /// <returns>Resampled version of the input channel</returns> public static float[] Adaptive(float[] samples, int to, QualityModes quality) { if (quality < QualityModes.High) { return(NearestNeighbour(samples, to)); } else if (quality < QualityModes.Perfect) { return(Lerp(samples, to)); } else { return(CatmullRom(samples, to)); } }
// Constructor public ViewImageControl() { AutoScaleMode = AutoScaleMode.Font; // ReSharper disable DoNotCallOverridableMethodsInConstructor DoubleBuffered = true; // ReSharper restore DoNotCallOverridableMethodsInConstructor ErrorImage = null; Image = ErrorImage; ImageVisible = true; EnableDragging = true; Rotation = RotateFlipType.RotateNoneFlipNone; RedrawTimer.Tick += (s, e) => { Refresh(); }; Quality = new QualityModes(); // Handle mouse zoom and dragging MouseWheel += OnMouseWheel; MouseDown += OnMouseDown; MouseUp += OnMouseUp; }