/// <summary> /// Saves EQPreset to file. /// </summary> /// <param name="filePath">EQ preset file path</param> /// <param name="eqPreset">EQPreset object</param> public static void Save(string filePath, EQPreset eqPreset) { #if !WINDOWSSTORE XmlSerializer serializer = new XmlSerializer(typeof(EQPreset)); TextWriter textWriter = new StreamWriter(filePath); serializer.Serialize(textWriter, eqPreset); textWriter.Dispose(); #endif }
public void RefreshPreset(EQPreset preset) { InvokeOnMainThread(() => { _isPresetModified = false; _preset = preset; txtPresetName.Text = preset.Name; for(int a = 0; a < preset.Bands.Count; a++) _faderViews[a].SetValue(preset.Bands[a].CenterString, preset.Bands[a].Gain); presetGraph.Preset = _preset; presetGraph.SetNeedsDisplay(); }); }
public void RefreshPreset(EQPreset preset) { //Console.WriteLine("EQDA - REFRESH PRESET"); RunOnUiThread(() => { UpdatePreset(preset); _listAdapter.SetData(preset); }); }
public void UpdatePreset(EQPreset preset) { //Console.WriteLine("EQDA - UPDATE PRESET"); _preset = preset; _equalizerPresetGraph.SetPreset(preset); _txtPresetName.Text = preset.Name; }
/// <summary> /// Initializes the player. /// </summary> /// <param name="device">Device output</param> /// <param name="mixerSampleRate">Mixer sample rate (default: 44100 Hz)</param> /// <param name="bufferSize">Buffer size (default: 500 ms)</param> /// <param name="updatePeriod">Update period (default: 10 ms)</param> /// <param name="initializeDevice">Indicates if the device should be initialized</param> private void Initialize(Device device, int mixerSampleRate, int bufferSize, int updatePeriod, bool initializeDevice) { OnPlaylistEnded += () => { }; Player.CurrentPlayer = this; _device = device; _mixerSampleRate = mixerSampleRate; _bufferSize = bufferSize; _updatePeriod = updatePeriod; //_decodingService = new DecodingService(100000, UseFloatingPoint); _playlist = new ShufflePlaylist(); _syncProcs = new List<PlayerSyncProc>(); #if !ANDROID _useFloatingPoint = true; #endif _timerPlayer = new System.Timers.Timer(); _timerPlayer.Elapsed += new System.Timers.ElapsedEventHandler(timerPlayer_Elapsed); _timerPlayer.Interval = 1000; _timerPlayer.Enabled = false; // Initialize BASS library by OS type if (OS.Type == OSType.Windows) { // Load decoding plugins //plugins = Base.LoadPluginDirectory(Path.GetDirectoryName((new Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath)); Tracing.Log("Player init -- Loading plugins..."); //aacPluginHandle = Base.LoadPlugin("bass_aac.dll"); _apePluginHandle = Base.LoadPlugin("bass_ape.dll"); _flacPluginHandle = Base.LoadPlugin("bassflac.dll"); _mpcPluginHandle = Base.LoadPlugin("bass_mpc.dll"); //ofrPluginHandle = Base.LoadPlugin("bass_ofr.dll"); // Requires OptimFrog.DLL //ttaPluginHandle = Base.LoadPlugin("bass_tta.dll"); _wmaPluginHandle = Base.LoadPlugin("basswma.dll"); _wvPluginHandle = Base.LoadPlugin("basswv.dll"); int bassFxVersion = Base.GetFxPluginVersion(); int bassEncVersion = BaseEnc.GetVersion(); //Base.LoadFxPlugin(); } else // Linux or Mac OS X { // Load BASS library Tracing.Log("Player init -- Checking BASS library and plugin versions..."); int bassVersion = Base.GetBASSVersion(); int bassFxVersion = Base.GetFxPluginVersion(); int bassMixVersion = Base.GetMixPluginVersion(); int bassEncVersion = BaseEnc.GetVersion(); Tracing.Log("Player init -- BASS Version: " + bassVersion); Tracing.Log("Player init -- BASS FX Version: " + bassFxVersion); Tracing.Log("Player init -- BASS Mix Version: " + bassMixVersion); Tracing.Log("Player init -- BASS Enc Version: " + bassEncVersion); // Check OS type Console.WriteLine("Player init -- OS is " + OS.Type.ToString()); if (OS.Type == OSType.Linux) { string pluginPath = string.Empty; #if ANDROID pluginPath = PluginDirectoryPath; _aacPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbass_aac.so")); _alacPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbass_alac.so")); _apePluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbass_ape.so")); _mpcPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbass_mpc.so")); _flacPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbassflac.so")); _wvPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbasswv.so")); #else // Find plugins either in current directory (i.e. development) or in a system directory (ex: /usr/lib/Sessions or /opt/lib/Sessions) string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Check in the current directory first if(!File.Exists(exePath + "/libbassflac.so")) { // Check in /usr/lib/Sessions if(!File.Exists("/usr/lib/Sessions/libbassflac.so")) { // Check in /opt/lib/Sessions if(!File.Exists("/opt/lib/Sessions/libbassflac.so")) { // The plugins could not be found! throw new Exception("The BASS plugins could not be found either in the current directory, in /usr/lib/Sessions or in /opt/lib/Sessions!"); } else { pluginPath = "/opt/lib/Sessions"; } } else { pluginPath = "/usr/lib/Sessions"; } } else { pluginPath = exePath; } // Load decoding plugins _flacPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbassflac.so")); _wvPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbasswv.so")); _mpcPluginHandle = Base.LoadPlugin(Path.Combine(pluginPath, "libbass_mpc.so")); #endif } else if (OS.Type == OSType.MacOSX) { #if IOS // Load decoding plugins (http://www.un4seen.com/forum/?topic=13851.msg96559#msg96559) _flacPluginHandle = Base.LoadPlugin("BASSFLAC"); _wvPluginHandle = Base.LoadPlugin("BASSWV"); _apePluginHandle = Base.LoadPlugin("BASS_APE"); _mpcPluginHandle = Base.LoadPlugin("BASS_MPC"); int bassEncVersionOSX = BaseEnc.GetVersion(); Console.WriteLine("Player init -- Configuring IOSNOTIFY delegate..."); _iosNotifyProc = new IOSNOTIFYPROC(IOSNotifyProc); IntPtr ptr = Marshal.GetFunctionPointerForDelegate(_iosNotifyProc); Bass.BASS_SetConfigPtr((BASSConfig)46, ptr); //Bass.BASS_SetConfigPtr(BASSIOSConfig.BASS_CONFIG_IOS_NOTIFY, ptr); Console.WriteLine("Player init -- Configuring AirPlay and remote control..."); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_IOS_MIXAUDIO, 0); // 0 = AirPlay #else // Try to get the plugins in the current path Console.WriteLine("Loading OS X plugins..."); string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginPath = exePath.Replace("MonoBundle", "Resources"); // Check in the current directory first if(!File.Exists(pluginPath + "/libbassflac.dylib")) { // The plugins could not be found! throw new Exception("The BASS plugins could not be found in the current directory!"); } // Load decoding plugins _flacPluginHandle = Base.LoadPlugin(pluginPath + "/libbassflac.dylib"); _wvPluginHandle = Base.LoadPlugin(pluginPath + "/libbasswv.dylib"); _mpcPluginHandle = Base.LoadPlugin(pluginPath + "/libbass_mpc.dylib"); _apePluginHandle = Base.LoadPlugin(pluginPath + "/libbass_ape.dylib"); _ttaPluginHandle = Base.LoadPlugin(pluginPath + "/libbass_tta.dylib"); int bassEncVersion2 = BaseEnc.GetVersion(); //Console.WriteLine("OSX Bassenc.dylib version: {0}", bassEncVersion); #endif } } #if IOS _bpmProc = new BPMPROC(BPMDetectionProcIOS); //bpmBeatProc = new BPMBEATPROC(BPMDetectionBeatProcIOS); #else _bpmProc = new BPMPROC(BPMDetectionProc); //bpmBeatProc = new BPMBEATPROC(BPMDetectionBeatProc); #endif // Create default EQ Tracing.Log("Player init -- Creating default EQ preset..."); _currentEQPreset = new EQPreset(); if (initializeDevice) { Tracing.Log("Player init -- Initializing device..."); InitializeDevice(device, mixerSampleRate); } }
/// <summary> /// Applies a preset on the 18-band equalizer. /// The equalizer needs to be created using the AddEQ method. /// </summary> public void ApplyEQPreset(EQPreset preset) { //Console.WriteLine("Player - ApplyEQPreset name: {0}", preset.Name); BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ(); _currentEQPreset = preset; if (_isEQBypassed) return; if(!_isPlaying) return; //Console.WriteLine("Player - ApplyEQPreset - Removing BPM callbacks..."); RemoveBPMCallbacks(); //Console.WriteLine("Player - ApplyEQPreset - Looping through bands"); for (int a = 0; a < _currentEQPreset.Bands.Count; a++) { //Console.WriteLine("Player - ApplyEQPreset name: {0} - Applying band {1}", preset.Name, a); EQPresetBand currentBand = _currentEQPreset.Bands[a]; eq.lBand = a; eq.lChannel = BASSFXChan.BASS_BFX_CHANALL; eq.fCenter = currentBand.Center; eq.fGain = currentBand.Gain; eq.fQ = currentBand.Q; bool success = BassWrapper.BASS_FXSetParametersPeakEQ(_fxEQHandle, eq); if(!success) Base.CheckForError(); } //Console.WriteLine("Player - ApplyEQPreset - Readding BPM callbacks..."); AddBPMCallbacks(); }
/// <summary> /// Adds the 18-band equalizer. /// </summary> /// <param name="preset">EQ preset to apply</param> protected void AddEQ(EQPreset preset) { if (_mixerChannel == null) throw new Exception("Error adding EQ: The mixer channel doesn't exist!"); if (_fxEQHandle != 0 || _isEQEnabled) throw new Exception("Error adding EQ: The equalizer already exists!"); _fxEQHandle = _mixerChannel.SetFX(BASSFXType.BASS_FX_BFX_PEAKEQ, 0); ApplyEQPreset(preset); _isEQEnabled = true; }
partial void actionRemovePreset(NSObject sender) { using(NSAlert alert = new NSAlert()) { alert.MessageText = "Equalizer preset will be deleted"; alert.InformativeText = "Are you sure you wish to delete this equalizer preset?"; alert.AlertStyle = NSAlertStyle.Warning; var btnOK = alert.AddButton("OK"); btnOK.Activated += (sender2, e2) => { NSApplication.SharedApplication.StopModal(); OnDeletePreset(_preset.EQPresetId); EnableFaders(false); EnablePresetDetails(false); ResetFaderValuesAndPresetDetails(); _preset = null; }; var btnCancel = alert.AddButton("Cancel"); btnCancel.Activated += (sender3, e3) => { NSApplication.SharedApplication.StopModal(); }; alert.RunModal(); } }
public void RefreshPreset(EQPreset preset) { _hasPresetChanged = false; _preset = preset; InvokeOnMainThread(delegate { EnableFaders(true); EnablePresetDetails(true); txtName.StringValue = _preset.Name; fader0.ValueWithoutEvent = FormatFaderValue(_preset.Gain0); fader1.ValueWithoutEvent = FormatFaderValue(_preset.Gain1); fader2.ValueWithoutEvent = FormatFaderValue(_preset.Gain2); fader3.ValueWithoutEvent = FormatFaderValue(_preset.Gain3); fader4.ValueWithoutEvent = FormatFaderValue(_preset.Gain4); fader5.ValueWithoutEvent = FormatFaderValue(_preset.Gain5); fader6.ValueWithoutEvent = FormatFaderValue(_preset.Gain6); fader7.ValueWithoutEvent = FormatFaderValue(_preset.Gain7); fader8.ValueWithoutEvent = FormatFaderValue(_preset.Gain8); fader9.ValueWithoutEvent = FormatFaderValue(_preset.Gain9); fader10.ValueWithoutEvent = FormatFaderValue(_preset.Gain10); fader11.ValueWithoutEvent = FormatFaderValue(_preset.Gain11); fader12.ValueWithoutEvent = FormatFaderValue(_preset.Gain12); fader13.ValueWithoutEvent = FormatFaderValue(_preset.Gain13); fader14.ValueWithoutEvent = FormatFaderValue(_preset.Gain14); fader15.ValueWithoutEvent = FormatFaderValue(_preset.Gain15); fader16.ValueWithoutEvent = FormatFaderValue(_preset.Gain16); fader17.ValueWithoutEvent = FormatFaderValue(_preset.Gain17); lblEQValue0.StringValue = FormatEQValue(_preset.Gain0); lblEQValue1.StringValue = FormatEQValue(_preset.Gain1); lblEQValue2.StringValue = FormatEQValue(_preset.Gain2); lblEQValue3.StringValue = FormatEQValue(_preset.Gain3); lblEQValue4.StringValue = FormatEQValue(_preset.Gain4); lblEQValue5.StringValue = FormatEQValue(_preset.Gain5); lblEQValue6.StringValue = FormatEQValue(_preset.Gain6); lblEQValue7.StringValue = FormatEQValue(_preset.Gain7); lblEQValue8.StringValue = FormatEQValue(_preset.Gain8); lblEQValue9.StringValue = FormatEQValue(_preset.Gain9); lblEQValue10.StringValue = FormatEQValue(_preset.Gain10); lblEQValue11.StringValue = FormatEQValue(_preset.Gain11); lblEQValue12.StringValue = FormatEQValue(_preset.Gain12); lblEQValue13.StringValue = FormatEQValue(_preset.Gain13); lblEQValue14.StringValue = FormatEQValue(_preset.Gain14); lblEQValue15.StringValue = FormatEQValue(_preset.Gain15); lblEQValue16.StringValue = FormatEQValue(_preset.Gain16); lblEQValue17.StringValue = FormatEQValue(_preset.Gain17); int row = _presets.FindIndex(x => x.EQPresetId == _preset.EQPresetId); if(row >= 0) tablePresets.SelectRows(NSIndexSet.FromIndex(row), false); }); }
public void RefreshPreset(EQPreset preset) { if (preset == null) return; _hasPresetChanged = false; _preset = preset; Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { EnableFaders(true); EnablePresetDetails(true); //gridCurrentPreset.IsEnabled = _preset != null; //gridFaders.IsEnabled = _preset != null; txtPresetName.Text = preset.Name; //lblGain0.Text = preset.Gain0; fader0.ValueWithoutEvent = (Int32)(preset.Bands[0].Gain * 10); fader1.ValueWithoutEvent = (Int32)(preset.Bands[1].Gain * 10); fader2.ValueWithoutEvent = (Int32)(preset.Bands[2].Gain * 10); fader3.ValueWithoutEvent = (Int32)(preset.Bands[3].Gain * 10); fader4.ValueWithoutEvent = (Int32)(preset.Bands[4].Gain * 10); fader5.ValueWithoutEvent = (Int32)(preset.Bands[5].Gain * 10); fader6.ValueWithoutEvent = (Int32)(preset.Bands[6].Gain * 10); fader7.ValueWithoutEvent = (Int32)(preset.Bands[7].Gain * 10); fader8.ValueWithoutEvent = (Int32)(preset.Bands[8].Gain * 10); fader9.ValueWithoutEvent = (Int32)(preset.Bands[9].Gain * 10); fader10.ValueWithoutEvent = (Int32)(preset.Bands[10].Gain * 10); fader11.ValueWithoutEvent = (Int32)(preset.Bands[11].Gain * 10); fader12.ValueWithoutEvent = (Int32)(preset.Bands[12].Gain * 10); fader13.ValueWithoutEvent = (Int32)(preset.Bands[13].Gain * 10); fader14.ValueWithoutEvent = (Int32)(preset.Bands[14].Gain * 10); fader15.ValueWithoutEvent = (Int32)(preset.Bands[15].Gain * 10); fader16.ValueWithoutEvent = (Int32)(preset.Bands[16].Gain * 10); fader17.ValueWithoutEvent = (Int32)(preset.Bands[17].Gain * 10); lblValue0.Content = FormatEQValue(preset.Bands[0].Gain); lblValue1.Content = FormatEQValue(preset.Bands[1].Gain); lblValue2.Content = FormatEQValue(preset.Bands[2].Gain); lblValue3.Content = FormatEQValue(preset.Bands[3].Gain); lblValue4.Content = FormatEQValue(preset.Bands[4].Gain); lblValue5.Content = FormatEQValue(preset.Bands[5].Gain); lblValue6.Content = FormatEQValue(preset.Bands[6].Gain); lblValue7.Content = FormatEQValue(preset.Bands[7].Gain); lblValue8.Content = FormatEQValue(preset.Bands[8].Gain); lblValue9.Content = FormatEQValue(preset.Bands[9].Gain); lblValue10.Content = FormatEQValue(preset.Bands[10].Gain); lblValue11.Content = FormatEQValue(preset.Bands[11].Gain); lblValue12.Content = FormatEQValue(preset.Bands[12].Gain); lblValue13.Content = FormatEQValue(preset.Bands[13].Gain); lblValue14.Content = FormatEQValue(preset.Bands[14].Gain); lblValue15.Content = FormatEQValue(preset.Bands[15].Gain); lblValue16.Content = FormatEQValue(preset.Bands[16].Gain); lblValue17.Content = FormatEQValue(preset.Bands[17].Gain); int row = _presets.FindIndex(x => x.EQPresetId == _preset.EQPresetId); if (row >= 0) listViewPresets.SelectedIndex = row; })); }
public void RefreshPreset(EQPreset preset) { Console.WriteLine("EffectsWindow - RefreshPreset"); Gtk.Application.Invoke(delegate{ _preset = preset; txtPresetName.Text = preset.Name; label1Value.Text = FormatEQValue(preset.Gain0); vscale1.Value = preset.Gain0; label2Value.Text = FormatEQValue(preset.Gain1); vscale2.Value = preset.Gain1; label3Value.Text = FormatEQValue(preset.Gain2); vscale3.Value = preset.Gain2; label4Value.Text = FormatEQValue(preset.Gain3); vscale4.Value = preset.Gain3; label5Value.Text = FormatEQValue(preset.Gain4); vscale5.Value = preset.Gain4; label6Value.Text = FormatEQValue(preset.Gain5); vscale6.Value = preset.Gain5; label7Value.Text = FormatEQValue(preset.Gain6); vscale7.Value = preset.Gain6; label8Value.Text = FormatEQValue(preset.Gain7); vscale8.Value = preset.Gain7; label9Value.Text = FormatEQValue(preset.Gain8); vscale9.Value = preset.Gain8; label10Value.Text = FormatEQValue(preset.Gain9); vscale10.Value = preset.Gain9; label11Value.Text = FormatEQValue(preset.Gain10); vscale11.Value = preset.Gain10; label12Value.Text = FormatEQValue(preset.Gain11); vscale12.Value = preset.Gain11; label13Value.Text = FormatEQValue(preset.Gain12); vscale13.Value = preset.Gain12; label14Value.Text = FormatEQValue(preset.Gain13); vscale14.Value = preset.Gain13; label15Value.Text = FormatEQValue(preset.Gain14); vscale15.Value = preset.Gain14; label16Value.Text = FormatEQValue(preset.Gain15); vscale16.Value = preset.Gain15; label17Value.Text = FormatEQValue(preset.Gain16); vscale17.Value = preset.Gain16; label18Value.Text = FormatEQValue(preset.Gain17); vscale18.Value = preset.Gain17; }); }
public void RefreshPresets(IEnumerable<EQPreset> presets, Guid selectedPresetId, bool isEQBypassed) { bool isFirstRefresh = _presets == null; _presets = presets.ToList(); _preset = _presets.FirstOrDefault(x => x.EQPresetId == selectedPresetId); Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { listViewPresets.Items.Clear(); foreach (var preset in _presets) listViewPresets.Items.Add(preset); if(isFirstRefresh) RefreshPreset(_preset); })); }
private void RemovePreset() { if (MessageBox.Show("Are you sure you wish to delete this equalizer preset?", "Delete equalizer preset", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) return; OnDeletePreset(_preset.EQPresetId); EnableFaders(false); EnablePresetDetails(false); ResetFaderValuesAndPresetDetails(); _preset = null; }
public void SetPreset(EQPreset preset) { _preset = preset; Invalidate(); }
public void UpdateEQPreset(EQPreset preset) { _gateway.UpdateEQPreset(preset); }
public void InsertEQPreset(EQPreset preset) { _gateway.InsertEQPreset(preset); }