Skip to content

Instantly share code, notes, and snippets.

@youpy
Created October 31, 2011 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youpy/1328495 to your computer and use it in GitHub Desktop.
Save youpy/1328495 to your computer and use it in GitHub Desktop.
amenizer
%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