Skip to content

Commit

Permalink
Improve Harmonize performance
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmacphersonmusic committed May 15, 2015
1 parent 0015c5c commit 51c5792
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/music_theory/harmonize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ class Harmonize
attr_accessor :samples

def initialize(*things_to_flatten)
@samples = []
max_sample_array_length = things_to_flatten.map(&:length).max
@samples = Array.new(max_sample_array_length, 0)

things_to_flatten.each do |group|
group.each_with_index do |value, i|
@samples[i] ||= 0
@samples[i] += value
@samples[i] += value
end
end

Expand Down

0 comments on commit 51c5792

Please sign in to comment.