Class: PocketMiku::Note

Inherits:
Base
  • Object
show all
Defined in:
lib/pocket_miku/note.rb

Direct Known Subclasses

RestNote

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Note

Args

options
  • sound

    発音する文字テーブルコード

  • key

    音程 (0-127)

  • velocity

    強さ (0-127)

  • pitchvend

    ピッチベンド

  • length

    音の長さ(相対)



14
15
16
17
18
19
20
# File 'lib/pocket_miku/note.rb', line 14

def initialize(options={})
  self.sound = options[:sound]
  self.key = options[:key]
  self.velocity = options[:velocity]
  self.pitchbend = options[:pitchbend]
  self.length = options[:length]
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



5
6
7
# File 'lib/pocket_miku/note.rb', line 5

def key
  @key
end

#lengthObject

Returns the value of attribute length.



5
6
7
# File 'lib/pocket_miku/note.rb', line 5

def length
  @length
end

#pitchbendObject

Returns the value of attribute pitchbend.



5
6
7
# File 'lib/pocket_miku/note.rb', line 5

def pitchbend
  @pitchbend
end

#soundObject

Returns the value of attribute sound.



5
6
7
# File 'lib/pocket_miku/note.rb', line 5

def sound
  @sound
end

#velocityObject

Returns the value of attribute velocity.



5
6
7
# File 'lib/pocket_miku/note.rb', line 5

def velocity
  @velocity
end

Instance Method Details

#to_aObject



26
27
28
29
# File 'lib/pocket_miku/note.rb', line 26

def to_a
  [0xF0, 0x43, 0x79, 0x09, 0x11, 0x0A, 0, sound, 0xF7,
   0x90, key, velocity]
end

#to_hObject



31
32
33
34
35
36
37
# File 'lib/pocket_miku/note.rb', line 31

def to_h
  { sound: sound,
    key: key,
    velocity: velocity,
    pitchbend: pitchbend,
    length: length }
end

#to_sObject



22
23
24
# File 'lib/pocket_miku/note.rb', line 22

def to_s
  PocketMiku::PacketFactory.pack(to_a)
end