diff options
author | Eric Wong <e@80x24.org> | 2015-01-28 07:44:05 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-01-28 07:47:57 +0000 |
commit | 37eae22446feb5a805d9cd59f6ad54362829189f (patch) | |
tree | 50172ce0b549fb9a0eae1e2e0b4d6bc47bc3a8d6 /lib/dtas/player/client_handler.rb | |
parent | ead7725fa693c7dd832b22f77b32847c81a70d72 (diff) | |
download | dtas-37eae22446feb5a805d9cd59f6ad54362829189f.tar.gz |
This feature is intended to allow users to "zoom-in" on a particular portion of a track to tweak parameters (either with dtas-sourceedit(1) or via playback of splitfx YAML files). This may be combined with looping the tracklist (via "tl repeat").
Diffstat (limited to 'lib/dtas/player/client_handler.rb')
-rw-r--r-- | lib/dtas/player/client_handler.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 68f1d80..a867265 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -1,10 +1,12 @@ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org> # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require_relative '../xs' +require_relative '../parse_time' # client protocol handling for -player module DTAS::Player::ClientHandler # :nodoc: include DTAS::XS + include DTAS::ParseTime # returns true on success, wait_ctl arg on error def set_bool(io, kv, v) @@ -183,6 +185,7 @@ module DTAS::Player::ClientHandler # :nodoc: bytes = bytes < 0 ? 0 : bytes # maybe negative in case of sink errors end + # returns seek offset as an Integer in sample count def __seek_offset_adj(dir, offset) if offset.sub!(/s\z/, '') offset = offset.to_i @@ -680,5 +683,31 @@ module DTAS::Player::ClientHandler # :nodoc: io.emit("NOCUE") end end + + def trim_handler(io, msg) + case msg.size + when 0 + io.emit({ 'trim' => @trim }.to_yaml) + when 1, 2 + case msg[0] + when 'off' + @trim = nil + else + begin + tbeg = parse_time(msg[0]) + if tlen = msg[1] + absolute = tlen.sub!(/\A=/, '') # 44:00 =44:55 + tlen = parse_time(tlen) + tlen -= tbeg if absolute + end + @trim = [ tbeg, tlen ] # seconds as float, since we don't know rate + rescue => e + return io.emit("ERR #{e.message}") + end + end + __current_requeue + io.emit('OK') + end + end end # :startdoc: |