Class: Archaeopteryx::Bassline

Inherits:
Object
  • Object
show all
Defined in:
lib/bassline.rb

Instance Method Summary (collapse)

Constructor Details

- (Bassline) initialize(attributes)

Returns a new instance of Bassline



3
4
5
6
7
# File 'lib/bassline.rb', line 3

def initialize(attributes)
  @mutation = attributes[:mutation]
  @drumfile = attributes[:drumfile]
  reload
end

Instance Method Details

- (Object) mutate(measure)



11
12
13
14
15
16
# File 'lib/bassline.rb', line 11

def mutate(measure)
  if @mutation[measure]
    reload # reloading can kill mutations!
    @drums.each {|drum| drum.mutate}
  end
end

- (Object) notes(beat)



17
18
19
20
21
22
23
24
# File 'lib/bassline.rb', line 17

def notes(beat)
  @drums.each do |drum|
    if drum.play? beat
      return drum.note
    end
  end
  [] # I can't tell if this is a bug or a feature. lispy listiness requires return empty list.
end

- (Object) reload



8
9
10
# File 'lib/bassline.rb', line 8

def reload
  @drums = eval(File.read(@drumfile))
end