Class: Beats
- Inherits:
-
Object
- Object
- Beats
- Defined in:
- lib/beats.rb
Constant Summary collapse
- BEATS_VERSION =
"1.2.3"
- OPTIMIZED_PATTERN_LENGTH =
Each pattern in the song will be split up into sub patterns that have at most this many steps. In general, audio for several shorter patterns can be generated more quickly than for one long pattern, and can also be cached more effectively.
4
Instance Method Summary collapse
-
#initialize(input_file_name, output_file_name, options) ⇒ Beats
constructor
A new instance of Beats.
- #run ⇒ Object
Constructor Details
#initialize(input_file_name, output_file_name, options) ⇒ Beats
Returns a new instance of Beats.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/beats.rb', line 9 def initialize(input_file_name, output_file_name, ) @input_file_name = input_file_name if output_file_name == nil output_file_name = File.basename(input_file_name, File.extname(input_file_name)) + ".wav" end @output_file_name = output_file_name @options = end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/beats.rb', line 20 def run base_path = @options[:base_path] || File.dirname(@input_file_name) song, kit = SongParser.new().parse(base_path, File.read(@input_file_name)) song = normalize_for_pattern_option(song) songs_to_generate = normalize_for_split_option(song) duration = nil song_optimizer = SongOptimizer.new() songs_to_generate.each do |output_file_name, song| song = song_optimizer.optimize(song, OPTIMIZED_PATTERN_LENGTH) duration = AudioEngine.new(song, kit).write_to_file(output_file_name) end return {:duration => duration} end |