class RSGuitarTech::WavShifter
Constants
- TS_CONV
Attributes
amount[RW]
dir[RW]
wav[RW]
Public Class Methods
new(opts)
click to toggle source
# File lib/rsgt/wav_shifter.rb, line 6 def initialize(opts) @wav = File.expand_path(opts.delete :wav) @dir = opts[:dir] @amount = opts[:amount].to_i end
Public Instance Methods
shift!()
click to toggle source
# File lib/rsgt/wav_shifter.rb, line 12 def shift! case dir when "forward" then forward! when /back/ then backward! end end
Private Instance Methods
backward!()
click to toggle source
# File lib/rsgt/wav_shifter.rb, line 25 def backward! Dir.mktmpdir do |tmpdir| puts "Trimming #{amount}ms from beginning..." status = CommandRunner.run! [ "ffmpeg", "-i", wav, "-ss", start_trim_timestamp, "-acodec", "copy", "#{tmpdir}/shifted.wav" ] if status.success? puts "Success!" FileUtils.cp "#{tmpdir}/shifted.wav", wav else puts "Failed!" end end end
forward!()
click to toggle source
# File lib/rsgt/wav_shifter.rb, line 21 def forward! raise NotImplementedError end
start_trim_timestamp()
click to toggle source
# File lib/rsgt/wav_shifter.rb, line 45 def start_trim_timestamp h = (amount / TS_CONV[3]) m = (amount % TS_CONV[3] / TS_CONV[2]) s = (amount % TS_CONV[2] / TS_CONV[1]) ms = (amount % TS_CONV[1]) "%02d:%02d:%02d.%03d" % [h, m, s, ms] end