class PocketMiku::Score
Attributes
default[R]
Public Class Methods
new()
click to toggle source
# File lib/pocket_miku/score.rb, line 8 def initialize @default = PocketMiku::Note.new(sound: 0, key: 60, velocity: 100, pitchbend: 0, length: QuarterNote) @playlist = [] @tempo = 120 if block_given? record(&Proc.new) end end
Public Instance Methods
add(note)
click to toggle source
PocketMiku::Note
を末尾に追加する
Args¶ ↑
- note
Return¶ ↑
self
# File lib/pocket_miku/score.rb, line 54 def add(note) @playlist << note self end
each()
click to toggle source
# File lib/pocket_miku/score.rb, line 27 def each @playlist.each(&Proc.new) end
generate_note(sound, options=nil)
click to toggle source
Note
を作成して、再生キューの末尾に追加する
Args¶ ↑
- sound
-
Symbol|Integer 発音する文字テーブルの文字(Symbol)か番号(Integer)
- options
-
以下のいずれか
- Integer :: 音の高さ(key) - Hash :: PocketMiku::Noteの第一引数
設定されたなかった Note
のオプションは、 default の値が使われる
Return¶ ↑
self
# File lib/pocket_miku/score.rb, line 68 def generate_note(sound, options=nil) add case options when NilClass PocketMiku::Note.new default.to_h.merge sound: sound when Integer PocketMiku::Note.new default.to_h.merge sound: sound, key: options when Hash, -> _ {_.respond_to? :to_h} PocketMiku::Note.new default.to_h.merge(options).merge sound: sound else raise ArgumentError, "options must nil, Integer, or Hash. but given `#{options.class}'" end end
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/pocket_miku/score.rb, line 85 def method_missing(method, *args) case method when -> _ {CharTable.include? _} generate_note method, *args else super end end
tempo(new=nil)
click to toggle source
to_a()
click to toggle source
# File lib/pocket_miku/score.rb, line 23 def to_a @playlist.dup end
っ(length)
click to toggle source
# File lib/pocket_miku/score.rb, line 81 def っ(length) add PocketMiku::RestNote.new(length) end