Skip to content

Commit

Permalink
🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
kn1kn1 committed Sep 12, 2017
1 parent c3c2216 commit 32ae377
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion petal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

module PetalLang
module Petal
extend self
include PetalLang::LoopHolder

@@seconds_per_cycle = 1.0
Expand Down
6 changes: 3 additions & 3 deletions petal_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(bpm, sound_array, stretch = nil, random_n = nil, random_gain = ni

def ==(other)
return false if other.nil?
return false unless other.is_a?(Cycle)
return false unless other.instance_of?(Cycle)
@bpm == other.bpm && @sound_array == other.sound_array &&
@stretch == other.stretch && @random_n == other.random_n &&
@random_gain == other.random_gain && @random_pan == other.random_pan &&
Expand All @@ -52,7 +52,7 @@ def initialize(sample_name, index, divisor)

def ==(other)
return false if other.nil?
return false unless other.is_a?(Sound)
return false unless other.instance_of?(Sound)
@name == other.name && @index == other.index &&
@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
Expand All @@ -72,7 +72,7 @@ def initialize(value, divisor)

def ==(other)
return false if other.nil?
return false unless other.is_a?(Option)
return false unless other.instance_of?(Option)
@value == other.value && @divisor.to_f == other.divisor.to_f
end

Expand Down
16 changes: 8 additions & 8 deletions petal_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ def find_element(index_array, target_array)
def dfs_merge_with_n_array(sound_array, n_array)
dfs_each_with_index_map(sound_array) do |sound, index_array|
n_element = find_element(index_array, n_array)
sound.index = n_element.value.to_i unless n_element == Option::REST
sound.index = n_element.value.to_i unless Option::REST.equal?(n_element)
sound
end
end

def dfs_merge_with_gain_array(sound_array, gain_array)
dfs_each_with_index_map(sound_array) do |sound, index_array|
gain = find_element(index_array, gain_array)
sound.amp = gain.value unless gain == Option::REST
sound.amp = gain.value unless Option::REST.equal?(gain)
sound
end
end

def dfs_merge_with_pan_array(sound_array, pan_array)
dfs_each_with_index_map(sound_array) do |sound, index_array|
pan = find_element(index_array, pan_array)
sound.pan = pan.value unless pan == Option::REST
sound.pan = pan.value unless Option::REST.equal?(pan)
sound
end
end

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 = sound.rate.to_f * speed.value.to_f unless speed == Option::REST
sound.rate = sound.rate.to_f * speed.value.to_f unless Option::REST.equal?(speed)
sound
end
end

def dfs_merge_n_array_with_sound_array(n_array, sound_array)
dfs_each_with_index_map(n_array) do |n_element, index_array|
if n_element == Option::REST
if Option::REST.equal?(n_element)
sound = Sound::REST
else
s = find_element(index_array, sound_array)
Expand All @@ -83,7 +83,7 @@ def dfs_merge_n_array_with_sound_array(n_array, sound_array)

def dfs_merge_gain_array_with_sound_array(gain_array, sound_array)
dfs_each_with_index_map(gain_array) do |gain, index_array|
if gain == Option::REST
if Option::REST.equal?(gain)
sound = Sound::REST
else
s = find_element(index_array, sound_array)
Expand All @@ -96,7 +96,7 @@ def dfs_merge_gain_array_with_sound_array(gain_array, sound_array)

def dfs_merge_pan_array_with_sound_array(pan_array, sound_array)
dfs_each_with_index_map(pan_array) do |pan, index_array|
if pan == Option::REST
if Option::REST.equal?(pan)
sound = Sound::REST
else
s = find_element(index_array, sound_array)
Expand All @@ -109,7 +109,7 @@ def dfs_merge_pan_array_with_sound_array(pan_array, sound_array)

def dfs_merge_speed_array_with_sound_array(speed_array, sound_array)
dfs_each_with_index_map(speed_array) do |speed, index_array|
if speed == Option::REST
if Option::REST.equal?(speed)
sound = Sound::REST
else
s = find_element(index_array, sound_array)
Expand Down

0 comments on commit 32ae377

Please sign in to comment.