public static void RTTick(object sender, EventArgs e) { try { MainWindow.KMCDialogs.MIDIImport.InitialDirectory = Properties.Settings.Default.LastMIDIFolder; if (!MainWindow.KMCStatus.IsKMCBusy) { RTF.KMCIdle(); } else { if (!MainWindow.KMCStatus.IsKMCNowExporting) { RTF.KMCMemoryAllocation(); } else { RTF.KMCBusy(); } } System.Threading.Thread.Sleep(1); } catch (Exception ex) { BasicFunctions.WriteToConsole(ex); } }
public static void PerformUpdate() { if (Properties.Settings.Default.AutoUpdateCheck) { BasicFunctions.CheckForUpdates(true); } }
// Code by Mac Gravell, edited by Keppy // https://stackoverflow.com/a/929418 static IEnumerable <String> GetFiles(String Target) { Queue <string> AnalyzeQueue = new Queue <string>(); // Add target of queue to the queue AnalyzeQueue.Enqueue(Target); // Do this while the queue list still contains items while (AnalyzeQueue.Count > 0) { // Dequeue the item that is going to be analyzed Target = AnalyzeQueue.Dequeue(); try { // Add each subdir to the queue if (CheckStop) { break; } foreach (string subDir in Directory.GetDirectories(Target)) { if (CheckStop) { break; } AnalyzeQueue.Enqueue(subDir); } } catch (Exception ex) { BasicFunctions.WriteToConsole(ex); } string[] Files = null; try { // Add files from the directory of the queued item Files = Directory.GetFiles(Target); } catch (Exception ex) { BasicFunctions.WriteToConsole(ex); } // If the function detected items, return them to the calling foreach loop if (Files != null) { for (int i = 0; i < Files.Length; i++) { if (CheckStop) { break; } yield return(Files[i]); } } // If the queued item is actually a direct path to the file, return it to the foreach loop if (File.Exists(Target)) { yield return(Target); } } }
private void InfoDialog_Load(object sender, EventArgs e) { ComputerInfo CI = new ComputerInfo(); String Version = String.Format("{0}.{1}.{2}", Converter.FileMajorPart, Converter.FileMinorPart, Converter.FileBuildPart); TaCI.Text = String.Format(Languages.Parse("TaCI"), Converter.FileMajorPart, DateTime.Now.Year, Languages.Parse("0Translators0")); ConverterVer.Text = String.Format("{0} ({1})", Version, (Environment.Is64BitProcess ? "x64, SSE2" : "x86, SSE")); BASSVer.Text = ReturnBASSAssemblyVersion(BASS.FileVersion, BASS.FilePrivatePart); BASSMIDIVer.Text = ReturnBASSAssemblyVersion(BASSMIDI.FileVersion, BASSMIDI.FilePrivatePart); CompilerDate.Text = BasicFunctions.GetLinkerTime(Assembly.GetExecutingAssembly(), TimeZoneInfo.Utc).ToString(Languages.ReturnCulture(false, null)); OSInfo.OSVERSIONINFOEX osVersionInfo = new OSInfo.OSVERSIONINFOEX { dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSInfo.OSVERSIONINFOEX)) }; if (Properties.Settings.Default.IsItPreRelease) { ConverterVer.Text += " (PRERELEASE)"; } WindowsName.Text = String.Format("{0} ({1})", OSInfo.Name, Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit"); if (Environment.OSVersion.Version.Major == 10) // If OS is Windows 10, get UBR too { WindowsBuild.Text = String.Format(Languages.Parse("W10VerRev"), CurrentVerKey.GetValue("ReleaseId", 0).ToString(), CurrentVerKey.GetValue("UBR", 0).ToString()); } else // Else, give normal version number { if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor > 1) { WindowsBuild.Text = String.Format("{0}.{1}.{2}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.OSVersion.Version.Build); } else { int SP = Int32.Parse(Regex.Match(Environment.OSVersion.ServicePack, @"\d+").Value, NumberFormatInfo.InvariantInfo); if (SP > 0) { WindowsBuild.Text = String.Format("{0}.{1}.{2} ({3})", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.OSVersion.Version.Build, Environment.OSVersion.ServicePack); } else { WindowsBuild.Text = String.Format("{0}.{1}.{2}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.OSVersion.Version.Build); } } } }
public static void BASSCloseStream(string message, string title, int type) { // Reset ReleaseResources(false, true); // Show message if (type == 0) { if (Properties.Settings.Default.ShowBalloon) { MainWindow.Delegate.Invoke((MethodInvoker) delegate { NotifyArea.ShowStatusTray(title, message, ToolTipIcon.Info); }); } else { MainWindow.Delegate.Invoke((MethodInvoker) delegate { MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }); } } else { if (Properties.Settings.Default.ShowBalloon) { MainWindow.Delegate.Invoke((MethodInvoker) delegate { NotifyArea.ShowStatusTray(title, message, ToolTipIcon.Info); }); } } // Last stuff then BOOPERS MainWindow.KMCGlobals.CancellationPendingValue = MainWindow.KMCConstants.IDLE; MainWindow.KMCGlobals.CurrentStatusTextString = null; BasicFunctions.PlayConversionStop(); }
private void pictureBox1_Click(object sender, EventArgs e) { BasicFunctions.Donate(); }
public static void PBRWork(object sender, DoWorkEventArgs e) { try { try { BasicFunctions.PlayConversionStart(); // First of all, initialize BASS itself BASSControl.BASSInitSystem(true); BASSControl.InitializeDummyVSTs(); foreach (String str in MainWindow.KMCGlobals.MIDIs) { // Initialize RT stuff Double[] CustomFramerates; BasicFunctions.ReturnCustomFramerate(out CustomFramerates); MainWindow.FPSSimulator.NextDouble(); // Initialize BASS stream BASSControl.BASSStreamSystemRT(str, true); BASSControl.BASSLoadSoundFonts(str); BASSControl.BASSInitVSTiIfNeeded(true); BASSControl.InitializeVSTsForStream(); BASSControl.BASSEffectSettings(); BASSControl.BASSVolumeSlideInit(); // Get length of the stream Int64 pos = 0, es = 0; // Notes stuff MainWindow.KMCStatus.PlayedNotes = 0; if (!MainWindow.KMCGlobals.DoNotCountNotes) { try { MainWindow.KMCGlobals._mySync = new SYNCPROC(BASSControl.NoteSyncProc); Bass.BASS_ChannelSetSync(MainWindow.KMCGlobals._recHandle, BASSSync.BASS_SYNC_MIDI_EVENT, (Int64)BASSMIDIEvent.MIDI_EVENT_NOTE, MainWindow.KMCGlobals._mySync, IntPtr.Zero); MainWindow.KMCStatus.TotalNotesOrg = 0; MainWindow.KMCStatus.TotalNotes = MainWindow.KMCStatus.TotalNotesOrg; } catch (Exception ex) { BasicFunctions.WriteToConsole(ex); MainWindow.KMCGlobals.DoNotCountNotes = true; } } // KMC is now busy MainWindow.KMCStatus.IsKMCNowExporting = true; BassWasapi.BASS_WASAPI_Start(); while (CheckStreamStatus() != BASSActive.BASS_ACTIVE_STOPPED) { if (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER) { BASSControl.BASSPlayBackEngineRT(CustomFramerates, ref pos, ref es); } else { break; } TimerFuncs.MicroSleep(-1); } BASSControl.ReleaseResources( (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER), (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ); if (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) { break; } } MainWindow.KMCStatus.RenderingMode = false; MainWindow.KMCStatus.IsKMCBusy = false; MainWindow.KMCStatus.IsKMCNowExporting = false; MainWindow.KMCGlobals.VSTSkipSettings = false; String Msg = (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ? "PlaybackAborted" : "PlaybackCompleted"; BASSControl.BASSCloseStream(Languages.Parse(Msg), Languages.Parse(Msg), 0); BasicFunctions.PlayConversionStop(); } catch (Exception exception) { BasicFunctions.WriteToConsole(exception); BASSControl.ReleaseResources(false, true); } } catch (Exception exception2) { BASSControl.BASSCloseStreamException(exception2); } }
public static void CPRWork(object sender, DoWorkEventArgs e) { try { try { BasicFunctions.PlayConversionStart(); // First of all, initialize BASS itself BASSControl.BASSInitSystem(false); BASSControl.InitializeDummyVSTs(); foreach (String str in MainWindow.KMCGlobals.MIDIs) { // Initialize RT stuff Double[] CustomFramerates; BasicFunctions.ReturnCustomFramerate(out CustomFramerates); MainWindow.FPSSimulator.NextDouble(); // Initialize BASS stream BASSControl.BASSStreamSystemRT(str, false); BASSControl.BASSLoadSoundFonts(str); BASSControl.BASSInitVSTiIfNeeded(false); BASSControl.InitializeVSTsForStream(); BASSControl.BASSEffectSettings(); BASSControl.BASSVolumeSlideInit(); BASSControl.BASSEncoderInit(MainWindow.KMCGlobals.CurrentEncoder, str); // Get length of the stream Int64 pos = 0, es = 0; // KMC is now busy MainWindow.KMCStatus.IsKMCNowExporting = true; for (pos = 0, es = 0; ;) { if (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER) { if (!BASSControl.BASSEncodingEngineRT(CustomFramerates, ref pos, ref es)) { break; } } else { break; } } BASSControl.ReleaseResources( (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER), (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ); if (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) { break; } } MainWindow.KMCStatus.RenderingMode = false; MainWindow.KMCStatus.IsKMCBusy = false; MainWindow.KMCStatus.IsKMCNowExporting = false; MainWindow.KMCGlobals.VSTSkipSettings = false; String Msg = (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ? "ConversionAborted" : "ConversionCompleted"; BASSControl.BASSCloseStream(Languages.Parse(Msg), Languages.Parse(Msg), 0); if (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) { if (MainWindow.KMCGlobals.AutoShutDownEnabled == true) { Process.Start(new ProcessStartInfo("shutdown", "/s /t 0") { CreateNoWindow = true, UseShellExecute = false }); } if (MainWindow.KMCGlobals.AutoClearMIDIListEnabled) { MainWindow.Delegate.Invoke((MethodInvoker) delegate { MainWindow.Delegate.MIDIList.Items.Clear(); }); } } BasicFunctions.PlayConversionStop(); } catch (Exception exception) { BasicFunctions.WriteToConsole(exception); BASSControl.ReleaseResources(false, true); } } catch (Exception exception2) { BASSControl.BASSCloseStreamException(exception2); } }
public static void CPWork(object sender, DoWorkEventArgs e) { try { try { BasicFunctions.PlayConversionStart(); // First of all, initialize BASS itself BASSControl.BASSInitSystem(false); BASSControl.InitializeDummyVSTs(); foreach (String str in MainWindow.KMCGlobals.MIDIs) { // Initialize BASS stream BASSControl.BASSStreamSystem(str, false); BASSControl.BASSLoadSoundFonts(str); BASSControl.BASSInitVSTiIfNeeded(false); BASSControl.InitializeVSTsForStream(); BASSControl.BASSEffectSettings(); BASSControl.BASSVolumeSlideInit(); BASSControl.BASSEncoderInit(MainWindow.KMCGlobals.CurrentEncoder, str); // Get length of the stream Int64 pos = Bass.BASS_ChannelGetLength(MainWindow.KMCGlobals._recHandle); Int64 length = Convert.ToInt64(Bass.BASS_ChannelSeconds2Bytes(MainWindow.KMCGlobals._recHandle, 0.0275)); // KMC is now busy MainWindow.KMCStatus.IsKMCNowExporting = true; while (BASSControl.BASSEncodingEngine(pos, length)) { if (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) { break; } } BASSControl.ReleaseResources( (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER), (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ); if (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) { break; } } MainWindow.KMCStatus.RenderingMode = false; MainWindow.KMCStatus.IsKMCBusy = false; MainWindow.KMCStatus.IsKMCNowExporting = false; MainWindow.KMCGlobals.VSTSkipSettings = false; String Msg = (MainWindow.KMCGlobals.CancellationPendingValue == MainWindow.KMCConstants.CANCELLED_BY_USER) ? "ConversionAborted" : "ConversionCompleted"; BASSControl.BASSCloseStream(Languages.Parse(Msg), Languages.Parse(Msg), 0); if (MainWindow.KMCGlobals.CancellationPendingValue != MainWindow.KMCConstants.CANCELLED_BY_USER) { if (MainWindow.KMCGlobals.AutoShutDownEnabled == true) { Process.Start(new ProcessStartInfo("shutdown", "/s /t 0") { CreateNoWindow = true, UseShellExecute = false }); } if (MainWindow.KMCGlobals.AutoClearMIDIListEnabled) { MainWindow.Delegate.Invoke((MethodInvoker) delegate { MainWindow.Delegate.MIDIList.Items.Clear(); }); } } BasicFunctions.PlayConversionStop(); } catch (Exception exception) { BASSControl.BASSCloseStreamException(exception); } } catch (Exception exception2) { BASSControl.BASSCloseStreamException(exception2); } }
private void STDWD_Click(object sender, EventArgs e) { BasicFunctions.Donate(); }
private void MoveDown_Click(object sender, EventArgs e) { BasicFunctions.MoveListViewItems(MIDIList, BasicFunctions.MoveDirection.Down); }
private void CFU_Click(object sender, EventArgs e) { BasicFunctions.CheckForUpdates(false); }
private void PlayConversionFail() { BasicFunctions.PlayConverterError(); }