示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
        }