Class: Midistack

Inherits:
Object
  • Object
show all
Defined in:
lib/melody_object/Mo_h_hc.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.doneObject

Returns the value of attribute done.



100
101
102
# File 'lib/melody_object/Mo_h_hc.rb', line 100

def done
  @done
end

.echostackObject (readonly)

Returns the value of attribute echostack.



99
100
101
# File 'lib/melody_object/Mo_h_hc.rb', line 99

def echostack
  @echostack
end

.stackObject (readonly)

Returns the value of attribute stack.



98
99
100
# File 'lib/melody_object/Mo_h_hc.rb', line 98

def stack
  @stack
end

.tickerObject (readonly)

Returns the value of attribute ticker.



101
102
103
# File 'lib/melody_object/Mo_h_hc.rb', line 101

def ticker
  @ticker
end

Class Method Details

.feed(bouncer) ⇒ Object



104
105
106
107
# File 'lib/melody_object/Mo_h_hc.rb', line 104

def self.feed(bouncer)
 @stack.push bouncer    unless bouncer.val.nil?

end

.harvestechostackObject



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/melody_object/Mo_h_hc.rb', line 114

def self.harvestechostack
  @echostack.each{|i|
  #~ puts "  cycling through #{i.val}"
   if i.inc==3
     #~ puts "    pushing to @stack #{i.val}"
     i.inc=0
     i.running=false
     @stack.push i unless i.val.nil?
   else
     i.inc+=1
   end}
end

.playObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/melody_object/Mo_h_hc.rb', line 127

def self.play
      #~ harvestechostack
  unless @internaldone
      @stack.each {|d| 
      d.inc+=1

              if d.turned_on==false 
                d.turned_on=true
                #~ puts d.chn
                
                gaga=(d.chn==9) ? 120 : 60
                #~ puts gaga
                $midi.note_on(d.val,d.chn,gaga)
                if d.chn==0
                  e=d.uf
                  e.inc=0
                  e.turned_on=false
                  @echostack.push e if e.running
                  #~ puts "pushing to echostack #{e.val}"
                end
                 #~ $fyl.puts "#{d.val} #{d.chn} #{@ticker}"
                   #~ puts "#{d.val} #{d.chn} #{@ticker}"
                 #~ $fyl2.puts "#{d.val} #{d.chn} #{@ticker}"
                #~ puts "#{d.val} #{d.chn} #{@ticker}"
              elsif d.inc>d.leng
                $midi.note_off(d.val,d.chn,100)
                d.del=true
              end
      }
            @stack.delete_if {|d| d.del}
  
            if @done
                @internaldone=true
                #~ sleep($g)
            @stack.each {|d| $midi.note_off(d.val,d.chn,100)} 
            end
  @ticker+=1
  #~ puts "ticker:#{@ticker}"
  else
  @internaldone=false
end
#~ $fyl.puts " "
#~ puts " "
end