Class: Feepogram
Overview
downloaded from github.com/aanand/feepogram
Instance Attribute Summary collapse
-
#bloops ⇒ Object
readonly
Returns the value of attribute bloops.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #dub(sound_name, notes) ⇒ Object
-
#initialize(bloops, &block) ⇒ Feepogram
constructor
A new instance of Feepogram.
- #metaclass ⇒ Object
- #metaclass_eval(&block) ⇒ Object
- #phrase(&block) ⇒ Object
- #play ⇒ Object
- #sound(name, base, &block) ⇒ Object
Constructor Details
#initialize(bloops, &block) ⇒ Feepogram
Returns a new instance of Feepogram.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 5 def initialize(bloops, &block) @bloops = bloops @length = 0 @sounds = {} @tracks = {} @track_lengths = {} instance_eval(&block) end |
Instance Attribute Details
#bloops ⇒ Object (readonly)
Returns the value of attribute bloops.
3 4 5 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 3 def bloops @bloops end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
3 4 5 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 3 def length @length end |
Instance Method Details
#dub(sound_name, notes) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 49 def dub sound_name, notes catchup = @length - @track_lengths[sound_name] @tracks[sound_name] << ("4 " * catchup) @tracks[sound_name] << notes @track_lengths[sound_name] = length+32 end |
#metaclass ⇒ Object
16 17 18 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 16 def class << self; self; end end |
#metaclass_eval(&block) ⇒ Object
20 21 22 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 20 def (&block) .class_eval(&block) end |
#phrase(&block) ⇒ Object
44 45 46 47 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 44 def phrase(&block) instance_eval(&block) @length += 32 end |
#play ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 57 def play @tracks.each do |sound_name, notes| bloops.tune @sounds[sound_name], notes #puts "#{sound_name}: #{notes.gsub(/\s+/, ' ')}" end bloops.play sleep 1 while !bloops.stopped? end |
#sound(name, base, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 24 def sound(name, base, &block) name = name.to_sym sound = bloops.sound(base) @sounds[name] = sound @tracks[name] = "" @track_lengths[name] = 0 block.call(sound) instance_variable_set("@#{name}", sound) do define_method(name) do |notes| dub(name, notes) end end end |