Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RecalculateDisplayTime(double maxCharactersPerSecond, int index, double optimalCharactersPerSeconds)
- {
- Paragraph p = GetParagraphOrDefault(index);
- if (p == null)
- {
- return;
- }
- double displayChars = p.Text.CountCharacters(Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace);
- double optimalCharsPerSec = Math.Min(displayChars / Utilities.GetOptimalDisplayMilliseconds(p.Text, optimalCharactersPerSeconds) / TimeCode.BaseUnit, maxCharactersPerSecond);
- double optimalDuratoinInSec = displayChars / optimalCharsPerSec;
- p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + optimalDuratoinInSec * TimeCode.BaseUnit;
- Paragraph next = GetParagraphOrDefault(index + 1);
- // p is last paragraph or next is null
- if (next == null)
- {
- return;
- }
- double optimalEndTime = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
- if (optimalEndTime < p.EndTime.TotalMilliseconds)
- {
- p.EndTime.TotalMilliseconds = Math.Max(p.StartTime.TotalMilliseconds + 1, optimalEndTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement