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.
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
# File 'lib/midinous/points.rb', line 1022 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.
1021 1022 1023 |
# File 'lib/midinous/points.rb', line 1021 def last_played_note @last_played_note end |
#remove ⇒ Object (readonly)
Returns the value of attribute remove.
1021 1022 1023 |
# File 'lib/midinous/points.rb', line 1021 def remove @remove end |
Instance Method Details
#play_check(portal_srce_rel, srce_rel) ⇒ Object
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'lib/midinous/points.rb', line 1051 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
1063 1064 1065 1066 1067 |
# File 'lib/midinous/points.rb', line 1063 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,@srce.mute) unless queued_notes.find {|f| @played_note == f[0] && @srce.channel == f[1]} end |
#play_relative ⇒ Object
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/midinous/points.rb', line 1068 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
1041 1042 1043 1044 1045 1046 1047 1048 1049 |
# File 'lib/midinous/points.rb', line 1041 def travel @travel_c += 1 if @travel_c == @duration @srce. = false CC.queued_note_stops << NoteSender.new(@played_note,@srce.channel,0,@srce.mute) CC.repeaters << Repeater.new(@srce,@repeat,@played_note) if @repeat > 0 @remove = true end end |