Class: FuturoCube::DumpCommand
- Inherits:
-
Object
- Object
- FuturoCube::DumpCommand
- Includes:
- CommandHelper
- Defined in:
- lib/futurocube/dump_command.rb
Instance Method Summary collapse
Methods included from CommandHelper
Instance Method Details
#args_valid?(args) ⇒ Boolean
31 32 33 |
# File 'lib/futurocube/dump_command.rb', line 31 def args_valid?(args) args.length == 2 end |
#exec(file, dir) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 ⇒ Object
35 36 37 |
# File 'lib/futurocube/dump_command.rb', line 35 def usage "filename directory" end |