class AudioTrack
Attributes
duration[R]
wavefile[R]
Public Class Methods
from_file(infile)
click to toggle source
# File lib/rtrack.rb, line 14 def self.from_file(infile) if not (File.exists? infile) fail StandardError, "Couldn't find file from path: #{infile}" end infile = File.open(infile) wavefile = Tempfile.new ['','.wav'] duration = RTrack::Transcoder.to_wave(infile.path, wavefile.path) AudioTrack.new wavefile, duration end
new(wavefile, duration)
click to toggle source
# File lib/rtrack.rb, line 9 def initialize (wavefile, duration) @wavefile = wavefile @duration = duration end
Public Instance Methods
+(other)
click to toggle source
# File lib/rtrack.rb, line 47 def +(other) info = RTrack::Transcoder.concat @wavefile.path, other.wavefile.path AudioTrack.new info["wavefile"], info["duration"] end
[](slice_range)
click to toggle source
# File lib/rtrack.rb, line 32 def [](slice_range) if not slice_range.class == Range fail StandardError, "Invalid slice was given: #{slice_range}" end slice_start, slice_end = slice_range.min, slice_range.max new_wavefile = Tempfile.new ['','.wav'] duration = RTrack::Transcoder.to_slice(@wavefile.path, new_wavefile.path, slice_start, slice_end) AudioTrack.new new_wavefile, duration end
export(outpath, format="mp3", bitrate="128k")
click to toggle source
# File lib/rtrack.rb, line 52 def export(outpath, format="mp3", bitrate="128k") return_code = RTrack::Transcoder.export(@wavefile.path, outpath, format, bitrate) return_code end
Also aliased as: save
path()
click to toggle source
# File lib/rtrack.rb, line 28 def path @wavefile.path end
seconds()
click to toggle source
# File lib/rtrack.rb, line 24 def seconds @duration / 1000 end