Skip to content

Instantly share code, notes, and snippets.

@youpy
Created July 20, 2011 17:30
Show Gist options
  • Save youpy/1095430 to your computer and use it in GitHub Desktop.
Save youpy/1095430 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'pit'
require 'scissor/echonest'
Scissor.echonest_api_key = Pit.get('echonest.com', :require => {
'api_key' => 'your Echo Nest API key'
})['api_key']
infile, outfile = ARGV
beats = Scissor(infile).beats
result = Scissor()
until beats.empty?
some_beats = beats.shift(rand(5) + 1)
duration = some_beats.inject(0) do |total, b|
total + b.duration
end
result += some_beats[0].stretch((duration / some_beats[0].duration.to_f) * 100)
end
result >> outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment