private void Initialize(VstPlugin plugin) { _plugin = plugin; CanClose = false; FormClosing += VSTPluginConfigForm_FormClosing; MinimizeBox = true; ShowInTaskbar = true; FormBorderStyle = FormBorderStyle.SizableToolWindow; TopMost = true; var borderSize = SystemInformation.BorderSize; Width = plugin.EditorWidth + (borderSize.Width * 2) + 15; Height = plugin.EditorHeight + _menuStrip.Height + (borderSize.Height * 2) + 35; var icon = ApplicationHelper.GetIcon(); if (icon != null) { Icon = icon; } Text = plugin.Name; BassVst.BASS_VST_EmbedEditor(plugin.Id, EditorPanelHandle); plugin.Form = this; LoadPresets(plugin); }
private static void LoadPluginParameters(VstPlugin plugin) { plugin.Parameters = new List <VstPlugin.VstPluginParameter>(); if (plugin.Name.Contains("mania")) { Console.WriteLine("mani"); } var parameterCount = BassVst.BASS_VST_GetParamCount(plugin.Id); for (var i = 0; i < parameterCount; i++) { var parameterInfo = BassVst.BASS_VST_GetParamInfo(plugin.Id, i); var name = parameterInfo.name.Trim(); if (string.IsNullOrWhiteSpace(name) || name.ToLower().StartsWith("unused")) { continue; } var parameter = new VstPlugin.VstPluginParameter { Id = i, Name = parameterInfo.name }; LoadPresetParameterValues(plugin, parameter); plugin.Parameters.Add(parameter); } }
public static void BASSPlayBackEngine(Int64 length, Int64 pos) { if (MainWindow.Seeking) { BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0); BassVst.BASS_VST_ProcessEvent(MainWindow.VSTs._VSTiHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0); Bass.BASS_ChannelSetPosition(MainWindow.KMCGlobals._recHandle, MainWindow.CurrentSeek, BASSMode.BASS_POS_MIDI_TICK); MainWindow.Seeking = false; return; } Int32 tempo = BassMidi.BASS_MIDI_StreamGetEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO); MainWindow.KMCGlobals.OriginalTempo = 60000000 / tempo; Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.DisableEffects ? BASSFlag.BASS_MIDI_NOFX : 0, BASSFlag.BASS_MIDI_NOFX); Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.NoteOff1 ? BASSFlag.BASS_MIDI_NOTEOFF1 : 0, BASSFlag.BASS_MIDI_NOTEOFF1); for (Int32 i = 0; i <= 15; i++) { BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, i, BASSMIDIEvent.MIDI_EVENT_MIXLEVEL, MainWindow.KMCStatus.ChannelsVolume[i]); } MainWindow.KMCGlobals._VolFXParam.fCurrent = 1.0f; MainWindow.KMCGlobals._VolFXParam.fTarget = Properties.Settings.Default.Volume; MainWindow.KMCGlobals._VolFXParam.fTime = 0.0f; MainWindow.KMCGlobals._VolFXParam.lCurve = 0; Bass.BASS_FXSetParameters(MainWindow.KMCGlobals._VolFX, MainWindow.KMCGlobals._VolFXParam); Bass.BASS_ChannelSetAttribute(MainWindow.KMCGlobals._recHandle, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, Properties.Settings.Default.Voices); }
private void f_Closing(object sender, CancelEventArgs e) { // unembed the VST editor BassVst.BASS_VST_EmbedEditor(VstEffectHandle, IntPtr.Zero); VstEffectHandle = 0; _vstEffectHandle = 0; }
public void LoadChannelStrips(Preferences form, Panel prefsPanel, int width = 0, int height = 0) { _paramInfo = new BASS_VST_PARAM_INFO(); int c = BassVst.BASS_VST_GetParamCount(VstEffectHandle); for (int i = 0; i < c; i++) { // get the info about the parameter _paramValue = BassVst.BASS_VST_GetParam(VstEffectHandle, i); BassVst.BASS_VST_GetParamInfo(VstEffectHandle, i, _paramInfo); _paramValue = BassVst.BASS_VST_GetParam(VstEffectHandle, i); Console.WriteLine(_paramInfo.ToString() + " : " + _paramValue.ToString()); } // show the embedded editor _vstInfo = new BASS_VST_INFO(); if (BassVst.BASS_VST_GetInfo(VstEffectHandle, _vstInfo) && _vstInfo.hasEditor) { form.Closing += new CancelEventHandler(f_Closing); //form.Text = _vstInfo.effectName + " " + Effects.GetorSetFx; BassVst.BASS_VST_EmbedEditor(VstEffectHandle, prefsPanel.Handle); _vstEffectHandle = VstEffectHandle; } }
public static void InitializeVSTsForStream() { try { if (MainWindow.KMCStatus.VSTMode == true) { MainWindow.VSTs._LoudMaxHan = BassVst.BASS_VST_ChannelSetDSP((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), String.Format("{0}\\LoudMax.dll", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)), BASSVSTDsp.BASS_VST_KEEP_CHANS, 9); BassVst.BASS_VST_SetParamCopyParams(MainWindow.VSTs._DummyLoudMaxHan, MainWindow.VSTs._LoudMaxHan); for (int i = 0; i <= 7; i++) { if (MainWindow.VSTs._DummyVSTHandles[i] != 0) { MainWindow.VSTs._VSTHandles[i] = BassVst.BASS_VST_ChannelSetDSP((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), MainWindow.VSTs.VSTDLLs[i], BASSVSTDsp.BASS_VST_DEFAULT, i); if (MainWindow.VSTs._VSTHandles[i] != 0) { BassVst.BASS_VST_SetParamCopyParams(MainWindow.VSTs._DummyVSTHandles[i], MainWindow.VSTs._VSTHandles[i]); } } } } } catch (Exception ex) { BASSCloseStreamCrash(ex); } }
// your VST callback - referenced below by BASS_VST_SetCallback() private static int VstProc_CallBack(int vstHandle, BASSVSTAction action, int param1, int param2, IntPtr user) { switch (action) { case BASSVSTAction.BASS_VST_PARAM_CHANGED: // we get notified that the user has changed some sliders in the editor - // do what to do here ... //_paramValue = BassVst.BASS_VST_GetParam(_vstBasicStrip, 0); BassVst.BASS_VST_SetParamCopyParams(_vstBasicStrip, Channel1Fx.GetChannelStrip); //Console.WriteLine(_paramValue.ToString()); break; case BASSVSTAction.BASS_VST_EDITOR_RESIZED: // the editor window requests a new size, // maybe we should resize the window the editor is embedded in? // the new width/height can be found in param1/param2 break; case BASSVSTAction.BASS_VST_AUDIO_MASTER: // this is only for people familiar with the VST SDK, // param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure // which contains all information needed break; } return(0); }
/// <summary> /// Sets the VST plug-in settings. /// </summary> /// <param name="plugin">The plug-in.</param> /// <param name="parameters">The parameters.</param> public static void SetVstPluginParameters(VstPlugin plugin, string parameters) { if (parameters.Trim() == "") { return; } var values = parameters.Split(',').ToList(); var parameterCount = BassVst.BASS_VST_GetParamCount(plugin.Id); for (var i = 0; i < parameterCount; i++) { try { if (i >= values.Count) { continue; } var value = float.Parse(values[i]); BassVst.BASS_VST_SetParam(plugin.Id, i, value); } catch { // ignored } } }
/// <summary> /// Stop Playing the active Music File /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btStop_Click(object sender, EventArgs e) { btPlay.Enabled = true; btStop.Enabled = false; // Stop the DSP Gain if (_gain != null) { _gain.Stop(); } foreach (DSPPluginInfo dsp in listBoxSelectedPlugins.Items) { // Save the VST plugin parameters before freeing the stream if (dsp.DSPPluginType == DSPPluginInfo.PluginType.VST) { _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, dsp.FilePath, BASSVSTDsp.BASS_VST_DEFAULT, 1); // Copy the parameters of the old handle int vstold = _vstHandles[dsp.Name]; BassVst.BASS_VST_SetParamCopyParams(vstold, _vstHandle); _vstHandles[dsp.Name] = _vstHandle; } else { // Stop the WinAmp DSP _waDspPlugin = _waDspPlugins[dsp.FilePath]; BassWaDsp.BASS_WADSP_Stop(_waDspPlugin); } } Bass.BASS_ChannelStop(_stream); }
public void VST_DISABLE(string del) { BassVst.BASS_VST_ChannelRemoveDSP(_Stream, getHAndle(del)); remove_workLIST(del, ref work_list_vst); remove_VST(del, ref data.workVST); data.UpdateLIST(); }
private void f_Closing(object sender, CancelEventArgs e) { BassVst.BASS_VST_EmbedEditor(this.FDSPHandle, IntPtr.Zero); this.FConfigVisible = false; if (this.FEditor != null) { this.FEditor.Dispose(); this.FEditor = null; } }
/// <summary> /// Loads a VST plug-in and applies it to the mixer /// </summary> /// <param name="location">The file location of the VST DLL</param> /// <param name="priority">The priority.</param> /// <returns>The VST plug-in</returns> private VstPlugin LoadAndApplyVstPlugin(string location, int priority) { if (location == "") { return(null); } if (!File.Exists(location)) { return(null); } var plugin = new VstPlugin { Id = BassVst.BASS_VST_ChannelSetDSP(ChannelId, location, BASSVSTDsp.BASS_VST_DEFAULT, priority) }; if (plugin.Id == 0) { throw new Exception("Cannot load plug-in " + Path.GetFileNameWithoutExtension(location)); } var info = BassVst.BASS_VST_GetInfo(plugin.Id); if (info != null) { plugin.Name = info.effectName; plugin.EditorWidth = info.editorWidth; plugin.EditorHeight = info.editorHeight; } else { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(location); if (fileNameWithoutExtension != null) { plugin.Name = StringHelper.TitleCase(fileNameWithoutExtension.Replace("_", " ")); } } if (plugin.EditorWidth == 0) { plugin.EditorWidth = 400; } if (plugin.EditorHeight == 0) { plugin.EditorHeight = 600; } plugin.Location = location; LoadPluginParameters(plugin); SetPluginBpm(plugin); return(plugin); }
/// <summary> /// Gets the VST plug-in settings. /// </summary> /// <param name="plugin">The plug-in.</param> /// <returns>The settings as a key=value comma delimited list</returns> public static string GetVstPluginParameters(VstPlugin plugin) { var values = new List <string>(); var parameterCount = BassVst.BASS_VST_GetParamCount(plugin.Id); for (var i = 0; i < parameterCount; i++) { var value = BassVst.BASS_VST_GetParam(plugin.Id, i); values.Add(value.ToString(CultureInfo.InvariantCulture)); } return(string.Join(",", values.ToArray())); }
public static List <VstPluginPreset> GetPluginPresets(VstPlugin plugin) { var names = BassVst.BASS_VST_GetProgramNames(plugin.Id).ToList(); return(names.Select(name => new VstPluginPreset() { Id = names.IndexOf(name), Name = name.Trim() }) .Where(x => x.Name != "") .ToList()); }
public static void UpdateSettings() { if (m_isEQ1bandSettingChange) { m_isEQ1bandSettingChange = false; // int eq1 = BassVst.BASS_VST_GetParamCount(_vstEffectEQ1band); for (int i = 0; i < eq1; i++) { AppSettings.Set("CH1EQ1band" + i, BassVst.BASS_VST_GetParam(_vstEffectEQ1band, i).ToString()); PlayerControl.LoadSaveProgress += i; } } else if (m_isCompressorSettingChange) { m_isCompressorSettingChange = false; // int comp1 = BassVst.BASS_VST_GetParamCount(_vstEffectCompressor); for (int i = 0; i < comp1; i++) { AppSettings.Set("CH1Comp" + i, BassVst.BASS_VST_GetParam(_vstEffectCompressor, i).ToString()); PlayerControl.LoadSaveProgress += i; } } else if (m_isEQ4BandSettingChange) { m_isEQ4BandSettingChange = false; // int eq7 = BassVst.BASS_VST_GetParamCount(_vstEffectEQ4Band); for (int i = 0; i < eq7; i++) { AppSettings.Set("CH1EQ4band" + i, BassVst.BASS_VST_GetParam(_vstEffectEQ4Band, i).ToString()); PlayerControl.LoadSaveProgress += i; } } else if (m_isEQ4BandPhoneSettingChange) { m_isEQ4BandPhoneSettingChange = false; for (int i = 0; i < eq7Phone; i++) { AppSettings.Set("CH1EQ4bandPhone" + i, BassVst.BASS_VST_GetParam(_vstEffectEQ4BandPhone, i).ToString()); PlayerControl.LoadSaveProgress += i; } } else if (m_isDeEsserSettingChange) { m_isDeEsserSettingChange = false; // int deEs = BassVst.BASS_VST_GetParamCount(_vstEffectDeEsser); for (int i = 0; i < deEs; i++) { AppSettings.Set("CH1DeEsser" + i, BassVst.BASS_VST_GetParam(_vstEffectDeEsser, i).ToString()); PlayerControl.LoadSaveProgress += i; } } }
public bool VST_ENABLE(string path) { var handle = BassVst.BASS_VST_ChannelSetDSP(_Stream, path, BASSVSTDsp.BASS_VST_DEFAULT, 1); if (handle < 1) { System.Windows.MessageBox.Show("Ошибка подключения " + get_nameVTS(path)); return(false); } work_list_vst.Add(new WORKVST(handle, path)); Trace.WriteLine("ENABLE header=" + handle.ToString() + " " + path); return(true); }
// your VST callback - referenced below by BASS_VST_SetCallback() private static int VstProc_CallBack(int vstHandle, BASSVSTAction action, int param1, int param2, IntPtr user) { switch (action) { case BASSVSTAction.BASS_VST_PARAM_CHANGED: if (vstHandle == _vstEffectEQ1band) { m_isEQ1bandSettingChange = true; } else if (vstHandle == _vstEffectCompressor) { m_isCompressorSettingChange = true; } else if (vstHandle == _vstEffectEQ4Band) { m_isEQ4BandSettingChange = true; } else if (vstHandle == _vstEffectEQ4BandPhone) { m_isEQ4BandPhoneSettingChange = true; } else if (vstHandle == _vstEffectDeEsser) { m_isDeEsserSettingChange = true; } else if (vstHandle == _vstBasicStrip) { BassVst.BASS_VST_SetParamCopyParams(_vstBasicStrip, Channel2Fx.GetChannelStrip); } // we get notified that the user has changed some sliders in the editor - // do what to do here ... break; case BASSVSTAction.BASS_VST_EDITOR_RESIZED: // the editor window requests a new size, // maybe we should resize the window the editor is embedded in? // the new width/height can be found in param1/param2 break; case BASSVSTAction.BASS_VST_AUDIO_MASTER: // this is only for people familiar with the VST SDK, // param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure // which contains all information needed break; } return(0); }
/// <summary> /// Load BASS DSP Plugins specified setup in the Configuration /// </summary> public static void LoadDSPPlugins() { Log.Debug("BASS: Loading DSP plugins ..."); _dspActive = false; // VST Plugins string vstPluginDir = Path.Combine(Application.StartupPath, @"musicplayer\plugins\dsp"); int vstHandle = 0; foreach (VSTPlugin plugins in Player.DSP.Settings.Instance.VSTPlugins) { // Get the vst handle and enable it string plugin = String.Format(@"{0}\{1}", vstPluginDir, plugins.PluginDll); vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, plugin, BASSVSTDsp.BASS_VST_DEFAULT, 1); if (vstHandle > 0) { _dspActive = true; _vstPlugins.Add(plugins.PluginDll); // Store the handle in the dictionary for later reference _vstHandles[plugins.PluginDll] = vstHandle; // Set all parameters for the plugin foreach (VSTPluginParm paramter in plugins.Parameter) { NumberFormatInfo format = new NumberFormatInfo(); format.NumberDecimalSeparator = "."; try { BassVst.BASS_VST_SetParam(vstHandle, paramter.Index, float.Parse(paramter.Value)); } catch (Exception ex) { Log.Error("Config: LoadDSPPlugins {0}", ex.Message); } } } else { Log.Debug("Couldn't load VST Plugin {0}. Error code: {1}", plugin, Bass.BASS_ErrorGetCode()); } } // Winamp Plugins can only be loaded on play to prevent Crashes if (Player.DSP.Settings.Instance.WinAmpPlugins.Count > 0) { _dspActive = true; } Log.Debug("BASS: Finished loading DSP plugins ..."); }
public void Show(int width = 0, int height = 0) { // if (_vstEffectHandle != 0) // { // return; // } _paramInfo = new BASS_VST_PARAM_INFO(); int c = BassVst.BASS_VST_GetParamCount(VstEffectHandle); for (int i = 0; i < c; i++) { // get the info about the parameter _paramValue = BassVst.BASS_VST_GetParam(VstEffectHandle, i); BassVst.BASS_VST_GetParamInfo(VstEffectHandle, i, _paramInfo); _paramValue = BassVst.BASS_VST_GetParam(VstEffectHandle, i); Console.WriteLine(_paramInfo.ToString() + " : " + _paramValue.ToString()); } // show the embedded editor _vstInfo = new BASS_VST_INFO(); if (BassVst.BASS_VST_GetInfo(VstEffectHandle, _vstInfo) && _vstInfo.hasEditor) { // create a new System.Windows.Forms.Form Form f = new Form(); if (width != 0 && height != 0) { f.ClientSize = new Size(width, height); } else { f.ClientSize = new Size(_vstInfo.editorWidth, _vstInfo.editorHeight); } f.MaximizeBox = false; f.MinimizeBox = false; f.FormBorderStyle = FormBorderStyle.FixedSingle; f.Closing += new CancelEventHandler(f_Closing); f.Text = _vstInfo.effectName + " " + Effects.GetorSetFx; f.Show(); BassVst.BASS_VST_EmbedEditor(VstEffectHandle, f.Handle); _vstEffectHandle = VstEffectHandle; } }
public static Boolean MidiFilterProc(int handle, int track, IntPtr midievent, bool seeking, IntPtr user) { try { Int32 Track = track; BASS_MIDI_EVENT temp = BASS_MIDI_EVENT.FromIntPtr(midievent); if (temp.eventtype == BASSMIDIEvent.MIDI_EVENT_NOTE && (Properties.Settings.Default.IgnoreNotes1 || Properties.Settings.Default.AskForIgnoreTracks)) { if (TracksList[Track]) { return(false); } int vel = (temp.param >> 0x08) & 0xFF; int note = temp.param & 0xFF; // First check if ((Properties.Settings.Default.IgnoreNotes1 && vel > 0) && (vel >= Properties.Settings.Default.IgnoreNotesLow && vel <= Properties.Settings.Default.IgnoreNotesHigh)) { return(false); } // Second if (Properties.Settings.Default.Limit88 && (temp.chan != 9 && !(note >= 21 && note <= 108))) { return(false); } } if (MainWindow.VSTs.VSTInfo[0].isInstrument) { BassVst.BASS_VST_ProcessEvent(MainWindow.VSTs._VSTiHandle, temp.chan, temp.eventtype, temp.param); } return(true); // process the event } catch (Exception ex) { BASSCloseStreamCrash(ex); return(false); } }
private void AddDSP() { if (this.FChannel != null) { double dpriority; this.FPinInPriority.GetValue(0, out dpriority); double denabled; this.FPinInEnabled.GetValue(0, out denabled); if (this.FChannel.BassHandle.HasValue && denabled >= 0.5) { this.FDSPHandle = BassVst.BASS_VST_ChannelSetDSP(this.FChannel.BassHandle.Value, this.FFilename, BASSVSTDsp.BASS_VST_DEFAULT, Convert.ToInt32(dpriority)); this.FPinOutFxHandle.SliceCount = 1; this.FPinOutFxHandle.SetValue(0, this.FDSPHandle); } } }
/// <summary> /// Add the selected VST plugin(s) to the Selected Plugin Listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonPluginAdd_Click(object sender, EventArgs e) { DSPPluginInfo pluginInfo = (DSPPluginInfo)listBoxFoundPlugins.SelectedItem; if (pluginInfo == null) { return; } if (pluginInfo.DSPPluginType == DSPPluginInfo.PluginType.VST) { // Get the VST handle and enable it _vstHandle = BassVst.BASS_VST_ChannelSetDSP(0, pluginInfo.FilePath, BASSVSTDsp.BASS_VST_DEFAULT, 1); if (_vstHandle > 0) { _vstHandles[pluginInfo.Name] = _vstHandle; listBoxSelectedPlugins.Items.Add(listBoxFoundPlugins.SelectedItem); listBoxFoundPlugins.Items.RemoveAt(listBoxFoundPlugins.SelectedIndex); } else { MessageBox.Show("Error loading VST Plugin. Probably not valid", "VST Plugin", MessageBoxButtons.OK); Log.Debug("Couldn't load VST Plugin {0}. Error code: {1}", pluginInfo.Name, Bass.BASS_ErrorGetCode()); } } else { // Get the winamp handle and enable it _waDspPlugin = BassWaDsp.BASS_WADSP_Load(pluginInfo.FilePath, 5, 5, 100, 100, null); if (_waDspPlugin > 0) { _waDspPlugins[pluginInfo.FilePath] = _waDspPlugin; listBoxSelectedPlugins.Items.Add(listBoxFoundPlugins.SelectedItem); listBoxFoundPlugins.Items.RemoveAt(listBoxFoundPlugins.SelectedIndex); } else { MessageBox.Show("Error loading WinAmp Plugin. Probably not valid", "WinAmp Plugin", MessageBoxButtons.OK); Log.Debug("Couldn't load WinAmp Plugin {0}. Error code: {1}", pluginInfo.FilePath, Bass.BASS_ErrorGetCode()); } } }