public void Init() { textEngine = new GLTextEngine(); if (settings.fontName != font || settings.fontSize != fontSize || settings.fontStyle != fontStyle) { font = settings.fontName; fontSize = settings.fontSize; fontStyle = settings.fontStyle; } textEngine.SetFont(font, fontStyle, fontSize); noteCount = 0; nps = 0; Mnps = 0; frames = 0; Mplph = 0; notesHit = new LinkedList <long>(); Initialized = true; if (settings.saveCsv && settings.csvOutput != "") { outputCsv = new StreamWriter(settings.csvOutput); } Console.WriteLine("Initialised NoteCountRender"); }
public void Init() { textEngine = new GLTextEngine(); if (settings.fontName != font || settings.fontSize != fontSize || settings.fontStyle != fontStyle) { font = settings.fontName; fontSize = settings.fontSize; fontStyle = settings.fontStyle; } textEngine.SetFont(font, fontStyle, fontSize); noteCount = 0; nps = 0; Mnps = 0; frames = 0; Mplph = 0; notesHit = new FastList <long>(); Initialized = true; if (settings.saveCsv && settings.csvOutput != "") { outputCsv = new StreamWriter(settings.csvOutput); } fzp = new string('0', renderSettings.fps.ToString().Length); scaleWidth = 1.0f / renderSettings.width; scaleHeight = -1.0f / renderSettings.height; Console.WriteLine("Initialised NoteCountRender"); }
public RenderWindow(CurrentRendererPointer renderer, MidiFile midi, RenderSettings settings) : base(16, 9, new GraphicsMode(new ColorFormat(8, 8, 8, 8)), "Render", GameWindowFlags.Default, DisplayDevice.Default) { Width = (int)(DisplayDevice.Default.Width / 1.5); Height = (int)((double)Width / settings.width * settings.height); Location = new Point((DisplayDevice.Default.Width - Width) / 2, (DisplayDevice.Default.Height - Height) / 2); textEngine = new GLTextEngine(); render = renderer; this.settings = settings; lastTempo = midi.zerothTempo; lock (render) { render.renderer.LastMidiTimePerTick = (double)midi.zerothTempo / midi.division; midiTime = -render.renderer.NoteScreenTime; tempoFrameStep = ((double)midi.division / lastTempo) * (1000000 / settings.fps); midiTime -= tempoFrameStep * settings.renderSecondsDelay * settings.fps; } pixels = new byte[settings.width * settings.height * 3]; //WindowBorder = WindowBorder.Hidden; globalDisplayNotes = midi.globalDisplayNotes; globalTempoEvents = midi.globalTempoEvents; globalColorEvents = midi.globalColorEvents; this.midi = midi; if (settings.ffRender) { string args = "-hide_banner"; if (settings.includeAudio) { double fstep = ((double)midi.division / lastTempo) * (1000000 / settings.fps); double offset = -midiTime / fstep / settings.fps; args = "" + " -f rawvideo -s " + settings.width + "x" + settings.height + " -pix_fmt rgb24 -r " + settings.fps + " -i -" + " -itsoffset " + offset + " -i \"" + settings.audioPath + "\"" + " -vf vflip -vcodec libx264 -pix_fmt yuv420p -acodec aac"; } else { args = "" + " -f rawvideo -s " + settings.width + "x" + settings.height + " -strict -2" + " -pix_fmt rgb24 -r " + settings.fps + " -i -" + " -vf vflip -vcodec libx264 -pix_fmt yuv420p"; } if (settings.useBitrate) { args += " -b:v " + settings.bitrate + "k" + " -maxrate " + settings.bitrate + "k" + " -minrate " + settings.bitrate + "k"; } else { args += " -preset " + settings.crfPreset + " -crf " + settings.crf; } args += " -y \"" + settings.ffPath + "\""; ffmpeg.StartInfo = new ProcessStartInfo("ffmpeg", args); ffmpeg.StartInfo.RedirectStandardInput = true; ffmpeg.StartInfo.UseShellExecute = false; ffmpeg.StartInfo.RedirectStandardError = true; try { ffmpeg.Start(); Console.OpenStandardOutput(); Regex messageMatch = new Regex("\\[.*@.*\\]"); ffmpeg.ErrorDataReceived += (s, e) => { if (e.Data == null) { return; } if (e.Data.Contains("frame=")) { Console.Write(e.Data); Console.SetCursorPosition(0, Console.CursorTop); } if (e.Data.Contains("Conversion failed!")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("An error occured in FFMPEG, closing!"); Console.ResetColor(); settings.running = false; } if (messageMatch.IsMatch(e.Data)) { Console.WriteLine(e.Data); } }; ffmpeg.BeginErrorReadLine(); } catch (Exception ex) { MessageBox.Show("There was an error starting the ffmpeg process\nNo video will be written\n(Is ffmpeg.exe in the same folder as this program?)\n\n\"" + ex.Message + "\""); settings.ffRender = false; } } else if (settings.imgRender) { if (!Directory.Exists(settings.imgPath)) { Directory.CreateDirectory(settings.imgPath); } } else { if (!settings.vsync) { VSync = VSyncMode.Off; } } finalCompositeBuff = new GLPostbuffer(settings); GL.GenBuffers(1, out screenQuadBuffer); GL.GenBuffers(1, out screenQuadIndexBuffer); GL.BindBuffer(BufferTarget.ArrayBuffer, screenQuadBuffer); GL.BufferData( BufferTarget.ArrayBuffer, (IntPtr)(screenQuadArray.Length * 8), screenQuadArray, BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, screenQuadIndexBuffer); GL.BufferData( BufferTarget.ElementArrayBuffer, (IntPtr)(screenQuadArrayIndex.Length * 4), screenQuadArrayIndex, BufferUsageHint.StaticDraw); postShader = MakeShader(postShaderVert, postShaderFrag); }