Example #1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            // Initialize the menu
            Menu = ConverterMenu;

            // Initialize context menu for MIDIs list
            MIDIList.ContextMenu = ListMenu;

            Title = Text;
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            // Initialize threads
            KMCThreads.ConversionProcess.DoWork   += ConverterFunctions.CPWork;
            KMCThreads.ConversionProcessRT.DoWork += ConverterFunctions.CPRWork;
            KMCThreads.PlaybackProcess.DoWork     += ConverterFunctions.PBWork;
            KMCThreads.PlaybackProcessRT.DoWork   += ConverterFunctions.PBRWork;

            // Notification icon in the system tray
            if (Properties.Settings.Default.MinimizeToTray || Properties.Settings.Default.ShowBalloon)
            {
                NotifyArea.ShowIconTray();
            }

            // Initialize values
            for (int i = 0; i < 8; i++)
            {
                VSTs.VSTInfo[i] = new BASS_VST_INFO();
            }

            try
            {
                // Generic settings
                VolumeBar.Value = Convert.ToInt32(Properties.Settings.Default.Volume * 10000.0f).LimitToRange(0, 10000);

                // Load settings
                CSFFS.Checked          = Properties.Settings.Default.AudioEvents;
                ACFUWSTC.Checked       = Properties.Settings.Default.AutoUpdateCheck;
                SCPIOTL.Checked        = Properties.Settings.Default.ShowOldTimeInfo;
                RenderStandard.Checked = !Properties.Settings.Default.RealTimeSimulator;
                RenderRTS.Checked      = Properties.Settings.Default.RealTimeSimulator;
                SBIOMB.Checked         = Properties.Settings.Default.ShowBalloon;
                AFIT.Checked           = Properties.Settings.Default.AskForIgnoreTracks;
                MTT.Checked            = Properties.Settings.Default.MinimizeToTray;
                ChangeLanguage.Enabled = !Program.DebugLang;

                KMCThreads.GarbageCollector.DoWork += BasicFunctions.GCWork;
                KMCThreads.GarbageCollector.RunWorkerAsync();

                KMCThreads.GetInfoWorker.DoWork += ConverterFunctions.GIWWork;
                KMCThreads.GetInfoWorker.RunWorkerAsync();

                KMCThreads.RenderingTimer.Tick    += ConverterFunctions.RTTick;
                KMCThreads.RenderingTimer.Interval = 10;
                KMCThreads.RenderingTimer.Enabled  = true;
                KMCThreads.RenderingTimer.Start();
            }
            catch (Exception exception2)
            {
                ErrorHandler errordialog = new ErrorHandler(Languages.Parse("FatalError"), exception2.ToString(), 1, 0);
                errordialog.ShowDialog();
            }

            //Check if there are soundfonts
            if (SoundFonts != null)
            {
                SoundFontChain.SoundFonts = new String[SoundFonts.Count];
                SoundFonts.CopyTo(SoundFontChain.SoundFonts, 0);

                foreach (String SF in SoundFonts)
                {
                    KMCDialogs.SFDialog.SFList.Items.Add(SF);
                }
            }

            // Check if there are MIDIs
            if (MIDIs != null)
            {
                new AddingMIDIs(MIDIs.ToArray(), true).ShowDialog();
            }
        }
Example #2
0
        public static bool ConfirmExit()
        {
            // Confirm user wants to close
            if (Bass.BASS_ChannelIsActive(KMCGlobals._recHandle) == BASSActive.BASS_ACTIVE_PLAYING)
            {
                DialogResult dialogResult = MessageBox.Show(Languages.Parse("AppBusy"), Languages.Parse("HeyYou"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (dialogResult == DialogResult.Yes)
                {
                    return(true);
                }
                else if (dialogResult == DialogResult.No)
                {
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Example #3
0
 public static void ToAddOrNotToAdd(ListViewItem lvi, string notes, string str)
 {
     if (notes == "0" || GetMIDILength(str) == -1)
     {
         MainWindow.Delegate.Invoke((MethodInvoker) delegate { MessageBox.Show(String.Format(Languages.Parse("InvalidMIDIFile"), Path.GetFileName(str)), Languages.Parse("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); });
     }
     else
     {
         MainWindow.Delegate.Invoke((MethodInvoker) delegate { MainWindow.Delegate.MIDIList.Items.Add(lvi); });
     }
 }
Example #4
0
        public static void InitializeLanguage()
        {
            Delegate.Text = String.Format(Delegate.Text, Program.Who, Program.Title);

            // Dialogs
            KMCDialogs.MIDIImport.Title          = Languages.Parse("ImportMIDIWindow");
            KMCDialogs.MIDIImport.Filter         = String.Format("{0}|*.mid;*.midi;*.kar;*.rmi;*.riff", Languages.Parse("MIDIFiles"));
            KMCDialogs.MIDIImport.Multiselect    = true;
            KMCDialogs.MIDIExport.Title          = Languages.Parse("ExportMIDIWindow");
            KMCDialogs.MIDIExport.IsFolderPicker = true;

            // MIDIs list
            Delegate.MIDIList.Columns.Clear();
            Delegate.MIDIList.Columns.Add(Languages.Parse("MIDIFile"), 1, HorizontalAlignment.Left);
            Delegate.MIDIList.Columns.Add(Languages.Parse("MIDINotes"), 1, HorizontalAlignment.Left);
            Delegate.MIDIList.Columns.Add(Languages.Parse("MIDITracks"), 1, HorizontalAlignment.Left);
            Delegate.MIDIList.Columns.Add(Languages.Parse("MIDILength"), 1, HorizontalAlignment.Left);
            Delegate.MIDIList.Columns.Add(Languages.Parse("MIDISize"), 1, HorizontalAlignment.Left);
            Delegate.MIDIList.Columns[0].Tag = 5.9;
            Delegate.MIDIList.Columns[1].Tag = 1.0;
            Delegate.MIDIList.Columns[2].Tag = 0.80;
            Delegate.MIDIList.Columns[3].Tag = 1.0;
            Delegate.MIDIList.Columns[4].Tag = 1.0;
            Delegate.MIDIList_SizeChanged(Delegate.MIDIList, new EventArgs());

            // Strips
            Delegate.ActionsStrip.Text = Languages.Parse("ActionsStrip");
            Delegate.OptionsStrip.Text = Languages.Parse("OptionsStrip");
            Delegate.HelpStrip.Text    = Languages.Parse("HelpStrip");

            // Actions Strip
            Delegate.ImportMIDIs.Text      = Languages.Parse("ImportMIDIs");
            Delegate.RemoveMIDIs.Text      = Languages.Parse("RemoveMIDIs");
            Delegate.ClearList.Text        = Languages.Parse("ClearList");
            Delegate.OpenSFVSTManager.Text = Languages.Parse("OpenSFVSTManager");
            Delegate.RenderToWAV.Text      = String.Format("{0} {1} ({2})", Languages.Parse("RenderTo"), ".WAV", "Wave");
            Delegate.RenderToOGG.Text      = String.Format("{0} {1} ({2})", Languages.Parse("RenderTo"), ".OGG", "Vorbis");
            Delegate.RenderToLAME.Text     = String.Format("{0} {1} ({2})", Languages.Parse("RenderTo"), ".MP3", "LAME");
            Delegate.PreviewFiles.Text     = Languages.Parse("PreviewFiles");
            Delegate.AbortConversion.Text  = Languages.Parse("AbortConversion");
            Delegate.Exit.Text             = Languages.Parse("Exit");

            // Options strip
            Delegate.RenderMode.Text      = Languages.Parse("RenderMode");
            Delegate.RenderStandard.Text  = Languages.Parse("RenderStandard");
            Delegate.RenderRTS.Text       = Languages.Parse("RealTimeSim");
            Delegate.NoAffectPreview.Text = Languages.Parse("NoAffectPreview");
            Delegate.ACFUWSTC.Text        = Languages.Parse("ACFUWSTC");
            Delegate.ASAR.Text            = Languages.Parse("ASAR");
            Delegate.CMLAR.Text           = Languages.Parse("CMLAR");
            Delegate.SCPIOTL.Text         = Languages.Parse("SCPIOTL");
            Delegate.CSFFS.Text           = Languages.Parse("CSFFS");
            Delegate.SBIOMB.Text          = Languages.Parse("SBIOMB");
            Delegate.MTT.Text             = Languages.Parse("MTT");
            Delegate.SVDS.Text            = Languages.Parse("SVDS");
            Delegate.AFIT.Text            = Languages.Parse("AFIT");
            Delegate.ChangeLanguage.Text  = Languages.Parse("ChangeLanguage");

            // Help strip
            Delegate.IATP.Text    = Languages.Parse("IATP");
            Delegate.STDWD.Text   = Languages.Parse("STDWD");
            Delegate.KK99GP.Text  = Languages.Parse("KK99GP");
            Delegate.KK99YTC.Text = Languages.Parse("KK99YTC");
            Delegate.JKSUS.Text   = Languages.Parse("JKSUS");

            // VSTi strip
            Delegate.VSTiSettings.Text = Languages.Parse("VSTiSettings");

            // MIDIs list context strip
            Delegate.AutoResizeColumns.Text = Languages.Parse("AutoResizeColumns");
            Delegate.ImportMIDIsC.Text      = Languages.Parse("ImportMIDIs");
            Delegate.RemoveMIDIsC.Text      = Languages.Parse("RemoveMIDIs");
            Delegate.ClearListC.Text        = Languages.Parse("ClearList");
            Delegate.SortName.Text          = Languages.Parse("SortName");
            Delegate.MoveUp.Text            = Languages.Parse("MoveUp");
            Delegate.MoveDown.Text          = Languages.Parse("MoveDown");

            // The rest of the controls
            Delegate.VolumeLabel.Text  = String.Format("{0}:", Languages.Parse("Volume"));
            Delegate.OpenSettings.Text = Languages.Parse("OpenSettings");
        }
Example #5
0
 private void InitializeLanguage()
 {
     Text                       = Languages.Parse("ParsingMIDIInfo");
     CancelBtn.Text             = Languages.Parse("CancelBtn");
     ParsingMIDIInfoStatus.Text = Languages.Parse("ParsingMIDIInfoPrepare");
 }
Example #6
0
        public static void CheckForUpdates(Boolean Startup)
        {
            if (!AlreadyChecking)
            {
                new Thread(() =>
                {
                    AlreadyChecking = true;
                    Thread.CurrentThread.IsBackground = true;

                    WebClient client;
                    Stream stream;
                    try
                    {
                        client = new WebClient();
                        stream = client.OpenRead("https://raw.githubusercontent.com/KaleidonKep99/Keppys-MIDI-Converter/master/KeppyMIDIConverter/kmcupdate.txt");
                        StreamReader reader       = new StreamReader(stream);
                        String newestversion      = reader.ReadToEnd();
                        FileVersionInfo Converter = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
                        Version.TryParse(newestversion, out Version x);
                        Version.TryParse(Converter.FileVersion.ToString(), out Version y);
                        if (x > y)
                        {
                            while (Application.OpenForms.OfType <MainWindow>().Count() != 1)
                            {
                                Thread.Sleep(1);
                            }

                            MainWindow.Delegate.Invoke((MethodInvoker) delegate {
                                DialogResult dialogResult = MessageBox.Show(String.Format(Languages.Parse("UpdateFound"), Program.Who, Program.Title, Converter.FileVersion, newestversion), String.Format(Languages.Parse("UpdateFoundTitle"), Program.Who, Program.Title), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                if (dialogResult == DialogResult.Yes)
                                {
                                    UpdateDownloader frm = new UpdateDownloader(newestversion)
                                    {
                                        StartPosition = FormStartPosition.CenterScreen
                                    };
                                    frm.ShowDialog();
                                }
                            });
                        }
                        else
                        {
                            if (!Startup)
                            {
                                MainWindow.Delegate.Invoke((MethodInvoker) delegate {
                                    MessageBox.Show(String.Format(Languages.Parse("NoUpdatesFound"), Program.Who, Program.Title), String.Format(Languages.Parse("NoUpdatesFoundTitle"), Program.Who, Program.Title), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                });
                            }
                        }
                    }
                    catch
                    {
                        if (!Startup)
                        {
                            MainWindow.Delegate.Invoke((MethodInvoker) delegate {
                                MessageBox.Show(String.Format(Languages.Parse("NoUpdatesFound"), Program.Who, Program.Title), String.Format(Languages.Parse("NoUpdatesFoundTitle"), Program.Who, Program.Title), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            });
                        }
                    }
                    AlreadyChecking = false;
                }).Start();
            }
        }
Example #7
0
        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);
                    }
                }
            }
        }
Example #8
0
 public static void CheckStartUpArguments(String[] args)
 {
     for (int i = 0; i < args.Length; i++)
     {
         if (args[i].ToLowerInvariant() == "/skipupdate")
         {
             SkipUpdate = true;
         }
         else if (args[i].ToLowerInvariant() == "/avoidtrigger")
         {
             SkipTrigger = true;
         }
         else if (args[i].ToLowerInvariant() == "/resetsettings")
         {
             Properties.Settings.Default.Reset();
             Properties.Settings.Default.Save();
             MessageBox.Show(Languages.Parse("SettingsReset"), "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (args[i].ToLowerInvariant() == "/debug") // DO NOT USE IF NOT NEEDED <.<
         {
             Program.DebugMode = true;
             FileVersionInfo fvi     = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
             string          version = fvi.FileVersion;
             AllocConsole();
             Console.Title           = "Keppy's MIDI Converter Debug Window";
             Console.BackgroundColor = ConsoleColor.Blue;
             Console.ForegroundColor = ConsoleColor.White;
             Console.Write(Properties.Resources.KMCTitle);
             Console.WriteLine();
             Console.WriteLine();
             Console.WriteLine("Keppy's MIDI Converter Debug Window - Version " + version);
             Console.WriteLine("Copyright(C) KaleidonKep99 2013 - " + DateTime.Now.Year.ToString());
             Console.ResetColor();
             Console.WriteLine();
             Console.BackgroundColor = ConsoleColor.Red;
             Console.ForegroundColor = ConsoleColor.White;
             Console.WriteLine("This should only be used when Kep himself asks you to do so. It's not really that useful, if not for debug.");
             Console.WriteLine();
             Console.ResetColor();
             Console.BackgroundColor = ConsoleColor.Green;
             Console.ForegroundColor = ConsoleColor.Black;
             Console.WriteLine("Debug started, waiting for errors...");
             Console.ResetColor();
         }
         else if (args[i].ToLowerInvariant() == "/restorelanguage")
         {
             Properties.Settings.Default.LangOverride = false;
             Properties.Settings.Default.SelectedLang = "en-US";
             Properties.Settings.Default.Save();
             MessageBox.Show("Language succesfully restored.", "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         else if (args[i].ToLowerInvariant() == "/triggerdonation")
         {
             Properties.Settings.Default.NoMoreDonation = false;
             Properties.Settings.Default.Save();
             Form frm = new DonateMonthlyDialog
             {
                 StartPosition = FormStartPosition.CenterScreen
             };
             frm.ShowDialog();
         }
         else if (args[i].ToLowerInvariant().Contains("/"))
         {
             MessageBox.Show(String.Format(Languages.Parse("InvalidArg"), args[i]), Languages.Parse("ArgumentError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
             CloseApp = true;
         }
         else
         {
             break;
         }
     }
 }
Example #9
0
File: RTF.cs Project: walney/KMC
        private static void SetStatus(Int32 Mode)
        {
            if (Mode == 0) // Idle
            {
                SetProgressBar(0);
                MainWindow.Delegate.StatusMsg.Text = Languages.Parse("IdleMessage");

                if (Busy)
                {
                    MainWindow.Delegate.StatusPicture.Image = Properties.Resources.convpause;
                    Busy = false;
                }
                if (PictureSet != 1)
                {
                    MainWindow.Delegate.StatusPicture.BackgroundImage = null;
                    PictureSet = 1;
                }

                if (MainWindow.Delegate.MIDIList.Items.Count < 1)
                {
                    EnableImportButtons();
                    DisableEncoderButtons();
                }
                else
                {
                    if (MainWindow.SoundFontChain.SoundFonts.Length == 0)
                    {
                        DirectoryInfo PathToGenericSF = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        String        FullPath        = String.Format("{0}\\GMGeneric.sf2", PathToGenericSF.Parent.FullName);
                        if (File.Exists(FullPath))
                        {
                            EnableImportButtons();
                            EnableEncoderButtons();
                            DefaultSelectionMenu(0);
                        }
                        else
                        {
                            EnableImportButtons();
                            DisableEncoderButtons();
                            DefaultSelectionMenu(1);
                        }
                    }
                    else
                    {
                        EnableImportButtons();
                        EnableEncoderButtons();
                        DefaultSelectionMenu(0);
                    }
                }
                thisProc.PriorityClass = ProcessPriorityClass.Idle;
            }
            else if (Mode == 1) // Memory allocation
            {
                SetProgressBar(1);

                if (!Busy)
                {
                    MainWindow.Delegate.StatusPicture.Image = Properties.Resources.convbusy;
                    Busy = true;
                }
                if (PictureSet != 0)
                {
                    MainWindow.Delegate.StatusPicture.BackgroundImage = Properties.Resources.convfiles;
                    PictureSet = 0;
                }

                if (MainWindow.KMCStatus.RenderingMode)
                {
                    if (MainWindow.KMCStatus.VSTMode == false)
                    {
                        MainWindow.Delegate.StatusMsg.Text = Languages.Parse("MemoryAllocationConversion");
                    }
                    else
                    {
                        MainWindow.Delegate.StatusMsg.Text = Languages.Parse("MemoryAllocationConversionVST");
                    }
                }
                else
                {
                    if (MainWindow.KMCStatus.VSTMode == false)
                    {
                        MainWindow.Delegate.StatusMsg.Text = Languages.Parse("MemoryAllocationPlayback");
                    }
                    else
                    {
                        MainWindow.Delegate.StatusMsg.Text = Languages.Parse("MemoryAllocationPlaybackVST");
                    }
                }
                DisableImportButtons();
                DisableEncoderButtons();
                thisProc.PriorityClass = ProcessPriorityClass.AboveNormal;
            }
            else if (Mode == 2) // Rendering/Playback
            {
                SetProgressBar(2);

                if (!Busy)
                {
                    MainWindow.Delegate.StatusPicture.Image = Properties.Resources.convbusy;
                    Busy = true;
                }
                if (!MainWindow.KMCStatus.RenderingMode)
                {
                    if (PictureSet != 2)
                    {
                        MainWindow.Delegate.StatusPicture.BackgroundImage = Properties.Resources.convprvw;
                        PictureSet = 2;
                    }
                }
                else
                {
                    if (PictureSet != 3)
                    {
                        MainWindow.Delegate.StatusPicture.BackgroundImage = Properties.Resources.convsave;
                        PictureSet = 3;
                    }
                }

                DisableImportButtons();
                DisableEncoderButtons();
                UpdateText();
                thisProc.PriorityClass = ProcessPriorityClass.High;
            }
        }
Example #10
0
        public static string[] GetMoreInfoMIDI(string str)
        {
            try
            {
                // Get size of MIDI
                long   length = new System.IO.FileInfo(str).Length;
                string size;
                try
                {
                    if (length / 1024f >= 1000000000)
                    {
                        size = ((((length / 1024f) / 1024f) / 1024f) / 1024f).ToString("0.0 TiB");
                    }
                    else if (length / 1024f >= 1000000)
                    {
                        size = (((length / 1024f) / 1024f) / 1024f).ToString("0.0 GiB");
                    }
                    else if (length / 1024f >= 1000)
                    {
                        size = ((length / 1024f) / 1024f).ToString("0.0 MiB");
                    }
                    else if (length / 1024f >= 1)
                    {
                        size = (length / 1024f).ToString("0.0 KiB");
                    }
                    else
                    {
                        size = (length).ToString("0 B");
                    }
                }
                catch { size = "-"; }

                Bass.BASS_Init(0, 4000, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                Int32 time = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE, 0);

                if (time == 0)
                {
                    return(null);
                }

                Int64    pos  = Bass.BASS_ChannelGetLength(time);
                Double   num9 = Bass.BASS_ChannelBytes2Seconds(time, pos);
                TimeSpan span = TimeSpan.FromSeconds(num9);

                // Get length of MIDI
                string Length = span.Minutes.ToString() + ":" + span.Seconds.ToString().PadLeft(2, '0') + "." + span.Milliseconds.ToString().PadLeft(3, '0');

                UInt64 count  = 0;
                Int32  Tracks = BassMidi.BASS_MIDI_StreamGetTrackCount(time);
                for (int i = 0; i < Tracks; i++)
                {
                    count += (UInt32)BassMidi.BASS_MIDI_StreamGetEvents(time, i, BASSMIDIEvent.MIDI_EVENT_NOTES, null);
                }

                Bass.BASS_Free();
                return(new string[] {
                    Length,
                    String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", Tracks),
                    String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", count),
                    size
                });
            }
            catch
            {
                MessageBox.Show(String.Format(Languages.Parse("NoEnoughMemoryParseInfo"), str), Languages.Parse("Error"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(new string[] { Languages.Parse("NA"), Languages.Parse("NA"), Languages.Parse("NA"), Languages.Parse("NA") });
            }
        }
Example #11
0
File: RTF.cs Project: walney/KMC
 private static void CurrentTitle(Int32 Mode)
 {
     try
     {
         if (Mode == 0 || Mode == 1) // Idle
         {
             MainWindow.Delegate.Text = MainWindow.Title;
         }
         else
         {
             if (MainWindow.KMCStatus.IsKMCBusy == false)
             {
                 MainWindow.Delegate.Text = MainWindow.Title;
             }
             else
             {
                 MainWindow.Delegate.Text = String.Format(MainWindow.KMCStatus.RenderingMode ? Languages.Parse("ConversionText") : Languages.Parse("PlaybackText"), MainWindow.Title, MainWindow.KMCGlobals.NewWindowName);
             }
         }
     }
     catch
     {
         MainWindow.Delegate.Text = MainWindow.Title;
     }
 }
Example #12
0
File: RTF.cs Project: walney/KMC
        private static void CurrentMode(Int32 Mode)
        {
            if (Mode == 0) // Idle
            {
                MainWindow.Delegate.AVSLabel.Text               = String.Format("{0}: 0/{2}", Languages.Parse("ActiveVoices"), 0, Properties.Settings.Default.Voices);
                MainWindow.Delegate.OpenSettings.Enabled        = true;
                MainWindow.Delegate.VolumeLabel.Enabled         = true;
                MainWindow.Delegate.PreviewTrackBar.Enabled     = false;
                MainWindow.Delegate.VolumeBar.Enabled           = true;
                MainWindow.Delegate.VSTiSeparator.Visible       = false;
                MainWindow.Delegate.VSTiSettings.Visible        = false;
                MainWindow.KMCDialogs.AdvSett.MaxVoices.Maximum = 100000;
                thisProc.PriorityClass = ProcessPriorityClass.Idle;
            }
            else if (Mode == 1) // Memory allocation
            {
                MainWindow.Delegate.AVSLabel.Text           = String.Format("{0}: 0/{2}", Languages.Parse("ActiveVoices"), 0, Properties.Settings.Default.Voices);
                MainWindow.Delegate.OpenSettings.Enabled    = false;
                MainWindow.Delegate.PreviewTrackBar.Enabled = false;
                MainWindow.Delegate.VSTiSeparator.Visible   = false;
                MainWindow.Delegate.VSTiSettings.Visible    = false;

                if (MainWindow.KMCStatus.RenderingMode)
                {
                    MainWindow.Delegate.VolumeLabel.Enabled         = false;
                    MainWindow.Delegate.VolumeBar.Enabled           = false;
                    MainWindow.KMCDialogs.AdvSett.MaxVoices.Maximum = 100000;
                }
                else
                {
                    MainWindow.Delegate.VolumeLabel.Enabled         = true;
                    MainWindow.Delegate.VolumeBar.Enabled           = true;
                    MainWindow.KMCDialogs.AdvSett.MaxVoices.Maximum = 2000;
                }

                thisProc.PriorityClass = ProcessPriorityClass.AboveNormal;
            }
            else if (Mode == 2) // Rendering/Playback
            {
                if (MainWindow.VSTs.VSTInfo[0].isInstrument)
                {
                    MainWindow.Delegate.AVSLabel.Text = String.Format("{0}: {1}", Languages.Parse("ActiveVoices"), Languages.Parse("Unavailable"));
                }
                else
                {
                    MainWindow.Delegate.AVSLabel.Text = String.Format("{0}: {1}/{2}", Languages.Parse("ActiveVoices"), Convert.ToInt32(ActiveVoices), Properties.Settings.Default.Voices);
                }

                if (MainWindow.KMCStatus.RenderingMode)
                {
                    MainWindow.Delegate.OpenSettings.Enabled        = false;
                    MainWindow.Delegate.VolumeLabel.Enabled         = false;
                    MainWindow.Delegate.VolumeBar.Enabled           = false;
                    MainWindow.Delegate.PreviewTrackBar.Enabled     = false;
                    MainWindow.Delegate.VSTiSeparator.Visible       = false;
                    MainWindow.Delegate.VSTiSettings.Visible        = false;
                    MainWindow.KMCDialogs.AdvSett.MaxVoices.Maximum = 100000;
                }
                else
                {
                    MainWindow.Delegate.OpenSettings.Enabled    = true;
                    MainWindow.Delegate.VolumeLabel.Enabled     = true;
                    MainWindow.Delegate.VolumeBar.Enabled       = true;
                    MainWindow.Delegate.PreviewTrackBar.Enabled = true;

                    if (MainWindow.VSTs.VSTInfo[0].isInstrument)
                    {
                        MainWindow.Delegate.VSTiSeparator.Visible = true;
                        MainWindow.Delegate.VSTiSettings.Visible  = true;
                    }
                    else
                    {
                        MainWindow.Delegate.VSTiSeparator.Visible = false;
                        MainWindow.Delegate.VSTiSettings.Visible  = false;
                    }

                    MainWindow.KMCDialogs.AdvSett.MaxVoices.Maximum = 2000;
                }

                thisProc.PriorityClass = ProcessPriorityClass.Normal;
            }
        }
Example #13
0
File: RTF.cs Project: walney/KMC
        private static void UpdateText()
        {
            String Time = ReturnOutputText(LenDoubleToSpan);

            string MIDILengthString  = (LenDoubleToSpan).ToString(Time);
            string MIDICurrentString = (CurDoubleToSpan).ToString(Time);

            float Percentage = (RAWConverted / RAWTotal).LimitFloatToRange(0.0f, 100.0f);

            MainWindow.KMCGlobals.PercentageProgress = Percentage.ToString("0.0%");

            String PassedTime = String.Format("{0}:{1}",
                                              (Int32)MainWindow.KMCStatus.PassedTime.TotalMinutes,
                                              MainWindow.KMCStatus.PassedTime.Seconds.ToString("00"));

            String EstimatedTime = String.Format("{0}:{1}",
                                                 (Int32)MainWindow.KMCStatus.EstimatedTime.TotalMinutes,
                                                 MainWindow.KMCStatus.EstimatedTime.Seconds.ToString("00"));

            MainWindow.KMCStatus.PassedTime = DateTime.Now - MainWindow.KMCStatus.StartTime;

            try
            {
                Double secondsremaining = (Double)(MainWindow.KMCStatus.PassedTime.TotalSeconds / (Double)RTF.MIDICurrentPosRAW * ((Double)RTF.MIDILengthRAW - (Double)RTF.MIDICurrentPosRAW));
                MainWindow.KMCStatus.EstimatedTime = TimeSpan.FromSeconds(MainWindow.KMCGlobals.RealTime ? 0 : secondsremaining);
            }
            catch { MainWindow.KMCStatus.EstimatedTime = TimeSpan.FromSeconds(0); }

            if (!MainWindow.KMCStatus.RenderingMode)
            {
                if (CPUUsage < 100f || CPUUsage == 100f)
                {
                    MainWindow.Delegate.StatusMsg.Text = String.Format(Languages.Parse("PlaybackStatusNormal"),
                                                                       Percentage.ToString("0.0%"),
                                                                       MIDICurrentString, MIDILengthString,
                                                                       MainWindow.KMCGlobals.DoNotCountNotes ? "N/A" : MainWindow.KMCStatus.PlayedNotes.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de")),
                                                                       MainWindow.KMCGlobals.DoNotCountNotes ? "N/A" : MainWindow.KMCStatus.TotalNotes.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de")),
                                                                       CPUUsage.ToString("0.0"));
                }
                else if (CPUUsage > 100f)
                {
                    MainWindow.Delegate.StatusMsg.Text = String.Format(Languages.Parse("PlaybackStatusSlower"),
                                                                       Percentage.ToString("0.0%"),
                                                                       MIDICurrentString, MIDILengthString,
                                                                       MainWindow.KMCGlobals.DoNotCountNotes ? "N/A" : MainWindow.KMCStatus.PlayedNotes.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de")),
                                                                       MainWindow.KMCGlobals.DoNotCountNotes ? "N/A" : MainWindow.KMCStatus.TotalNotes.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("de")),
                                                                       ((float)(CPUUsage / 100f)).ToString("0.0"));
                }
            }
            else
            {
                if (CPUUsage < 100f)
                {
                    if (MainWindow.KMCGlobals.RealTime)
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(Languages.Parse("ConvStatusFasterNew"),
                                                                           RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                                                                           "?:??", PassedTime, Convert.ToInt32(CPUUsage).ToString(),
                                                                           ((float)(100f / CPUUsage)).ToString("0.0"));
                    }
                    else
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(
                            Properties.Settings.Default.ShowOldTimeInfo ? Languages.Parse("ConvStatusFasterOld") : Languages.Parse("ConvStatusFasterNew"),
                            RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDICurrentString : EstimatedTime,
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDILengthString : PassedTime,
                            Convert.ToInt32(CPUUsage).ToString(),
                            ((float)(100f / CPUUsage)).ToString("0.0"));
                    }
                }
                else if (CPUUsage == 100f)
                {
                    if (MainWindow.KMCGlobals.RealTime)
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(Languages.Parse("ConvStatusNormalNew"),
                                                                           RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                                                                           "?:??", PassedTime, Convert.ToInt32(CPUUsage).ToString(),
                                                                           CPUUsage.ToString("0.0"));
                    }
                    else
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(
                            Properties.Settings.Default.ShowOldTimeInfo ? Languages.Parse("ConvStatusNormalOld") : Languages.Parse("ConvStatusNormalNew"),
                            RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDICurrentString : EstimatedTime,
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDILengthString : PassedTime,
                            Convert.ToInt32(CPUUsage).ToString(),
                            CPUUsage.ToString("0.0"));
                    }
                }
                else if (CPUUsage > 100f)
                {
                    if (MainWindow.KMCGlobals.RealTime)
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(Languages.Parse("ConvStatusSlowerNew"),
                                                                           RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                                                                           "?:??", PassedTime, Convert.ToInt32(CPUUsage).ToString(),
                                                                           ((float)(CPUUsage / 100f)).ToString("0.0"));
                    }
                    else
                    {
                        MainWindow.Delegate.StatusMsg.Text = String.Format(
                            Properties.Settings.Default.ShowOldTimeInfo ? Languages.Parse("ConvStatusSlowerOld") : Languages.Parse("ConvStatusSlowerNew"),
                            RAWConverted.ToString("0.00"), Percentage.ToString("0.0%"),
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDICurrentString : EstimatedTime,
                            Properties.Settings.Default.ShowOldTimeInfo ? MIDILengthString : PassedTime,
                            Convert.ToInt32(CPUUsage).ToString(),
                            ((float)(CPUUsage / 100f)).ToString("0.0"));
                    }
                }
            }
        }
Example #14
0
 public static void BASSEncoderInit(Int32 format, String str)
 {
     try
     {
         string pathwithoutext = String.Format("{0}\\{1}", Properties.Settings.Default.LastExportFolder, Path.GetFileNameWithoutExtension(str));
         string ext;
         string enc;
         string args;
         int    copynum = 1;
         if (format == 1)
         {
             foreach (Process proc in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Program.OGGEnc)))
             {
                 proc.Kill();
             }
             ext  = "ogg";
             enc  = Program.OGGEnc;
             args = String.Format(Properties.Settings.Default.EncoderOGG, Properties.Settings.Default.OverrideBitrate ? Properties.Settings.Default.Bitrate : 192);
         }
         else if (format == 2)
         {
             foreach (Process proc in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Program.MP3Enc)))
             {
                 proc.Kill();
             }
             ext  = "mp3";
             enc  = Program.MP3Enc;
             args = String.Format(Properties.Settings.Default.EncoderMP3, Properties.Settings.Default.OverrideBitrate ? Properties.Settings.Default.Bitrate : 192);
         }
         else
         {
             ext  = "wav";
             enc  = null;
             args = "";
         }
         if (File.Exists(String.Format("{0}.{1}", pathwithoutext, ext)))
         {
             string temp;
             do
             {
                 temp = String.Format("{0} ({1} {2})", pathwithoutext, Languages.Parse("CopyText"), copynum);
                 ++copynum;
             } while (File.Exists(String.Format("{0}.{1}", temp, ext)));
             BassEnc.BASS_Encode_Stop(MainWindow.VSTs._VSTiHandle);
             BassEnc.BASS_Encode_Stop(MainWindow.KMCGlobals._recHandle);
             MainWindow.KMCGlobals._Encoder = BassEnc.BASS_Encode_Start((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), EncoderString(enc, temp, ext, args), (Properties.Settings.Default.LoudMaxEnabled ? BASSEncode.BASS_ENCODE_FP_16BIT : BASSEncode.BASS_ENCODE_DEFAULT) | BASSEncode.BASS_ENCODE_AUTOFREE | IsOgg(format) | IsWav(format), null, IntPtr.Zero);
             BASSCheckError();
         }
         else
         {
             BassEnc.BASS_Encode_Stop(MainWindow.VSTs._VSTiHandle);
             BassEnc.BASS_Encode_Stop(MainWindow.KMCGlobals._recHandle);
             MainWindow.KMCGlobals._Encoder = BassEnc.BASS_Encode_Start((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), EncoderString(enc, pathwithoutext, ext, args), (Properties.Settings.Default.LoudMaxEnabled ? BASSEncode.BASS_ENCODE_FP_16BIT : BASSEncode.BASS_ENCODE_DEFAULT) | BASSEncode.BASS_ENCODE_AUTOFREE | IsOgg(format) | IsWav(format), null, IntPtr.Zero);
             BASSCheckError();
         }
     }
     catch (Exception ex)
     {
         BASSCloseStreamException(ex);
     }
 }
Example #15
0
 public static void BASSVSTShowDialog(bool vsti, int towhichstream, int whichvst, BASS_VST_INFO vstInfo)
 {
     try
     {
         if (vstInfo.hasEditor && !MainWindow.KMCGlobals.VSTSkipSettings)
         {
             Form f = new Form();
             f.Width           = vstInfo.editorWidth + 4;
             f.Height          = vstInfo.editorHeight + 34;
             f.ClientSize      = new Size(vstInfo.editorWidth, vstInfo.editorHeight);
             f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
             f.StartPosition   = FormStartPosition.CenterScreen;
             f.Text            = String.Format("{0} {1}", Languages.Parse("DSPSettings"), vstInfo.effectName);
             BassVst.BASS_VST_EmbedEditor(whichvst, f.Handle);
             f.ShowDialog();
             BassVst.BASS_VST_EmbedEditor(whichvst, IntPtr.Zero);
         }
     }
     catch (Exception ex)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("==== Start of Keppy's MIDI Converter Error ====");
         sb.AppendLine(ex.ToString());
         sb.AppendLine("====  End of Keppy's MIDI Converter Error  ====");
         Thread thread = new Thread(() => Clipboard.SetText(sb.ToString()));
         thread.SetApartmentState(ApartmentState.STA);
         thread.Start();
         thread.Join();
         ErrorHandler errordialog = new ErrorHandler(Languages.Parse("VSTInvalidCallTitle"), Languages.Parse("VSTInvalidCallError"), 0, 0);
         errordialog.ShowDialog();
         if (!vsti)
         {
             BassVst.BASS_VST_ChannelRemoveDSP(towhichstream, whichvst);
         }
         else
         {
             BassVst.BASS_VST_ChannelFree(MainWindow.VSTs._VSTiHandle);
         }
     }
 }