public bool Read(string filename) { if (Chapters.Count > 0) { return(false); } using (var ism = new StreamReader(filename)) { int i = 0; while (!ism.EndOfStream) { string s = ism.ReadLine().Trim(); if (s.StartsWith("[")) { terminateChapter(); if (s.Equals(CHAPTER, StringComparison.InvariantCultureIgnoreCase)) { _timebase = new TimeBase(); _chapter = new Chapter(); i = 0; } } else { parseChapter(s, ref i); } } terminateChapter(); } return(true); }
static IEnumerable <uint> KeyFrames(uint StartTimeStamp, uint EndTimeStamp, TimeBase TimeBase) { for (uint time = StartTimeStamp; time < EndTimeStamp; time += 500) { yield return(FrameCloseTo(time, TimeBase)); } }
/// <summary> /// Calculates the frequency. /// </summary> /// <returns>The frequency.</returns> /// <param name="timebase">Timebase.</param> /// <param name="marker1">Marker1.</param> /// <param name="marker2">Marker2.</param> /// <param name="frame">Frame.</param> public static double CalculateFrequency(TimeBase timebase, Marker marker1, Marker marker2, Grid frame) { var time = CalculateTime(timebase, marker1, marker2, frame); var frequency = 1 / Math.Round(time, 9); return(frequency); }
public static void Update() { var timeBase = TimeBase.GetTimeBase(); if (Globals.Timing.TimeMs > sUpdateTime) { if (!timeBase.SyncTime) { sGameTime = sGameTime.Add(new TimeSpan(0, 0, 0, 0, (int)(1000 * timeBase.Rate))); //Not sure if Rate is negative if time will go backwards but we can hope! } else { sGameTime = DateTime.Now; } //Calculate what "timeRange" we should be in, if we're not then switch and notify the world //Gonna do this by minutes var minuteOfDay = sGameTime.Hour * 60 + sGameTime.Minute; var expectedRange = (int)Math.Floor(minuteOfDay / (float)timeBase.RangeInterval); if (expectedRange != sTimeRange) { sTimeRange = expectedRange; //Send the Update to everyone! PacketSender.SendTimeToAll(); } sUpdateTime = Globals.Timing.TimeMs + 1000; } }
private static Line ReadLine(XmlElement elem, List <Line> positions, List <Line> windowStyles, List <Section> pens) { int t = elem.GetIntAttribute("t") ?? 0; int d = elem.GetIntAttribute("d") ?? 5000; if (t == 1) // Reverse Android workaround (See WriteLine) { t--; d++; } DateTime start = TimeBase.AddMilliseconds(t); DateTime end = start.AddMilliseconds(d); Line line = new Line(start, end); Line position = GetItemAtIndex(positions, elem.GetIntAttribute("wp")); if (position != null) { line.AnchorPoint = position.AnchorPoint; line.Position = position.Position; } Line windowStyle = GetItemAtIndex(windowStyles, elem.GetIntAttribute("ws")); if (windowStyle != null) { line.VerticalTextType = windowStyle.VerticalTextType; } Section linePen = GetItemAtIndex(pens, elem.GetIntAttribute("p")); line.Sections.AddRange(ReadSections(elem, pens, linePen).Where(s => s.Text.Length > 0 || s.StartOffset > TimeSpan.Zero)); return(line); }
static void Main(string[] args) { var timeBase = new TimeBase { Numerator = 1001, Denominator = 30000 }; var ffmpegBin = "/usr/bin/ffmpeg"; //var videoFile = "/home/boris/droneMov/falafel_low.mov"; var videoFile = "/home/boris/droneMov/valkarra_sunny.mov"; Console.WriteLine("video {0}", videoFile); uint NumFrames; string ImagesDir; PrepVideo.SplitFrames(ffmpegBin, videoFile, SplitProgress, out NumFrames, out ImagesDir); Console.WriteLine("done spliting hairs, {0} NumFrames", NumFrames); PrepVideo.ExtractSubtitles(ffmpegBin, videoFile); // NumFrames = 1499u; // ImagesDir = "/home/boris/droneMov/panopt/valkarra_sunny"; MeshroomCompute.PhotogrammImages( "/home/boris/Meshroom-2019.1.0/meshroom_compute", "/home/boris/Meshroom-2019.1.0/aliceVision/share/aliceVision/cameraSensors.db", "/home/boris/Meshroom-2019.1.0/aliceVision/share/aliceVision/vlfeat_K80L3.SIFT.tree", ImagesDir, timeBase, NumFrames, MeshroomProgress); }
private void parseChapter(string s, ref int i) { if (_chapter is null) { return; } if (i >= Tags.Length) { return; } string arg = findArg(Tags[i], s); if (!(arg is null)) { switch (i) { case 0: { int pos = arg.IndexOf('/'); if (pos > 0) { double denom = 1, nom = 1; bool succ = double.TryParse(arg.Substring(0, pos), out denom); succ = succ && double.TryParse(arg.Substring(pos + 1), out nom); if (succ) { _timebase = new TimeBase(denom, nom); } } break; } case 1: { bool succ = long.TryParse(arg, out long tim); if (succ) { _chapter.Time.Begin = TimeSpan.FromSeconds(tim * _timebase.Denominator / _timebase.Nominator); } break; } case 2: { bool succ = long.TryParse(arg, out long tim); if (succ) { _chapter.Time.End = TimeSpan.FromSeconds(tim * _timebase.Denominator / _timebase.Nominator); } break; } case 3: _chapter.Name = unescape(arg); break; } i++; } }
/// <summary> /// Calculates the time. /// </summary> /// <returns>The time.</returns> /// <param name="timebase">Timebase.</param> /// <param name="marker1">Marker1.</param> /// <param name="marker2">Marker2.</param> /// <param name="frame">Frame.</param> public static double CalculateTime(TimeBase timebase, Marker marker1, Marker marker2, Grid frame) { var pixelsPerDiv = frame.Width / frame.HorizontalDivs; var distance = Math.Abs(marker1.Value - marker2.Value); var divs = distance / pixelsPerDiv; var result = divs * TimeBaseConverter.ToSeconds(timebase); return(result); }
private void cmbIntervals_SelectedIndexChanged(object sender, EventArgs e) { if (mYTime.RangeInterval != TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex)) { mYTime.RangeInterval = TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex); UpdateList(mYTime.RangeInterval); mYTime.ResetColors(); grpRangeOptions.Hide(); } }
const uint CHUNK_DURATION = CHUNK_LENGTH / 2 * 1000; /* in miliseconds */ public static uint FrameCloseTo(uint TimeStamp, TimeBase TimeBase) { var tbNum = (double)TimeBase.Numerator; var tbDen = (double)TimeBase.Denominator; var ts = ((double)TimeStamp) / 1000.0; var frame = (uint)Math.Round(ts * (tbDen / tbNum)) + 1; return(frame); }
public static IEnumerable <IEnumerable <uint> > GetChunks(TimeBase TimeBase, uint LastFrame) { var lastPTS = TimeBase.Numerator * (LastFrame - 1); var lastTimeStamp = (uint)((double)(lastPTS) / (double)TimeBase.Denominator * 1000.0); for (uint ts = 0; ts < lastTimeStamp - CHUNK_DURATION; ts += CHUNK_DURATION) { yield return(KeyFrames(ts, ts + CHUNK_DURATION, TimeBase)); } yield return(KeyFrames(lastTimeStamp - CHUNK_DURATION, lastTimeStamp, TimeBase)); }
public YttDocument(string filePath) { XmlDocument doc = new XmlDocument(); doc.Load(filePath); foreach (XmlElement parElem in doc.SelectNodes("/timedtext/body/p")) { int.TryParse(parElem.GetAttribute("t"), out int startMs); int.TryParse(parElem.GetAttribute("d"), out int durationMs); DateTime start = TimeBase.AddMilliseconds(startMs + SubtitleDelayMs); DateTime end = start.AddMilliseconds(durationMs); Line line = new Line(start, end, parElem.InnerText); Lines.Add(line); } }
public static void PhotogrammImages( string MeshroomComputeBin, string SensorDatabase, string VocTree, string ImagesDir, TimeBase TimeBase, uint LastFrame, ComputeProgress ComputeProgressCB) { var chunks = Chunks.GetChunks(TimeBase, LastFrame); var graphs = MeshroomGraphs(SensorDatabase, VocTree, ImagesDir, chunks); foreach (var graph in graphs) { RunMeshroomCompute(MeshroomComputeBin, ImagesDir, graph, ComputeProgressCB); } /* clean-up last meshroom cache directory */ Utils.RemoveDir(Meshroom.GetCacheDir(ImagesDir)); }
public static bool MeetsCondition( TimeBetweenCondition condition, Player player, Event eventInstance, QuestBase questBase ) { if (condition.Ranges[0] > -1 && condition.Ranges[1] > -1 && condition.Ranges[0] < 1440 / TimeBase.GetTimeBase().RangeInterval&& condition.Ranges[1] < 1440 / TimeBase.GetTimeBase().RangeInterval) { return(Time.GetTimeRange() >= condition.Ranges[0] && Time.GetTimeRange() <= condition.Ranges[1]); } return(true); }
public static void Init() { var timeBase = TimeBase.GetTimeBase(); if (timeBase.SyncTime) { sGameTime = DateTime.Now; } else { sGameTime = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Globals.Rand.Next(0, 24), Globals.Rand.Next(0, 60), Globals.Rand.Next(0, 60) ); } sTimeRange = -1; sUpdateTime = 0; }
/// <summary> /// On PC, the first piece of italic text shows up with a noticeable delay: the background appears as usual, /// but for a fraction of a second after that, the text is either shown as non-italic or not shown at all. /// To work around this, we add an invisible italic subtitle at the start to make YouTube eagerly load /// whatever it normally loads lazily. /// </summary> private void AddItalicPrefetch() { Line italicLine = new Line(TimeBase.AddMilliseconds(SubtitleDelayMs), TimeBase.AddMilliseconds(SubtitleDelayMs + 100)) { Position = new PointF(0, 0), AnchorPoint = AnchorPoint.BottomRight }; Section section = new Section("\x200B") { ForeColor = Color.FromArgb(1, 0, 0, 0), BackColor = Color.Empty, Italic = true }; italicLine.Sections.Add(section); Lines.Add(italicLine); }
public static IEnumerable <IEnumerable <uint> > GetChunks(TimeBase TimeBase, uint LastFrame) { var lastPTS = TimeBase.Numerator * (LastFrame - 1); var lastTimeStamp = (uint)((double)(lastPTS) / (double)TimeBase.Denominator * 1000.0); var frames = KeyFrames(0, lastTimeStamp, TimeBase).ToArray(); int ChunkNums, Overlap; GetChunkParameters(frames.Length, out ChunkNums, out Overlap); for (int chunk = 0; chunk < ChunkNums; chunk += 1) { //TODO: take care of the last chunk, as right now it can potentionally be shorter // then CHUNK_LENGTH, it needs to be moved 'left' a bit more then Overlap var start = chunk * (CHUNK_LENGTH - Overlap); yield return(frames.Skip(start).Take(CHUNK_LENGTH)); } }
private static float ReferenceTime(TimeBase timebase, float fps) { switch (timebase) { case TimeBase.FixedDeltaTime: return(Time.fixedDeltaTime * fps); case TimeBase.UnscaledDeltaTime: return(Time.unscaledDeltaTime * fps); case TimeBase.UnscaledFixedDeltaTime: return(Time.fixedUnscaledDeltaTime * fps); case TimeBase.DeltaTime: return(Time.deltaTime * fps); default: return(1.0f); } }
public void InitEditor(TimeBase time) { //Create a backup in case we want to revert mYTime = time; mBackupTime = new TimeBase(); mBackupTime.LoadFromJson(time.GetInstanceJson()); mTileBackbuffer = new Bitmap(pnlColor.Width, pnlColor.Height); UpdateList(TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex)); typeof(Panel).InvokeMember( "DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, pnlColor, new object[] { true } ); chkSync.Checked = mYTime.SyncTime; txtTimeRate.Text = mYTime.Rate.ToString(); cmbIntervals.SelectedIndex = TimeBase.GetIntervalIndex(mYTime.RangeInterval); UpdateList(mYTime.RangeInterval); txtTimeRate.Enabled = !mYTime.SyncTime; }
public static void PhotogrammImages( string MeshroomComputeBin, string SensorDatabase, string VocTree, string ImagesDir, TimeBase TimeBase, uint LastFrame, ComputeProgress ComputeProgressCB, AutoResetEvent AbortEvent) { var chunks = FrameChunks.GetChunks(TimeBase, LastFrame); var graphs = MeshroomGraphs(SensorDatabase, VocTree, ImagesDir, chunks); int chunkNum = 0; foreach (var graph in graphs) { RunMeshroomCompute(MeshroomComputeBin, ImagesDir, graph, chunkNum, (done) => ComputeProgressCB(chunkNum, done), AbortEvent); chunkNum += 1; } /* clean-up last meshroom cache directory */ RemoveCacheDir(ImagesDir, chunkNum); }
/// <summary> /// On PC, the first piece of italic text shows up with a noticeable delay: the background appears instantly, /// but during a fraction of a second after that, the text is either shown as non-italic or not shown at all. /// To work around this, we add an invisible italic subtitle at the start to make YouTube eagerly load /// whatever it normally loads lazily. /// </summary> private void AddItalicPrefetch() { if (!Lines.SelectMany(l => l.Sections).Any(s => s.Italic)) { return; } Line italicLine = new Line(TimeBase.AddMilliseconds(SubtitleDelayMs + 5000), TimeBase.AddMilliseconds(SubtitleDelayMs + 5100)) { Position = new PointF(0, 0), AnchorPoint = AnchorPoint.BottomRight }; Section section = new Section("\x200B") { ForeColor = Color.FromArgb(1, 0, 0, 0), BackColor = Color.Empty, Italic = true }; italicLine.Sections.Add(section); Lines.Add(italicLine); }
public static double ToSeconds(TimeBase timeBase) { return(timeBaseValues [(int)timeBase]); }
public static string ToString(TimeBase timeBase) { double seconds = TimeBaseConverter.ToSeconds(timeBase); return(String.Format("{0}/div", TimeConverter.ToString(seconds, 0))); }
public VisualMachine(IApplication application, string path, MemoryBase memory, int min_mem_size, IComplexOperation icomplex, TimeBase time, IDevice idevice, INetControl inet, int cache_size, int core_num, int stack_size) : base(application, path, memory, min_mem_size, icomplex, time, idevice, inet, cache_size, core_num, stack_size) { }
public static Color GetTimeColor() { return(TimeBase.GetTimeBase().DaylightHues[sTimeRange]); }
private void UpdateFormElements(ConditionTypes type) { grpVariable.Hide(); grpHasItem.Hide(); grpSpell.Hide(); grpClass.Hide(); grpLevelStat.Hide(); grpSelfSwitch.Hide(); grpPowerIs.Hide(); grpTime.Hide(); grpStartQuest.Hide(); grpQuestInProgress.Hide(); grpQuestCompleted.Hide(); grpGender.Hide(); grpMapIs.Hide(); grpEquippedItem.Hide(); grpFreeInventorySlots.Hide(); switch (type) { case ConditionTypes.VariableIs: grpVariable.Show(); cmbCompareGlobalVar.Items.Clear(); cmbCompareGlobalVar.Items.AddRange(ServerVariableBase.Names); cmbComparePlayerVar.Items.Clear(); cmbComparePlayerVar.Items.AddRange(PlayerVariableBase.Names); cmbBooleanGlobalVariable.Items.Clear(); cmbBooleanGlobalVariable.Items.AddRange(ServerVariableBase.Names); cmbBooleanPlayerVariable.Items.Clear(); cmbBooleanPlayerVariable.Items.AddRange(PlayerVariableBase.Names); break; case ConditionTypes.HasItem: grpHasItem.Show(); cmbItem.Items.Clear(); cmbItem.Items.AddRange(ItemBase.Names); break; case ConditionTypes.ClassIs: grpClass.Show(); cmbClass.Items.Clear(); cmbClass.Items.AddRange(ClassBase.Names); break; case ConditionTypes.KnowsSpell: grpSpell.Show(); cmbSpell.Items.Clear(); cmbSpell.Items.AddRange(SpellBase.Names); break; case ConditionTypes.LevelOrStat: grpLevelStat.Show(); break; case ConditionTypes.SelfSwitch: grpSelfSwitch.Show(); break; case ConditionTypes.AccessIs: grpPowerIs.Show(); break; case ConditionTypes.TimeBetween: grpTime.Show(); cmbTime1.Items.Clear(); cmbTime2.Items.Clear(); var time = new DateTime(2000, 1, 1, 0, 0, 0); for (var i = 0; i < 1440; i += TimeBase.GetTimeBase().RangeInterval) { var addRange = time.ToString("h:mm:ss tt") + " " + Strings.EventConditional.to + " "; time = time.AddMinutes(TimeBase.GetTimeBase().RangeInterval); addRange += time.ToString("h:mm:ss tt"); cmbTime1.Items.Add(addRange); cmbTime2.Items.Add(addRange); } break; case ConditionTypes.CanStartQuest: grpStartQuest.Show(); cmbStartQuest.Items.Clear(); cmbStartQuest.Items.AddRange(QuestBase.Names); break; case ConditionTypes.QuestInProgress: grpQuestInProgress.Show(); cmbQuestInProgress.Items.Clear(); cmbQuestInProgress.Items.AddRange(QuestBase.Names); break; case ConditionTypes.QuestCompleted: grpQuestCompleted.Show(); cmbCompletedQuest.Items.Clear(); cmbCompletedQuest.Items.AddRange(QuestBase.Names); break; case ConditionTypes.NoNpcsOnMap: break; case ConditionTypes.GenderIs: grpGender.Show(); break; case ConditionTypes.MapIs: grpMapIs.Show(); break; case ConditionTypes.IsItemEquipped: grpEquippedItem.Show(); cmbEquippedItem.Items.Clear(); cmbEquippedItem.Items.AddRange(ItemBase.Names); break; case ConditionTypes.HasFreeInventorySlots: grpFreeInventorySlots.Show(); break; default: throw new ArgumentOutOfRangeException(); } }
public object Time() { return(TimeBase.GetTimeBase()); }
//TimeDataPacket private static void HandlePacket(TimeDataPacket packet) { TimeBase.GetTimeBase().LoadFromJson(packet.TimeJson); }
/// <summary> /// 天宇虚拟机默认框架构造函数 /// </summary> /// <param name="application">上层应用程序接口</param> /// <param name="path">初始启动文件路径</param> /// <param name="memory">内存接口</param> /// <param name="icomplex">复杂运算接口</param> /// <param name="time">时间接口</param> /// <param name="idevice">设备接口</param> /// <param name="inet">网络接口</param> public VisualMachine(IApplication application, string path, MemoryBase memory, IComplexOperation icomplex, TimeBase time, IDevice idevice, INetControl inet) : base(application, path, memory, 16, icomplex, time, idevice, inet, 3, 1, 100) { }
public static Vector3 FIR3(Vector3 previous, Vector3 current, float smoothness = 0.9f, TimeBase timebase = TimeBase.DeltaTime, float fps = 60.0f) { var k = Mathf.Pow(smoothness, ReferenceTime(timebase, fps)); return(previous * k + (1.0f - k) * current); }