public override void FixedDisplay(double time) { if (!m_output) { return; } if (double.IsNaN(m_current_pp.RealTimePP)) { m_current_pp.RealTimePP = 0; } if (double.IsNaN(m_current_pp.FullComboPP)) { m_current_pp.FullComboPP = 0; } if (double.IsNaN(m_speed.RealTimePP)) { m_speed.RealTimePP = 0; } if (double.IsNaN(m_speed.FullComboPP)) { m_speed.FullComboPP = 0; } m_current_pp = SmoothMath.SmoothDampPPTuple(m_current_pp, m_target_pp, ref m_speed, time); var formatter = GetFormattedPP(m_current_pp); string str = formatter.ToString(); if (m_win != null) { m_win.PPContext = formatter.ToString(); } }
public override void FixedDisplay(double time) { if (!_output) { return; } if (double.IsNaN(_currentPp.RealTimePP)) { _currentPp.RealTimePP = 0; } if (double.IsNaN(_currentPp.FullComboPP)) { _currentPp.FullComboPP = 0; } if (double.IsNaN(_speed.RealTimePP)) { _speed.RealTimePP = 0; } if (double.IsNaN(_speed.FullComboPP)) { _speed.FullComboPP = 0; } _currentPp = SmoothMath.SmoothDampPPTuple(_currentPp, Pp, ref _speed, time); var formatter = FormatPp(_currentPp); int len = formatter.CopyTo(0, _ppBuffer, 0); StreamWriter[] streamWriters = new StreamWriter[2]; if (_splited) { streamWriters[0] = new StreamWriter(_mmfs[0].CreateViewStream()); streamWriters[1] = new StreamWriter(_mmfs[1].CreateViewStream()); } else { streamWriters[0] = new StreamWriter(_mmfs[0].CreateViewStream()); streamWriters[1] = streamWriters[0]; } streamWriters[0].Write(_ppBuffer, 0, len); streamWriters[0].Write(!_splited ? '\n' : '\0'); streamWriters[1].Write(_hitBuffer, 0, _hitStrLen); streamWriters[1].Write('\0'); for (int i = 0; i < _mmfs.Length; i++) { if (_mmfs[i] != null) { streamWriters[i].Dispose(); } } }
public override void FixedDisplay(double time) { if (!_output) { return; } _currentPp = SmoothMath.SmoothDampPPTuple(_currentPp, Pp, ref _speed, time); var formatter = FormatPp(_currentPp); if (_win != null) { _win.PpContext = formatter.ToString(); } _win.Refresh(); }
public override void FixedDisplay(double time) { if (!m_output) { return; } if (double.IsNaN(m_current_pp.RealTimePP)) { m_current_pp.RealTimePP = 0; } if (double.IsNaN(m_current_pp.FullComboPP)) { m_current_pp.FullComboPP = 0; } if (double.IsNaN(m_speed.RealTimePP)) { m_speed.RealTimePP = 0; } if (double.IsNaN(m_speed.FullComboPP)) { m_speed.FullComboPP = 0; } m_current_pp = SmoothMath.SmoothDampPPTuple(m_current_pp, m_target_pp, ref m_speed, time); var formatter = GetFormattedPP(m_current_pp); int len = formatter.CopyTo(0, m_pp_buffer, 0); using (MemoryMappedViewStream stream = m_mmf.CreateViewStream()) { using (var sw = new StreamWriter(stream)) { sw.Write(m_pp_buffer, 0, len); sw.Write('\n'); sw.Write(m_hit_buffer, 0, m_hit_str_len); sw.Write('\0'); } } }
public override void FixedDisplay(double time) => _tuple = SmoothMath.SmoothDampPPTuple(_tuple, Pp, ref _refTuple, 0.033);
public double ExecAst(IAstNode root) { switch (root) { case AstNumberNode numberNode: return(numberNode.Number); case AstVariableNode varNode: if (Constants.TryGetValue(varNode.Id, out var val)) { return(val); } else if (Variables.TryGetValue(varNode.Id, out val)) { return(val); } else { if (Setting.DebugMode) { Sync.Tools.IO.CurrentIO.WriteColor($"[RTPP:Expression]No Variable found (return zero). Variable name: { varNode.Id }", ConsoleColor.Yellow); } return(0); } case AstOpNode opNode: switch (opNode.Op) { case "+": return(ExecAst(opNode.LNode) + ExecAst(opNode.RNode)); case "-": return(ExecAst(opNode.LNode) - ExecAst(opNode.RNode)); case "*": return(ExecAst(opNode.LNode) * ExecAst(opNode.RNode)); case "/": return(ExecAst(opNode.LNode) / ExecAst(opNode.RNode)); case "%": return(ExecAst(opNode.LNode) % ExecAst(opNode.RNode)); case "^": return(Math.Pow(ExecAst(opNode.LNode), ExecAst(opNode.RNode))); case ">": return((ExecAst(opNode.LNode) > ExecAst(opNode.RNode)) ? 1 : 0); case "<": return((ExecAst(opNode.LNode) < ExecAst(opNode.RNode)) ? 1 : 0); case ">=": return((ExecAst(opNode.LNode) >= ExecAst(opNode.RNode)) ? 1 : 0); case "<=": return((ExecAst(opNode.LNode) <= ExecAst(opNode.RNode)) ? 1 : 0); case "==": return(IsNotZero(ExecAst(opNode.LNode) - ExecAst(opNode.RNode)) ? 0 : 1); case "!=": return(IsNotZero(ExecAst(opNode.LNode) - ExecAst(opNode.RNode)) ? 1 : 0); case "!": return(IsNotZero(ExecAst(opNode.LNode)) ? 0 : 1); case "&&": return((IsNotZero(ExecAst(opNode.LNode)) && IsNotZero(ExecAst(opNode.RNode))) ? 1 : 0); case "||": return((IsNotZero(ExecAst(opNode.LNode)) || IsNotZero(ExecAst(opNode.RNode))) ? 1 : 0); } break; case AstFunctionNode funcNode: try { if (funcNode.Id == "set") { AstVariableNode varNode = funcNode.Args[0] as AstVariableNode; string varName = varNode?.Id ?? throw new ExpressionException($"The \"{funcNode.Id}()\" first parameter is the variable name."); double varVal = ExecAst(funcNode.Args[1]); Variables[varName] = varVal; return(0); } else if (funcNode.Id == "if") { IAstNode condNode = funcNode.Args[0]; double condNodeResult = ExecAst(condNode); if (Math.Abs(condNodeResult) <= 1e-5) { //false_expr return(ExecAst(funcNode.Args[2])); } else { //true_expr return(ExecAst(funcNode.Args[1])); } } else if (funcNode.Id == "smooth") { AstVariableNode varNode = funcNode.Args[0] as AstVariableNode; string varName = varNode?.Id ?? throw new ExpressionException($"The \"{funcNode.Id}()\" first parameter is the variable name."); double varVal = ExecAst(funcNode.Args[0]); return(SmoothMath.SmoothVariable(varName, varVal)); } else { if (Functions.TryGetValue(funcNode.Id, out var func)) { return(func(ComputeArgs(funcNode.Args))); } else { throw new ExpressionException($"No function found. Fucntion: {funcNode.Id}"); } } } catch (ArgumentOutOfRangeException) { throw new ExpressionException($"The function is missing a parameter. Fucntion: {funcNode.Id}"); } } return(Double.NaN); }
double GetTestPp(double pp) { double speed = pp - _tPp; return(_tPp = SmoothMath.SmoothDamp(_tPp, pp, ref speed, 0.02, 0.33)); }