Exemplo n.º 1
0
        private void LoadVST(ref String VSTDLL, ref String VSTDLLDesc, Label Desc, Button Unload, Button Load, Int32 NumVST)
        {
            try
            {
                int status = 0;

                if (ModifierKeys == Keys.Shift)
                {
                    status = 1;
                }
                else if (ModifierKeys == Keys.Control)
                {
                    if (NumVST == 1)
                    {
                        if (Properties.Settings.Default.VSTiDisclaimer)
                        {
                            DialogResult dialogResult = MessageBox.Show("By clicking 'Yes', you agree not to abuse the 'VST instrument' feature to create, disseminate, or make accessible anything exploiting the copyrighted/protected samples or files included within a VST (\"Visual Studio Technology\" plugin).\n\nSuch resultant files could include (but are not limited to):\nSoundFonts, VSTs, or any other usable tool that commits copyright infringement.\n\nSimply put it, you may not use this tool to commit piracy on a copyrighted/trademarked/protected VST, free or paid, unless you have permission from the developer.\nYou may create audio at will from the VST, but DO NOT use this export feature to extract/\"rip\" samples from the VST.\n\nThe author assumes no legal responsibility from the use of this tool.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (dialogResult == DialogResult.Yes)
                            {
                                Properties.Settings.Default.VSTiDisclaimer = false;
                                Properties.Settings.Default.Save();
                                status = 2;
                                MessageBox.Show("VSTi mode activated.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else if (dialogResult == DialogResult.No)
                            {
                                Properties.Settings.Default.VSTiDisclaimer = true;
                                Properties.Settings.Default.Save();
                                return;
                            }
                        }
                        else
                        {
                            status = 2;
                            MessageBox.Show("VSTi mode activated.", "Keppy's MIDI Converter - Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        status = 0;
                    }
                }

                InitStartDirectory();
                if (VSTImportDialog.ShowDialog() == DialogResult.OK)
                {
                    BASS_VST_INFO VSTInfo = new BASS_VST_INFO();
                    if (status == 1)
                    {
                        VSTDLL     = VSTImportDialog.FileName;
                        VSTDLLDesc = VSTImportDialog.FileName + " (Not verified)";
                        Desc.Text  = VSTImportDialog.FileName + " (Not verified)";
                        Bass.BASS_Free();
                        Unload.Enabled = true;
                        Load.Enabled   = false;
                        SaveDirectory(VSTImportDialog.FileName);
                    }
                    else if (status == 2)
                    {
                        Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                        int VSTiTester = BassVst.BASS_VST_ChannelCreate(44100, 2, VSTImportDialog.FileName, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
                        MainWindow.KMCGlobals.vstIInfo = new BASS_VST_INFO();
                        bool Success = BassVst.BASS_VST_GetInfo(VSTiTester, MainWindow.KMCGlobals.vstIInfo);
                        if (Success)
                        {
                            String Lab = String.Format("{0} by {1} (Version number: {2}", MainWindow.KMCGlobals.vstIInfo.productName, MainWindow.KMCGlobals.vstIInfo.vendorName, MainWindow.KMCGlobals.vstIInfo.vendorVersion);
                            VSTDLL         = VSTImportDialog.FileName;
                            VSTDLLDesc     = MainWindow.KMCGlobals.vstIInfo.productName + " by " + MainWindow.KMCGlobals.vstIInfo.vendorName + " (Version: " + MainWindow.KMCGlobals.vstIInfo.vendorVersion + ")";
                            Desc.Text      = MainWindow.KMCGlobals.vstIInfo.productName + " by " + MainWindow.KMCGlobals.vstIInfo.vendorName + " (Version: " + MainWindow.KMCGlobals.vstIInfo.vendorVersion + ")";
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                            BassVst.BASS_VST_ChannelFree(VSTiTester);
                            Bass.BASS_Free();
                        }
                        else
                        {
                            MessageBox.Show(String.Format(MainWindow.res_man.GetString("InvalidVSTLoaded", MainWindow.cul), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            BassVst.BASS_VST_ChannelFree(VSTiTester);
                            Bass.BASS_Free();
                        }
                    }
                    else
                    {
                        Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                        int  Test      = Bass.BASS_StreamCreateDummy(44100, 2, BASSFlag.BASS_STREAM_DECODE, IntPtr.Zero);
                        int  VSTTester = BassVst.BASS_VST_ChannelSetDSP(Test, VSTImportDialog.FileName, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                        bool Success   = BassVst.BASS_VST_GetInfo(VSTTester, VSTInfo);
                        if (Success)
                        {
                            VSTDLL     = VSTImportDialog.FileName;
                            VSTDLLDesc = VSTInfo.productName + " by " + VSTInfo.vendorName + " (Version: " + VSTInfo.vendorVersion + ")";
                            Desc.Text  = VSTInfo.productName + " by " + VSTInfo.vendorName + " (Version: " + VSTInfo.vendorVersion + ")";
                            Bass.BASS_Free();
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                            BassVst.BASS_VST_ChannelRemoveDSP(Test, VSTTester);
                            Bass.BASS_StreamFree(Test);
                            Bass.BASS_Free();
                        }
                        else
                        {
                            MessageBox.Show(String.Format(MainWindow.res_man.GetString("InvalidVSTLoaded", MainWindow.cul), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            BassVst.BASS_VST_ChannelRemoveDSP(Test, VSTTester);
                            Bass.BASS_StreamFree(Test);
                            Bass.BASS_Free();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                KeppyMIDIConverter.ErrorHandler errordialog = new KeppyMIDIConverter.ErrorHandler(MainWindow.res_man.GetString("Error", MainWindow.cul), ex.ToString(), 0, 1);
                errordialog.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void LoadVST(ref String VSTDLL, ref String VSTDLLDesc, ref Label Desc, ref Button Unload, ref Button Load, Int32 NumVST)
        {
            try
            {
                int status = 0;

                if (ModifierKeys == Keys.Shift)
                {
                    status = 1;
                }
                else if (ModifierKeys == Keys.Control)
                {
                    if (NumVST == 1)
                    {
                        if (Properties.Settings.Default.VSTiDisclaimer)
                        {
                            DialogResult dialogResult = MessageBox.Show(Languages.Parse("LegalWarningVSTi"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("Warning")), MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (dialogResult == DialogResult.Yes)
                            {
                                Properties.Settings.Default.VSTiDisclaimer = false;
                                Properties.Settings.Default.Save();
                                status = 2;
                                MessageBox.Show(Languages.Parse("VSTiModeOnLegal"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("Warning")), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else if (dialogResult == DialogResult.No)
                            {
                                Properties.Settings.Default.VSTiDisclaimer = true;
                                Properties.Settings.Default.Save();
                                return;
                            }
                        }
                        else
                        {
                            status = 2;
                            MessageBox.Show(Languages.Parse("VSTiModeOn"), String.Format("{0} {1} - {2}", Program.Who, Program.Title, Languages.Parse("Warning")), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        status = 0;
                    }
                }

                InitStartDirectory();
                if (VSTImportDialog.ShowDialog() == DialogResult.OK)
                {
                    if (status == 1)
                    {
                        VSTDLL     = VSTImportDialog.FileName;
                        VSTDLLDesc = String.Format("{0} - ({1})", VSTImportDialog.FileName, Languages.Parse("NotVerified"));
                        Desc.Text  = String.Format("{0} - ({1})", VSTImportDialog.FileName, Languages.Parse("NotVerified"));
                        Bass.BASS_Free();
                        Unload.Enabled = true;
                        Load.Enabled   = false;
                        SaveDirectory(VSTImportDialog.FileName);
                    }
                    else if (status == 2)
                    {
                        Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                        int VSTiTester = BassVst.BASS_VST_ChannelCreate(44100, 2, VSTImportDialog.FileName, BASSFlag.BASS_STREAM_DECODE);
                        MainWindow.VSTs.VSTInfo[NumVST - 1] = new BASS_VST_INFO();
                        bool Success = BassVst.BASS_VST_GetInfo(VSTiTester, MainWindow.VSTs.VSTInfo[NumVST - 1]);
                        Bass.BASS_Free();
                        if (Success)
                        {
                            String Lab = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            VSTDLL         = VSTImportDialog.FileName;
                            VSTDLLDesc     = Lab;
                            Desc.Text      = Lab;
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                        }
                        else
                        {
                            MessageBox.Show(String.Format(Languages.Parse("InvalidVSTLoaded"), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        Un4seen.Bass.Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                        int  Test      = Bass.BASS_StreamCreateDummy(44100, 2, BASSFlag.BASS_STREAM_DECODE, IntPtr.Zero);
                        int  VSTTester = BassVst.BASS_VST_ChannelSetDSP(Test, VSTImportDialog.FileName, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                        bool Success   = BassVst.BASS_VST_GetInfo(VSTTester, MainWindow.VSTs.VSTInfo[NumVST - 1]);
                        if (Success)
                        {
                            VSTDLL     = VSTImportDialog.FileName;
                            VSTDLLDesc = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            Desc.Text  = String.Format(Languages.Parse("VSTNameAndVersion"), MainWindow.VSTs.VSTInfo[NumVST - 1].productName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorName, MainWindow.VSTs.VSTInfo[NumVST - 1].vendorVersion);
                            Bass.BASS_Free();
                            Unload.Enabled = true;
                            Load.Enabled   = false;
                            SaveDirectory(VSTImportDialog.FileName);
                        }
                        else
                        {
                            MessageBox.Show(String.Format(Languages.Parse("InvalidVSTLoaded"), Path.GetFileNameWithoutExtension(VSTImportDialog.FileName), bitreq, bitnow), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                        BassVst.BASS_VST_ChannelRemoveDSP(Test, VSTTester);
                        Bass.BASS_StreamFree(Test);
                        Bass.BASS_Free();
                    }
                }
            }
            catch (Exception ex)
            {
                KeppyMIDIConverter.ErrorHandler errordialog = new KeppyMIDIConverter.ErrorHandler(Languages.Parse("Error"), ex.ToString(), 0, 1);
                errordialog.ShowDialog();
            }
        }