private void ResetFamiStudioTempo() { if (!famitrackerTempo) { var newGroove = song.GetPatternGroove(playLocation.PatternIndex); var newGroovePadMode = song.GetPatternGroovePaddingMode(playLocation.PatternIndex); FamiStudioTempoUtils.ValidateGroove(newGroove); grooveIterator = new GrooveIterator(newGroove, newGroovePadMode); tempoEnvelope = FamiStudioTempoUtils.GetTempoEnvelope(newGroove, newGroovePadMode, song.Project.PalMode); tempoEnvelopeCounter = tempoEnvelope[0]; tempoEnvelopeIndex = 0; } }
public static int ComputeNumberOfFrameForGroove(int length, int[] groove, int groovePadMode) { // Look in the cache first. var key = new CacheGrooveLengthKey() { groove = groove, groovePadMode = groovePadMode }; if (cachedGrooveLengths.TryGetValue(key, out var grooveLengthArray)) { return(grooveLengthArray[length]); } grooveLengthArray = new int[Pattern.MaxLength]; // Add to cache if not found. var idx = 0; var grooveIterator = new GrooveIterator(groove, groovePadMode); // This is really not optimal, not need to run the full iterator until the very end. for (int i = 0; i < grooveLengthArray.Length; i++) { if (grooveIterator.IsPadFrame) { grooveIterator.Advance(); } grooveLengthArray[idx++] = grooveIterator.FrameIndex; grooveIterator.Advance(); } cachedGrooveLengths.Add(key, grooveLengthArray); return(grooveLengthArray[length]); }