Skip to content

Instantly share code, notes, and snippets.

@youpy
Created December 1, 2011 08:06
Show Gist options
  • Save youpy/1414847 to your computer and use it in GitHub Desktop.
Save youpy/1414847 to your computer and use it in GitHub Desktop.
909 乗っけるやつ
%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
bd = Scissor('http://dl.dropbox.com/u/334064/909BD.wav')
target = Scissor(infile)
result = Scissor.silence(target.duration)
target.beats.each do |beat|
x = nil
if bd.duration > beat.duration
x = bd + Scissor.silence(beat.duration - bd.duration)
else
x = bd[0, beat.duration]
end
result = result.replace(beat.start, beat.duration, x)
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