Skip to content

Instantly share code, notes, and snippets.

@youpy
Created June 5, 2012 23:36
Show Gist options
  • Save youpy/2878816 to your computer and use it in GitHub Desktop.
Save youpy/2878816 to your computer and use it in GitHub Desktop.
require 'scissor'
def main
max = 16
max.times.inject([[random_sequence], Scissor()]) do |memo, i|
# workaround to avoid ecasound bug which occurs when the number of tracks is 3 or 10 (or more)
tracks = memo[0] + (max - (memo[0].size - 1)).times.map { Scissor.silence(1) }
memo[1] += (mix(tracks, 'tracks_%i.wav' % i) * 8)
memo[0] += [random_sequence]
memo
end[1] >> 'result_%i.wav' % Time.now.to_i
end
def mix(tracks, filename)
Scissor.mix(tracks, filename, :overwrite => true)
end
def random_tape
# http://beatsdrummachine.com/hammerhead_drum_sounds.zip
Scissor(Dir[File.expand_path('~/Downloads/hammerhead_drum_sounds/*.wav')].sample)
end
def random_sequence
n = rand(100)
Scissor.sequence(16.times.map {|i| Math.sin(n * i) > 0.7 ? 'x' : ' '}.join(''), 60.0 / 105 / 6).apply(:x => random_tape)
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment