examples/afromb.rb in scissor-echonest-0.0.8 vs examples/afromb.rb in scissor-echonest-0.1.0

- old
+ new

@@ -9,22 +9,16 @@ # http://soundcloud.com/youpy/pocket-calculator-scissor-afroma-mix require 'rubygems' require 'scissor/echonest' require 'narray' - -Scissor.logger.level = Logger::DEBUG - + class AfromB def initialize(a, b = nil) @a, @b = [a, b || a] - @segments_of_a = @a.inject([]) do |memo, file| - memo += Scissor(file).segments - memo - end - + @segments_of_a = Scissor(@a).segments @segments_of_b = (@a == @b) ? @segments_of_a : Scissor(@b).segments end def get_distance_from(target) dur_weight = 1000 @@ -71,25 +65,23 @@ end Scissor.join(result) end end - + if __FILE__ == $0 require 'pit' - + Scissor.echonest_api_key = Pit.get('echonest.com', :require => { 'api_key' => 'your Echo Nest API key' })['api_key'] Scissor::Chunk.echonest.user_agent.send_timeout = 300 - if ARGV.size == 2 + if ARGV.size == 3 + a, b, outfile = ARGV + else a, outfile = ARGV b = a - else - a = ARGV - outfile = a.pop - b = a.pop end - AfromB.new(a, b).run > outfile + AfromB.new(a, b).run >> outfile end