示例#1
0
        private void UpdateEqalizerButtons(EqualizerPreset preset)
        {
            switch (preset)
            {
                case EqualizerPreset.Default:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnDefault.IsEnabled = true;
                        btnDefault.Text = "Default - ON";
                    });
                    break;
                case EqualizerPreset.Rock:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnRock.IsEnabled = true;
                        btnRock.Text = "Rock - ON";
                    });
                    break;
                case EqualizerPreset.Jazz:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnJazz.IsEnabled = true;
                        btnJazz.Text = "Jazz - ON";
                    });
                    break;
                case EqualizerPreset.Folk:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnFolk.IsEnabled = true;
                        btnFolk.Text = "Folk - ON";
                    });
                    break;
                case EqualizerPreset.Pop:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnPop.IsEnabled = true;
                        btnPop.Text = "Pop - ON";
                    });
                    break;
                case EqualizerPreset.Classic:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        InitEqulizeralPresetButtons();

                        btnClassic.IsEnabled = true;
                        btnClassic.Text = "Classic - ON";
                    });
                    break;
            }
        }
示例#2
0
        public void LoadPresets(bool force = false)
        {
            if (Presets.Count == 0 || force)
            {
                var groupInfo = new GroupInfo {
                    OrderBy = "Name"
                };
                Presets = Database.Main.GetObjects <EqualizerPreset>(groupInfo).OrderBy(x => x.Name).ToList();
                if (Presets.Count == 0 || force)
                {
                    foreach (var p in DefaultPresets)
                    {
                        p.Save();
                    }
                    Presets = Database.Main.GetObjects <EqualizerPreset>(groupInfo);
                }


                EqualizerPreset preset = Presets.FirstOrDefault(x => x.Id == StateManager.Shared.GlobalEqualizerPreset);
                if (preset != null)
                {
                    ApplyPreset(preset);
                }
            }
        }
示例#3
0
 public void SetPreset(EqualizerPreset preset)
 {
     if (preset == null)
     {
         return;
     }
     try
     {
         EqualizerManager.Shared.SaveCurrent();
         shouldSave = false;
         Equalizer.Shared.CurrentPreset = preset;
         Settings.EqualizerPreset       = preset.Id;
         for (int i = 0; i < preset.Values.Length; i++)
         {
             var value = preset.Values[i].Value;
             sliders[i].DoubleValue = value;
             EqualizerManager.Shared.SetGain((int)sliders[i].Tag, (float)value);
         }
         shouldSave = true;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
示例#4
0
        public async Task <List <EqualizerPreset> > GetPresetsAsync()
        {
            var presets = new List <EqualizerPreset>();

            // First, get the builtin equalizer presets
            presets = await this.GetBuiltInPresetsAsync();

            // Then, get custom equalizer presets
            var customPresets = await this.GetCustomEqualizerPresetsAsync();

            foreach (var preset in customPresets)
            {
                // Give priority to built-in presets. If the user messed up and created a custom preset
                // file which has the same name as a built-in preset file, the custom file is ignored.
                if (!presets.Contains(preset))
                {
                    presets.Add(preset);
                }
            }

            // Sort the presets
            presets = presets.OrderBy((p) => p.Name.ToLower()).ToList();

            // Insert manual preset in first position
            var manualPreset = new EqualizerPreset(Defaults.ManualPresetName, false);

            manualPreset.Load(ArrayUtils.ConvertArray(SettingsClient.Get <string>("Equalizer", "ManualPreset").Split(';')));
            presets.Insert(0, manualPreset);

            return(presets);
        }
示例#5
0
        public static void LoadPresets(bool force = false)
        {
            if (Presets.Count == 0 || force)
            {
                var groupInfo = new GroupInfo {
                    OrderBy = "Name"
                };
                Presets = Database.Main.GetObjects <EqualizerPreset>(groupInfo).OrderBy(x => x.Name).ToList();
                if (Presets.Count == 0 || force)
                {
                    foreach (var p in DefaultPresets)
                    {
                        p.Save();
                    }
                    Presets = Database.Main.GetObjects <EqualizerPreset>(groupInfo);
                }

                if (force)
                {
                    EqualizerPreset preset = Presets.FirstOrDefault(x => x.Id == Settings.EqualizerPreset);
                    if (preset != null)
                    {
                        CurrentPreset = preset;
                    }
                }
            }
        }
示例#6
0
        public void Reset(EqualizerPreset preset)
        {
            var match = Equalizer.DefaultPresets.FirstOrDefault(x => x.GlobalId == preset.GlobalId) ?? new EqualizerPreset()
            {
                DoubleValues = new double[10]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                }
            };

            for (var i = 0; i < preset.Values.Length; i++)
            {
                preset.Values[i].Value = match.Values[i].Value;
            }
            preset.Save();
            ReloadPresets();
        }
示例#7
0
 private void SetPreset(EqualizerPreset preset)
 {
     int PAYLOAD_LENGTH = 1;
     int PRESET_OFFSET = 0;
     byte[] payload = new byte[PAYLOAD_LENGTH];
     payload[PRESET_OFFSET] = (byte)preset;
     CreateRequest(CreatePacket(GAIA.COMMAND_SET_EQ_CONTROL, payload));
 }
示例#8
0
 static void ApplyPreset(EqualizerPreset preset)
 {
     for (int i = 0; i < preset.Values.Count(); i++)
     {
         var gain = (float)preset.Values[i].Value;
         Bands[i].Gain = gain;
         PlaybackManager.Shared.Player.UpdateBand(i, gain);
     }
 }
示例#9
0
 public void ApplyPreset(EqualizerPreset preset)
 {
     CurrentPreset = preset;
     for (int i = 0; i < preset.Values.Count(); i++)
     {
         var gain = (float)preset.Values[i].Value;
         Bands[i].Gain = gain;
         UpdateBand(i, gain);
     }
 }
        public async Task SetIsEqualizerEnabledAsync(bool isEnabled)
        {
            this.isEqualizerEnabled = isEnabled;

            this.desiredPreset = await this.equalizerService.GetSelectedPresetAsync();

            this.activePreset = isEnabled ? this.desiredPreset : new EqualizerPreset();

            if (this.player != null)
            {
                this.player.ApplyFilter(this.activePreset.Bands);
            }
        }
示例#11
0
        public void ApplyPreset(EqualizerPreset preset)
        {
            this.desiredPreset = preset;

            if (this.isEqualizerEnabled)
            {
                this.activePreset = desiredPreset;
                if (this.player != null)
                {
                    this.player.ApplyFilter(this.activePreset.Bands);
                }
            }
        }
示例#12
0
        public async Task <EqualizerPreset> GetSelectedPresetAsync()
        {
            var presets = await this.GetPresetsAsync();

            string          selectedPresetName = SettingsClient.Get <string>("Equalizer", "SelectedPreset");
            EqualizerPreset selectedPreset     = presets.Select((p) => p).Where((p) => p.Name == selectedPresetName).FirstOrDefault();

            if (selectedPreset == null)
            {
                selectedPreset = new EqualizerPreset(Defaults.ManualPresetName, false);
            }

            return(selectedPreset);
        }
示例#13
0
        private void cboEqualizerPreset_SelectedIndexChanged(object sender, EventArgs e)
        {
            EqualizerPreset preset = cboEqualizerPreset.GetEnumValue <EqualizerPreset>();

            foreach (Control ctrl in tlpEqualizer.Controls)
            {
                if (ctrl is ctrlTrackbar)
                {
                    ctrl.Enabled = preset < EqualizerPreset.TwinFamicom60;
                }
            }

            AudioInfo audio = (AudioInfo)Entity;

            audio.EqualizerPreset = preset;
            switch (preset)
            {
            case EqualizerPreset.TwinFamicom:
                audio.Band1Gain  = -44;
                audio.Band2Gain  = -22;
                audio.Band3Gain  = -10;
                audio.Band4Gain  = -7;
                audio.Band5Gain  = -3;
                audio.Band6Gain  = 0;
                audio.Band7Gain  = -2;
                audio.Band8Gain  = -3;
                audio.Band9Gain  = 0;
                audio.Band10Gain = -3;
                audio.Band11Gain = -4;
                audio.Band12Gain = -9;
                audio.Band13Gain = -17;
                audio.Band14Gain = -28;
                audio.Band15Gain = -44;
                audio.Band16Gain = -65;
                audio.Band17Gain = -83;
                audio.Band18Gain = -103;
                audio.Band19Gain = -109;
                audio.Band20Gain = -94;
                UpdateUI();
                break;
            }

            if (cboEqualizerPreset.GetEnumValue <EqualizerPreset>() != preset)
            {
                this.BeginInvoke((Action)(() => {
                    cboEqualizerPreset.SetEnumValue(preset);
                }));
            }
        }
示例#14
0
        public async void SetIsEqualizerEnabled(bool isEnabled)
        {
            this.isEqualizerEnabled = isEnabled;

            this.desiredPreset = await this.equalizerService.GetSelectedPresetAsync();

            if (isEnabled)
            {
                this.activePreset = this.desiredPreset;
            }
            else
            {
                this.activePreset = new EqualizerPreset();
            }

            if (this.player != null)
            {
                this.player.ApplyFilter(this.activePreset.Bands);
            }
        }
        async Task setPreset(EqualizerPreset preset)
        {
            try
            {
                if (CurrentItem == null)
                {
                    Equalizer.Shared.CurrentPreset = preset;
                }
                else
                {
#if iPod
                    Equalizer.SaveEq(currentItem, preset);
                    if (CurrentItem == AudioPlayer.Shared.CurrentSong)
                    {
                        await Equalizer.Shared.ApplyEqualizer();
                    }
#else
                    Equalizer.Shared.ApplyEqualizer();
#endif
                }
                SetSourc();
                if (PresetSelected != null)
                {
                    PresetSelected(preset);
                }
#if PIONEER
                if (PPioneerManager.SharedPioneerManager.Connected)
                {
                    NavigationController.PopViewController(true);
                }
                else
#endif
                this.NavigationController.DismissViewController(true, null);
            }
            catch (Exception ex)
            {
                LogManager.Shared.Report(ex);
            }
            //TableView.ReloadData ();
        }
        private void ApplyManualPreset()
        {
            if (!this.canApplyManualPreset)
            {
                return;
            }

            EqualizerPreset manualPreset = this.Presets.Select((p) => p).Where((p) => p.Name == Defaults.ManualPresetName).FirstOrDefault();

            manualPreset.Load(this.Band0, this.Band1, this.Band2, this.Band3, this.Band4, this.Band5, this.Band6, this.Band7, this.Band8, this.Band9);

            XmlSettingsClient.Instance.Set <string>("Equalizer", "ManualPreset", manualPreset.ToValueString());

            // Once a slider has moved, revert to the manual preset (also in the settings).
            if (this.SelectedPreset.Name != Defaults.ManualPresetName)
            {
                this.SelectedPreset = manualPreset;
                XmlSettingsClient.Instance.Set <string>("Equalizer", "SelectedPreset", Defaults.ManualPresetName);
            }

            this.playbackService.ApplyPreset(manualPreset);
        }
示例#17
0
        private EqualizerPreset CreatePresetFromFile(string filename, bool isRemovable)
        {
            var preset = new EqualizerPreset(Path.GetFileNameWithoutExtension(filename), isRemovable);

            using (var reader = new StreamReader(filename))
            {
                var bandValuesList = new List <double>();

                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    double value;
                    if (double.TryParse(line, NumberStyles.Number, CultureInfo.InvariantCulture, out value))
                    {
                        bandValuesList.Add(value);
                    }
                }

                preset.Load(bandValuesList.ToArray());
            }

            return(preset);
        }
示例#18
0
        public void AddPreset(string name)
        {
            var preset = new EqualizerPreset()
            {
                Name         = name,
                DoubleValues = new double[10]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                }
            };

            preset.Save();
            ReloadPresets();
        }
示例#19
0
 public void Delete(EqualizerPreset preset)
 {
     preset.Delete();
     ReloadPresets();
 }