Class: Feepogram
Overview
downloaded from github.com/aanand/feepogram
Instance Attribute Summary (collapse)
-
- (Object) bloops
readonly
Returns the value of attribute bloops.
-
- (Object) length
readonly
Returns the value of attribute length.
Instance Method Summary (collapse)
- - (Object) dub(sound_name, notes)
-
- (Feepogram) initialize(bloops, &block)
constructor
A new instance of Feepogram.
- - (Object) metaclass
- - (Object) metaclass_eval(&block)
- - (Object) phrase(&block)
- - (Object) play
- - (Object) sound(name, base, &block)
Constructor Details
- (Feepogram) initialize(bloops, &block)
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
- (Object) bloops (readonly)
Returns the value of attribute bloops
3 4 5 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 3 def bloops @bloops end |
- (Object) length (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
- (Object) dub(sound_name, notes)
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 |
- (Object) metaclass
16 17 18 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 16 def class << self; self; end end |
- (Object) metaclass_eval(&block)
20 21 22 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 20 def (&block) .class_eval(&block) end |
- (Object) phrase(&block)
44 45 46 47 |
# File 'lib/ext/bloops/songs/feepogram.rb', line 44 def phrase(&block) instance_eval(&block) @length += 32 end |
- (Object) play
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 |
- (Object) sound(name, base, &block)
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 |