-
Notifications
You must be signed in to change notification settings - Fork 0
/
msu1_helper.rb
executable file
·44 lines (40 loc) · 1.16 KB
/
msu1_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'pathname'
require 'optparse'
require 'ostruct'
require 'fileutils'
require 'json'
require './lib/file_convertor'
require './lib/loop_table'
require './lib/argument_parser'
class Msu1Helper
def initialize(options)
@options = options
end
def execute!
case @options.output_type
when 'wav_pcm_s16le'
@options.input_files.each {|filename|
FileConvertor.new(filename,{
destdir: @options.destdir,
}).convert_to_wav!
}
when 'msu1_pcm'
@options.input_files.each {|filename|
loop_start, loop_end =
if loop_bounds = @options.loop_table&.loop_bounds_by_filename(filename)
[loop_bounds[:loop_start], loop_bounds[:loop_end]]
else
[@options.loop_start, @options.loop_end]
end
FileConvertor.new(filename,{
loop_start_sample_number: loop_start,
loop_end_sample_number: loop_end,
destdir: @options.destdir,
no_clobber: @options.no_clobber,
}).convert_wav_to_msu1_pcm!
}
end
end
end # Msu1Helper
options = ArgumentParser.parse(ARGV)
Msu1Helper.new(options).execute!