about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-14 08:04:32 +0000
committerEric Wong <e@80x24.org>2015-12-14 08:20:34 +0000
commit7bed564d979ce7eceac9cd382be5c993cf0acfc5 (patch)
tree058d06d065f88fdcd65bf91c50bfb40e93105546 /bin
parent9263eecf93555beb3567af401a2bfdf25df5e8cd (diff)
downloaddtas-7bed564d979ce7eceac9cd382be5c993cf0acfc5.tar.gz
This is on a linear scale from 0.0 (mute) to 1.0 (no change)
This is in the MPRIS spec and mpd as well (scaled to 0-100)

This changes dtas-console key bindings (0/9) slightly to match
mplayer more closely.  ReplayGain preamp adjustment has moved from
'0'/'9' to '7'/'8' keys.  The 'm' key also toggles mute state (the
pre-mute volume is stored in the dtas-console instance, not in
dtas-player itself).
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dtas-console19
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/dtas-console b/bin/dtas-console
index a98244b..a8e1838 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -114,6 +114,7 @@ def may_fail(res, events)
   events << res if res != "OK"
 end
 
+pre_mute_vol = 1.0
 enc_locale = Encoding.find("locale")
 $stdout.set_encoding(enc_locale)
 enc_opts = { undef: :replace, invalid: :replace, replace: '?' }
@@ -163,12 +164,18 @@ begin
       Curses.setpos(lineno += 1, 0)
       Curses.clrtoeol
     end
-
-    rgs = rg_string(cur["rg"] || {}, current)
+    rg = cur['rg'] || {}
+    rgs = rg_string(rg, current)
     Curses.setpos(lineno += 1, 0)
     Curses.clrtoeol
     Curses.addstr(rgs)
 
+    Curses.setpos(lineno += 1, 0)
+    Curses.clrtoeol
+    cur_vol = rg['volume'] || 1.0
+    Curses.addstr("volume=#{cur_vol}")
+    pre_mute_vol = cur_vol if cur_vol != 0
+
     show_events(lineno, screen, events)
 
     Curses.refresh # draw and wait
@@ -206,8 +213,12 @@ begin
         # yes, some of us have long audio files
         when Curses::KEY_PPAGE then c.req_ok("seek +600")
         when Curses::KEY_NPAGE then c.req_ok("seek -600")
-        when "9" then c.req_ok("rg preamp-=1")
-        when "0" then c.req_ok("rg preamp+=1")
+        when '9' then c.req_ok('rg volume-=0.01')
+        when '0' then c.req_ok('rg volume+=0.01')
+        when '=' then c.req_ok('rg volume=1')
+        when '7' then c.req_ok('rg preamp-=1')
+        when '8' then c.req_ok('rg preamp+=1')
+        when 'm' then c.req_ok("rg volume=#{cur_vol == 0 ? pre_mute_vol : 0}")
         when "F" then c.req_ok("rg fallback_gain+=1")
         when "f" then c.req_ok("rg fallback_gain-=1")
         when ">" then c.req_ok("tl next")