Class: Note

Inherits:
Object show all
Defined in:
lib/kuromusic/Track/Measure/Chord/Note.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(degree, octave, velocity, dur) ⇒ Note

Returns a new instance of Note.



18
19
20
21
22
23
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 18

def initialize(degree, octave, velocity, dur)
  @degree = degree
  @octave = octave
  @dur = dur
  @velocity = velocity
end

Instance Attribute Details

#durObject (readonly)

Returns the value of attribute dur.



4
5
6
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 4

def dur
  @dur
end

#noteObject (readonly)

Returns the value of attribute note.



4
5
6
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 4

def note
  @note
end

#octaveObject (readonly)

Returns the value of attribute octave.



4
5
6
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 4

def octave
  @octave
end

#velocityObject (readonly)

Returns the value of attribute velocity.



4
5
6
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 4

def velocity
  @velocity
end

Instance Method Details

#get_off_event(key) ⇒ Object



30
31
32
33
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 30

def get_off_event(key)
  gdeg, goct = get_gdeg_and_goct(key)
  Event::Note::off(Key::degree_to_key(gdeg), goct)
end

#get_on_event(key) ⇒ Object



25
26
27
28
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 25

def get_on_event(key)
  gdeg, goct = get_gdeg_and_goct(key)
  Event::Note::on(Key::degree_to_key(gdeg), goct, @velocity)
end

#inspect(key = nil) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/kuromusic/Track/Measure/Chord/Note.rb', line 35

def inspect(key = nil)
  if key.nil?
    "<:degree=>" + @degree.to_s + ", :octave=>" + @octave.to_s + ", :velocity:=>" + @velocity.to_s + ", :duration=>" + @dur.to_s + ">"
  else
    gdeg, goct = get_gdeg_and_goct(key)
    "<:note=>" + Key::degree_to_key(gdeg) + ", :octave=>" + goct.to_s + ", :velocity:=>" + @velocity.to_s + ", :duration=>" + @dur.to_s + ">"
  end
end