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/source/file.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/source/file.rb')
-rw-r--r-- | lib/dtas/source/file.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/dtas/source/file.rb b/lib/dtas/source/file.rb index 8a9fa34..75b4a43 100644 --- a/lib/dtas/source/file.rb +++ b/lib/dtas/source/file.rb @@ -21,17 +21,18 @@ module DTAS::Source::File # :nodoc: FILE_SIVS = %w(infile comments command env) # for the "current" command SRC_SIVS = %w(command env tryorder) - def source_file_dup(infile, offset) + def source_file_dup(infile, offset, trim) rv = dup - rv.__file_init(infile, offset) + rv.__file_init(infile, offset, trim) rv end - def __file_init(infile, offset) + def __file_init(infile, offset, trim) @env = @env.dup @format = nil @infile = infile @offset = offset + @trim = trim @comments = nil @samples = nil @cuebp = nil @@ -47,6 +48,13 @@ module DTAS::Source::File # :nodoc: # returns any offset in samples (relative to the original source file), # likely zero unless seek was used def offset_samples + off = __offset_samples + return off unless @trim + tbeg = @trim[0] * format.rate + tbeg < off ? off : tbeg + end + + def __offset_samples return 0 unless @offset case @offset when /\A\d+s\z/ @@ -56,6 +64,16 @@ module DTAS::Source::File # :nodoc: end end + # creates the effect to fill the TRIMFX env + def trimfx + return unless @offset || @trim + fx = "trim #{offset_samples}s" + if @trim && @trim[1] + fx << sprintf(' =%0.9gs', (@trim[0] + @trim[1]) * format.rate) + end + fx + end + # A user may be downloading the file and start playing # it before the download completes, this refreshes def samples! |