Class: Zgomot::Comp::NoteList

Inherits:
Object
  • Object
show all
Defined in:
lib/zgomot/comp/note_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*notes) ⇒ NoteList

Returns a new instance of NoteList.



11
12
13
14
15
16
# File 'lib/zgomot/comp/note_list.rb', line 11

def initialize(*notes)
  unless notes.all?{|n| n.class == Zgomot::Midi::Note or n.class == Zgomot::Comp::Perc}
    raise(Zgomot::Error, "all arguments must be class Zgomot::Midi::Note Zgomot::Comp::Perc")
  end
  @notes = notes
end

Instance Attribute Details

#clockObject (readonly)

Returns the value of attribute clock.



9
10
11
# File 'lib/zgomot/comp/note_list.rb', line 9

def clock
  @clock
end

#notesObject (readonly)

Returns the value of attribute notes.



9
10
11
# File 'lib/zgomot/comp/note_list.rb', line 9

def notes
  @notes
end

Class Method Details

.nl(*args) ⇒ Object



5
6
7
# File 'lib/zgomot/comp/note_list.rb', line 5

def self.nl(*args)
  NoteList.new(*args)
end

Instance Method Details

#<<(note) ⇒ Object



17
18
19
# File 'lib/zgomot/comp/note_list.rb', line 17

def <<(note)
  notes << note
end

#bpm!(bpm) ⇒ Object



38
39
40
# File 'lib/zgomot/comp/note_list.rb', line 38

def bpm!(bpm)
  notes.each{|n| n.bpm!(bpm)}; self
end

#channel=(chan) ⇒ Object



26
27
28
# File 'lib/zgomot/comp/note_list.rb', line 26

def channel=(chan)
  notes.each{|n| n.channel = chan}
end

#length!(v) ⇒ Object



35
36
37
# File 'lib/zgomot/comp/note_list.rb', line 35

def length!(v)
  notes.each{|n| n.length!(v)}; self
end

#length_to_secObject



20
21
22
# File 'lib/zgomot/comp/note_list.rb', line 20

def length_to_sec
  notes.map(&:length_to_sec).max
end

#octave!(oct) ⇒ Object



41
42
43
# File 'lib/zgomot/comp/note_list.rb', line 41

def octave!(oct)
  notes.each{|n| n.octave!(oct)}; self
end

#offset=(time) ⇒ Object



29
30
31
# File 'lib/zgomot/comp/note_list.rb', line 29

def offset=(time)
  notes.each{|n| n.offset = time}
end

#popObject



50
51
52
# File 'lib/zgomot/comp/note_list.rb', line 50

def pop
  @notes.pop
end

#push(n) ⇒ Object



53
54
55
# File 'lib/zgomot/comp/note_list.rb', line 53

def push(n)
  @notes.push(n); self
end

#reverse!Object



56
57
58
# File 'lib/zgomot/comp/note_list.rb', line 56

def reverse!
  @notes.reverse!; self
end

#shiftObject



44
45
46
# File 'lib/zgomot/comp/note_list.rb', line 44

def shift
  @notes.shift
end

#time=(time) ⇒ Object



59
60
61
62
63
# File 'lib/zgomot/comp/note_list.rb', line 59

def time=(time)
  @clock = Zgomot::Midi::Clock.new
  clock.update(time)
  notes.each{|n| n.time = clock.current_time}
end

#to_midiObject



23
24
25
# File 'lib/zgomot/comp/note_list.rb', line 23

def to_midi
  notes.map{|n| n.to_midi}
end

#unshift(n) ⇒ Object



47
48
49
# File 'lib/zgomot/comp/note_list.rb', line 47

def unshift(n)
  @notes.unshift(n); self
end

#velocity!(v) ⇒ Object



32
33
34
# File 'lib/zgomot/comp/note_list.rb', line 32

def velocity!(v)
  notes.each{|n| n.velocity!(v)}; self
end