Class: Starter
- Inherits:
-
Object
- Object
- Starter
- Defined in:
- lib/midinous/points.rb
Overview
A starter handles notes that are used as starting points for paths and point jumps for portals
Instance Attribute Summary collapse
-
#last_played_note ⇒ Object
readonly
Returns the value of attribute last_played_note.
-
#remove ⇒ Object
readonly
Returns the value of attribute remove.
Instance Method Summary collapse
-
#initialize(portal_srce, srce, lpn) ⇒ Starter
constructor
A new instance of Starter.
- #play_check(portal_srce_rel, srce_rel) ⇒ Object
- #play_note ⇒ Object
- #play_relative ⇒ Object
- #travel ⇒ Object
Constructor Details
#initialize(portal_srce, srce, lpn) ⇒ Starter
Returns a new instance of Starter.
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/midinous/points.rb', line 979 def initialize(portal_srce,srce,lpn) @travel_c = 0 @srce = srce @portal_srce = portal_srce @duration = srce.duration @remove = false @repeat = srce.repeat @played_note = nil @last_played_note = lpn @srce. = true if @portal_srce != nil play_check(@portal_srce.use_rel,@srce.use_rel) else @played_note = @srce.note play_note end end |
Instance Attribute Details
#last_played_note ⇒ Object (readonly)
Returns the value of attribute last_played_note.
978 979 980 |
# File 'lib/midinous/points.rb', line 978 def last_played_note @last_played_note end |
#remove ⇒ Object (readonly)
Returns the value of attribute remove.
978 979 980 |
# File 'lib/midinous/points.rb', line 978 def remove @remove end |
Instance Method Details
#play_check(portal_srce_rel, srce_rel) ⇒ Object
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 |
# File 'lib/midinous/points.rb', line 1008 def play_check(portal_srce_rel,srce_rel) if !srce_rel @played_note = @srce.note play_note elsif portal_srce_rel && srce_rel @played_note = @last_played_note play_relative elsif !portal_srce_rel && srce_rel @played_note = @portal_srce.note.to_i play_relative end end |
#play_note ⇒ Object
1020 1021 1022 1023 1024 |
# File 'lib/midinous/points.rb', line 1020 def play_note queued_notes = [] CC.queued_note_plays.each {|q| queued_notes << [q.note,q.chan]} CC.queued_note_plays << NoteSender.new(@played_note,@srce.channel,@srce.velocity) unless queued_notes.find {|f| @played_note == f[0] && @srce.channel == f[1]} end |
#play_relative ⇒ Object
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
# File 'lib/midinous/points.rb', line 1025 def play_relative #search the current scales variable and round to nearest note. rel = @srce.note.to_i pn = @played_note if @srce.note.to_s.include?("+") (pn..127).each do |s| rel -= 1 if CC.scale_posns[s] == true && s != pn if rel == 0 pn = s break end end elsif @srce.note.to_s.include?("-") (0..pn).reverse_each do |s| rel += 1 if CC.scale_posns[s] == true && s != pn if rel == 0 pn = s break end end end @played_note = pn play_note end |
#travel ⇒ Object
998 999 1000 1001 1002 1003 1004 1005 1006 |
# File 'lib/midinous/points.rb', line 998 def travel @travel_c += 1 if @travel_c == @duration @srce. = false CC.queued_note_stops << NoteSender.new(@played_note,@srce.channel,0) CC.repeaters << Repeater.new(@srce,@repeat,@played_note) if @repeat > 0 @remove = true end end |