public int[] BuildVibrato(VibratoInfo vibratoInfo, VibratoInfo vibratoPrevInfo) { var pitches = new List <int>(); var interv = Settings.Current.IntervalTick; for (var x = 0; x <= vibratoInfo.Length; x += interv) { double y = 0; //Apply vibratos if (MusicMath.Current.TickToMillisecond(x) < vibratoPrevInfo.End && MusicMath.Current.TickToMillisecond(x) >= vibratoPrevInfo.Start && vibratoPrevInfo.Vibrato != null) { y += InterpolateVibrato(vibratoPrevInfo.Vibrato, MusicMath.Current.TickToMillisecond(x) - vibratoPrevInfo.Start, vibratoPrevInfo.Length); } if (MusicMath.Current.TickToMillisecond(x) < vibratoInfo.End && MusicMath.Current.TickToMillisecond(x) >= vibratoInfo.Start) { y += InterpolateVibrato(vibratoInfo.Vibrato, MusicMath.Current.TickToMillisecond(x) - vibratoInfo.Start, vibratoInfo.Length); } pitches.Add((int)Math.Round(y)); } return(pitches.ToArray()); }
public void BuildVibratoInfo(Note note, Note prevNote, Note nextNote, out VibratoInfo vibratoInfo, out VibratoInfo vibratoPrevInfo) { vibratoInfo = new VibratoInfo { Start = 0, End = 0, Vibrato = note.Vibrato, Length = note.FinalLength }; if (prevNote != null) { vibratoPrevInfo = new VibratoInfo { Start = 0, End = 0, Vibrato = prevNote.Vibrato, Length = prevNote.FinalLength } } ; else { vibratoPrevInfo = new VibratoInfo { Start = 0, End = 0, Vibrato = null, Length = 0 } }; if (note.Vibrato != null && note.Vibrato.Depth != 0) { vibratoInfo.End = MusicMath.Current.TickToMillisecond(note.FinalLength); vibratoInfo.Start = vibratoInfo.End * (1 - note.Vibrato.Length / 100); } if (prevNote != null && prevNote.Vibrato != null && prevNote.Vibrato.Depth != 0) { vibratoPrevInfo.Start = -MusicMath.Current.TickToMillisecond(prevNote.FinalLength) * prevNote.Vibrato.Length / 100; vibratoPrevInfo.End = 0; } }