Class: Archaeopteryx::Arkx

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

Instance Method Summary (collapse)

Constructor Details

- (Arkx) initialize(attributes)

Returns a new instance of Arkx



3
4
5
6
7
8
9
10
11
12
# File 'lib/arkx.rb', line 3

def initialize(attributes)
  @generator = attributes[:generator]
  # @measures = attributes[:measures] || 32
  @beats = attributes[:beats] || 16
  midi_destination = attributes[:midi_destination] || 0
  @evil_timer_offset_wtf = attributes[:evil_timer_offset_wtf]
  @midi = LiveMIDI.new(:clock => @clock = attributes[:clock], # confusion!!!!!!!!!!
                       :logging => attributes[:logging] || false,
                       :midi_destination => midi_destination)
end

Instance Method Details

- (Object) go



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/arkx.rb', line 16

def go
  generate_beats = L do
    (1..$measures).each do |measure|
      @generator.mutate(measure)
      (0..(@beats - 1)).each do |beat|
        play @generator.notes(beat)
        @clock.tick
      end
    end
    @midi.timer.at((@clock.start + @clock.time) - @evil_timer_offset_wtf, &generate_beats)
  end
  generate_beats[]
  if Platform::IMPL == :mswin
    puts 'Press CTRL-C to stop'
    sleep(10000)
  else
    gets
  end
end

- (Object) play(music)



13
14
15
# File 'lib/arkx.rb', line 13

def play(music)
  music.each {|note| @midi.play(note)}
end