Skip to content

Commit

Permalink
Revise merging and comparing algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
kn1kn1 committed Aug 8, 2017
1 parent fff76b3 commit e0298c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions petal_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def ==(other)
return false if other.nil?
return false unless other.is_a?(Sound)
@name == other.name && @index == other.index &&
@divisor == other.divisor && @amp == other.amp &&
@pan == other.pan && @rate == other.rate
@divisor.to_f == other.divisor.to_f && @amp.to_f == other.amp.to_f &&
@pan.to_f == other.pan.to_f && @rate.to_f == other.rate.to_f
end

REST = Sound.new('~', 0, 1)
Expand All @@ -68,7 +68,7 @@ def initialize(value, divisor)
def ==(other)
return false if other.nil?
return false unless other.is_a?(Option)
@value == other.value && @divisor == other.divisor
@value == other.value && @divisor.to_f == other.divisor.to_f
end

REST = Option.new('~', 1)
Expand Down
4 changes: 2 additions & 2 deletions petal_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def dfs_merge_with_pan_array(sound_array, pan_array)
def dfs_merge_with_speed_array(sound_array, speed_array)
dfs_each_with_index_map(sound_array) do |sound, index_array|
speed = find_element(index_array, speed_array)
sound.rate = speed.value unless speed == Option::REST
sound.rate = sound.rate.to_f * speed.value.to_f unless speed == Option::REST
sound
end
end
Expand Down Expand Up @@ -113,7 +113,7 @@ def dfs_merge_speed_array_with_sound_array(speed_array, sound_array)
else
s = find_element(index_array, sound_array)
sound = Sound.new(s.name, s.index, speed.divisor)
sound.rate = speed.value
sound.rate = sound.rate.to_f * speed.value.to_f
end
sound
end
Expand Down

0 comments on commit e0298c5

Please sign in to comment.