Exemple #1
0
        /// <summary>
        /// Fill _timeAtGrid, index in range [from, to], assuming constant BPM (bpm) starting from referenceIdx
        /// </summary>
        private void SetTimeAtGrid(int from, int to, double bpm, int referenceIdx)
        {
            var secondsPerSignature = DirectorHelper.BpmToSeconds(bpm);

            for (int i = from; i <= to; ++i)
            {
                var numGrids = i - referenceIdx;
                _timeAtGrid[i] = _timeAtGrid[referenceIdx] + numGrids * secondsPerSignature / GridPerSignature;
            }
        }
Exemple #2
0
        private void UpdateTimeLength()
        {
            var  length      = 0.0;
            Note lastBpmNote = null;

            _timeAtGrid    = new double[TotalGridCount];
            _timeAtGrid[0] = StartTime;

            // find all BpmNotes and compute the length between them
            foreach (var note in Notes)
            {
                if (note.Type != NoteType.VariantBpm)
                {
                    continue;
                }

                if (lastBpmNote == null)
                {
                    // length between start and first BpmNote
                    length += DirectorHelper.BpmToSeconds(StartBpm) * note.IndexInGrid / GridPerSignature;
                    SetTimeAtGrid(1, note.IndexInGrid, StartBpm, 0);
                }
                else
                {
                    // length between prev BpmNote and current
                    var deltaGridCount = note.IndexInGrid - lastBpmNote.IndexInGrid;
                    length += DirectorHelper.BpmToSeconds(lastBpmNote.ExtraParams.NewBpm) * deltaGridCount / GridPerSignature;
                    SetTimeAtGrid(lastBpmNote.IndexInGrid + 1, note.IndexInGrid, lastBpmNote.ExtraParams.NewBpm, lastBpmNote.IndexInGrid);
                }

                lastBpmNote = note;
            }

            // length from the last BpmNote to end
            // if it's null, there is no BpmNote in the bar
            if (lastBpmNote != null)
            {
                length += DirectorHelper.BpmToSeconds(lastBpmNote.ExtraParams.NewBpm) * (TotalGridCount - lastBpmNote.IndexInGrid) / GridPerSignature;
                SetTimeAtGrid(lastBpmNote.IndexInGrid + 1, TotalGridCount - 1, lastBpmNote.ExtraParams.NewBpm, lastBpmNote.IndexInGrid);
            }
            else
            {
                length = DirectorHelper.BpmToSeconds(StartBpm) * Signature;
                for (int i = 0; i < TotalGridCount; ++i)
                {
                    _timeAtGrid[i] = StartTime + length * i / TotalGridCount;
                }
            }

            TimeLength = length;
        }
Exemple #3
0
        private static double CalculateTimingPeriodBetweenNotes(List <DelesteBeatmapEntry> entries, DelesteBasicNote currentBasicFlickNote, DelesteBasicNote lastBasicFlickNote, int fullLength)
        {
            double timeDiff;
            double timePerBeat;
            DelesteBeatmapEntry entry;

            if (currentBasicFlickNote.Entry.MeasureIndex != lastBasicFlickNote.Entry.MeasureIndex)
            {
                var startIndex = entries.IndexOf(lastBasicFlickNote.Entry);
                var endIndex   = entries.IndexOf(currentBasicFlickNote.Entry, startIndex + 1);

                entry       = lastBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff    = timePerBeat * entry.Signature * (1 - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength);
                for (var i = startIndex + 1; i < endIndex; ++i)
                {
                    entry = entries[i];
                    if (entry.IsCommand)
                    {
                        continue;
                    }
                    timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                    timeDiff   += timePerBeat * entry.Signature;
                }
                entry       = currentBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff   += timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength);
            }
            else
            {
                entry       = currentBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff    = timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength);
            }
            return(timeDiff);
        }