Equalizer.lua 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. --[[
  2. Version 1.3
  3. Cycle audio equalizer presets.
  4. Hotkeys: alt+e (cycle forwards), alt+shift+e (cycle backwards)
  5. Equalizer presets found here:
  6. <http://advantage-bash.blogspot.in/2013/05/mplayer-presets.html>
  7. Modified 08/06/2015: v1.1 by Anonymous
  8. - added option to cycle backwards
  9. Modified 08/08/2015: v1.2 by Anonymous
  10. - code formatting, added EQPs "Boost" and "Double Boost"
  11. Modified 08/10/2015: v1.3 by Anonymous
  12. - changed binds to alt+e/alt+shift+e to avoid conflicts with
  13. shell key combinations in audio only mode
  14. Copyright (C) 2015 Anonymous
  15. This program is free software: you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation, either version 3 of the License, or
  18. (at your option) any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. --]]
  26. local eq_values = {
  27. "af set equalizer=6:4:2:1:0:0:0:1:3:7 ; show_text \"Equalizer: Pekman\"",
  28. "af set equalizer=0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0:0.0 ; show_text \"Equalizer: Flat (Default)\"",
  29. "af set equalizer=4.8:5.7:5.7:3.3:1.0:-2.4:-4.8:-6.3:-6.7:-6.7 ; show_text \"Equalizer: Full Bass\"",
  30. "af set equalizer=5.8:-5.8:-5.8:-2.4:1.4:6.7:9.6:9.6:9.6:10.1 ; show_text \"Equalizer: Full Treble\"",
  31. "af set equalizer=4.3:3.3:0.0:-4.4:-2.9:1.0:4.8:6.7:7.2:7.2 ; show_text \"Equalizer: Full Bass & Treble\"",
  32. "af set equalizer=2.8:6.7:3.3:-2.0:-1.4:1.0:2.8:5.7:7.7:8.6 ; show_text \"Equalizer: Headphones\"",
  33. "af set equalizer=6.2:6.2:3.3:3.3:0.0:-2.9:-2.9:-2.9:0.0:0.0 ; show_text \"Equalizer: Large Hall\"",
  34. "af set equalizer=2.9:0.0:2.4:3.3:3.3:3.3:2.4:1.4:1.4:1.4 ; show_text \"Equalizer: Live\"",
  35. "af set equalizer=4.3:4.3:0.0:0.0:0.0:0.0:0.0:0.0:4.3:4.3 ; show_text \"Equalizer: Party\"",
  36. "af set equalizer=2.8:1.0:0.0:-1.4:0.0:2.4:4.8:5.7:6.7:7.2 ; show_text \"Equalizer: Soft\"",
  37. "af set equalizer=0.0:0.0:0.0:0.0:0.0:-4.4:-4.4:-4.4:-5.8 ; show_text \"Equalizer: Classical\"",
  38. "af set equalizer=0.0:0.0:4.8:3.3:3.3:3.3:1.9:0.0:0.0 ; show_text \"Equalizer: Club\"",
  39. "af set equalizer=5.7:4.3:1.4:0.0:0.0:-3.4:-4.4:-4.3:0.0:0.0 ; show_text \"Equalizer: Dance\"",
  40. "af set equalizer=1.0:2.8:4.3:4.8:3.3:0.0:-1.4:-1.4:-1.0:-1.0 ; show_text \"Equalizer: Pop\"",
  41. "af set equalizer=0.0:0.0:0.0:-3.4:0.0:3.8:3.8:0.0:0.0:0.0 ; show_text \"Equalizer: Reggae\"",
  42. "af set equalizer=1.4:-2.9:-2.4:0.0:2.4:3.3:5.3:5.7:6.7:5.8 ; show_text \"Equalizer: Ska\"",
  43. "af set equalizer=2.4:2.4:1.4:0.0:-2.4:-3.4:-2.0:0.0:1.4:5.3 ; show_text \"Equalizer: Soft Rock\"",
  44. "af set equalizer=4.8:2.8:-3.4:-4.8:-2.0:2.4:5.3:6.7:6.7:6.7 ; show_text \"Equalizer: Rock\"",
  45. "af set equalizer=4.8:3.3:0.0:-3.4:-2.9:0.0:4.8:5.7:5.8:5.3 ; show_text \"Equalizer: Techno\"",
  46. "af set equalizer=2.5:2.5:0.0:0.0:0.0:0.0:0.0:0.0:2.5:2.5 ; show_text \"Equalizer: Boost (Anonymous)\"",
  47. "af set equalizer=5.0:5.0:0.0:0.0:0.0:0.0:0.0:0.0:5.0:5.0 ; show_text \"Equalizer: Double Boost (Anonymous)\""
  48. }
  49. local current_index = 1
  50. local function cycle_eq()
  51. local last_index = #eq_values
  52. if current_index == last_index then
  53. current_index = 1
  54. else
  55. current_index = current_index + 1
  56. end
  57. mp.command(eq_values[current_index])
  58. end
  59. local function cycle_eq_back()
  60. local last_index = #eq_values
  61. if current_index == 1 then
  62. current_index = last_index
  63. else
  64. current_index = current_index - 1
  65. end
  66. mp.command(eq_values[current_index])
  67. end
  68. mp.add_key_binding("alt+e", "cycle_eq_lua", cycle_eq)
  69. mp.add_key_binding("alt+E", "cycle_eq_back_lua", cycle_eq_back)