class FuturoCube::DumpCommand
Public Instance Methods
args_valid?(args)
click to toggle source
# File lib/futurocube/dump_command.rb, line 31 def args_valid?(args) args.length == 2 end
exec(file, dir)
click to toggle source
# File lib/futurocube/dump_command.rb, line 10 def exec(file, dir) ResourceFile.open(file) do |rf| with_progress('Dumping', rf.records.size) do |progress| rf.records.each do |rec| data = rf.data(rec) f = File.join(dir, "#{rec.name}.wav") format = WaveFile::Format.new(:mono, :pcm_16, 22050) WaveFile::Writer.new(f, format) do |writer| #TODO: is there a way to write a buffer directly? samples = data.unpack("S<*") buffer = WaveFile::Buffer.new(samples, format) writer.write(buffer) end progress.inc end end end end
usage()
click to toggle source
# File lib/futurocube/dump_command.rb, line 35 def usage "filename directory" end