/// <summary> /// Creates an object with raw parameters and velocity. Parameters are adjusted by velocity. /// </summary> /// <param name="OutputFile"></param> /// <param name="InputFile"></param> /// <param name="Length"></param> /// <param name="Tempo"></param> /// <param name="STP"></param> /// <param name="PreUtterance"></param> /// <param name="Overlap"></param> /// <param name="Envelope"></param> /// <param name="Velocity"></param> public WavtoolParameter(string OutputFile, string InputFile, double STP, double Length, double Tempo, double PreUtterance, double Overlap, Envelope Envelope, double Velocity) : this(OutputFile, InputFile, STP *CommonReferences.GetEffectiveVelocityFactor(Velocity), Length, Tempo, PreUtterance *CommonReferences.GetEffectiveVelocityFactor(Velocity), Overlap *CommonReferences.GetEffectiveVelocityFactor(Velocity), Envelope) { }
public void TestVelocity() { Assert.AreEqual(CommonReferences.GetEffectiveVelocityFactor(0), 2); Assert.AreEqual(CommonReferences.GetEffectiveVelocityFactor(100), 1); Assert.AreEqual(CommonReferences.GetEffectiveVelocityFactor(200), 0.5); Assert.AreEqual(CommonReferences.GetVelocity(2), 0); Assert.AreEqual(CommonReferences.GetVelocity(1), 100); Assert.AreEqual(CommonReferences.GetVelocity(0.5), 200); }
/// <summary> /// Set a region in the original. Start and End both inclusive. /// This is for when you have only the region you want to set. /// if you have the entire array, use SetPitchbends(int[]) /// </summary> /// <param name="Start">Inclusive.</param> /// <param name="End">Inclusive.</param> /// <param name="Pitchbends">the data for that region.</param> public void SetPitchbends(int Start, int End, int[] Pitchbends) { int[] array = CommonReferences.DecodePitchbends(PitchbendString); for (int i = Start; i <= End; i++) { array[i] = Pitchbends[i - Start]; } PitchbendString = CommonReferences.EncodePitchbends(array); }
public void CommonReferences_ForMapping_Get_ReturnsReferences() { var commonReferences = new CommonReferences(); var references = commonReferences.Get().ToList(); references[0].Display.ShouldContain("mscorlib.dll"); references[1].Display.ShouldContain("System.Runtime.dll"); references[2].Display.ShouldContain("Private.CoreLib.dll"); references[3].Display.ShouldContain("System.Collections.dll"); references[4].Display.ShouldContain("netstandard.dll"); }
public void TestPBEfficency() { var param = new ResamplerParameter() { PitchbendString = "1E#14#1T18244B5N6T7K7r7z#2#7y7x7w7v7t7s7q7o7m7k7j7h7g7e7d7d7c#2#7e7k7s748H8X8q8+9U9q+A+W+q++/P/f/r/1/8//AA#3#ABABACADAEAFAGAHAIAJAKALAM#4#ALALAJAIAGAEACAA/9/6/3/0/x/u/s/p/n/m/l/k#2#/l/m/n/p/r/t/v/y/1/4/7//ACAFAIALAOARATAWAYAZAaAbAc#2#AbAaAYAXAVASAQANAKAHAEAA/9/6/3/0/x/u/s/q/o/m/l/k#2#/l/l/n/o/q/s/v/x/0/3/6/+ABAEAHALAOAQATAVAXAZAaAbAc#2#AbAZAYAWATARAOAMAJAGAEAB/+/8/6/4/2/0/z/y/x#5#/y/z/0/1" }; for (int i = 0; i < 10000; i++) { CommonReferences.EncodePitchbends(CommonReferences.DecodePitchbends(param.PitchbendString)); } }
public void TestPB() { var param = new ResamplerParameter(); string[] testCases = new string[] { "1E#14#1T18244B5N6T7K7r7z#2#7y7x7w7v7t7s7q7o7m7k7j7h7g7e7d7d7c#2#7e7k7s748H8X8q8+9U9q+A+W+q++/P/f/r/1/8//AA#3#ABABACADAEAFAGAHAIAJAKALAM#4#ALALAJAIAGAEACAA/9/6/3/0/x/u/s/p/n/m/l/k#2#/l/m/n/p/r/t/v/y/1/4/7//ACAFAIALAOARATAWAYAZAaAbAc#2#AbAaAYAXAVASAQANAKAHAEAA/9/6/3/0/x/u/s/q/o/m/l/k#2#/l/l/n/o/q/s/v/x/0/3/6/+ABAEAHALAOAQATAVAXAZAaAbAc#2#AbAZAYAWATARAOAMAJAGAEAB/+/8/6/4/2/0/z/y/x#5#/y/z/0/1", "AJAWAvBOBxCTCvDBDHDI#13#DGC3CaBxA/AI/S+g929Y9I9H#14#9V9y+Y/B/j/6", "84#38#85#2#8686878788#2#89898+#5#9A9O9m+F+o/K/m/5//", "AA#43#" }; foreach (string s in testCases) { param.PitchbendString = s; //this is necessary because the original algorithm is inconsistent. string recoded = CommonReferences.EncodePitchbends(CommonReferences.DecodePitchbends(param.PitchbendString)); Assert.AreEqual(recoded, CommonReferences.EncodePitchbends(CommonReferences.DecodePitchbends(recoded))); } }
/// <summary> /// This makes it shorter. Don't worry, data will be unchanged. /// </summary> public void RecodePitchbendString() { this.PitchbendString = CommonReferences.EncodePitchbends(CommonReferences.DecodePitchbends(this.PitchbendString)); }
/// <summary> /// /// </summary> /// <param name="NewPitchbends"></param> public void SetPitchbends(int[] NewPitchbends) { PitchbendString = CommonReferences.EncodePitchbends(NewPitchbends); }
/// <summary> /// Use this if you only change one value in the pitchbend. /// Use "SetPitchbends" for many values. /// </summary> /// <param name="index"></param> /// <param name="value"></param> public void SetPitchbend(int Index, int Value) { int[] array = CommonReferences.DecodePitchbends(PitchbendString); array[Index] = Value; PitchbendString = CommonReferences.EncodePitchbends(array); }
/// <summary> /// This decodes the pitchbend string into actual pitchbends in unit of cents, zeroed at given register. They only goes from -2048 to 2048. /// </summary> public int[] GetPitchbendArray() { return(CommonReferences.DecodePitchbends(PitchbendString)); }