Created
October 31, 2011 19:01
-
-
Save youpy/1328495 to your computer and use it in GitHub Desktop.
amenizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w!ubygems scissor/echonest pit open-uri tempfile!.each {|g| require g } | |
Scissor.logger.level = Logger::DEBUG | |
Scissor.echonest_api_key = Pit.get('echonest.com', :require => { | |
'api_key' => 'your Echo Nest API key' | |
})['api_key'] | |
infile, outfile = ARGV | |
file = Tempfile.new(%w/amen .wav/) | |
file.write(open('http://dl.dropbox.com/u/334064/amen_lq.wav').read) | |
amens = Scissor(file.path) / 4 | |
target = Scissor(infile) | |
result = Scissor.silence(target.duration) | |
target.bars.each do |bar| | |
amen = amens[rand(amens.size)] | |
new_bar = amen.stretch((bar.duration / amen.duration) * 100) | |
result = result.replace(bar.start - 0.05, bar.duration, new_bar) | |
end | |
Scissor.mix([target, result], outfile, :overwrite => true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment