class MelodyObject
Attributes
children[RW]
childrenlist[RW]
chn[RW]
currentchild[RW]
flag[RW]
gotimeobject[RW]
leng[RW]
name[RW]
nayme[RW]
offset[RW]
parent[RW]
place[RW]
seeder[RW]
situation[RW]
space[RW]
started[RW]
status[RW]
type[RW]
val[RW]
Public Class Methods
new(seder=0)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 577 def initialize(seder=0) @children=[] @childrenlist=[] @name=self.class.to_s @currentchild=0 @situation=:free @status=:notdone @started=false @space=1 @offset=0 localinit(seder) end
Public Instance Methods
alter_pitch(rsltamt)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 279 def alter_pitch(rsltamt) if self.class==Ender @val+=rsltamt puts @val else unless @children==nil or @children.empty? @children.each do |cd| cd.alter_pitch(rsltamt) end end end end
alter_versions_all(alter_pitch,alter_pitch_paramobj,amt)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 262 def alter_versions_all(alter_pitch,alter_pitch_paramobj,amt) b=Object.const_get(alter_pitch_paramobj) x=b.new(amt) @flag.childrenaelist.each do |currentchildren| unless currentchildren==@children qq=x.rslt puts qq currentchildren.each do |currentchildrencurrentchild| puts 'starting' currentchildrencurrentchild.send(alter_pitch,qq) puts 'ending' end end end end
alteri()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 503 def alteri p 'alteri' #something that alters based on note. #first, collect all notes.. then assign an amount to alter each, and apply throughout. a=self.bottomlevel a.each{|d| puts d} maphash={} a.each{|b| maphash[b]=rand(8)+b} p maphash self.bottomlevel!.alterindx(maphash) return self end
anewchildren()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 292 def anewchildren rslt=Section.new @children.each_with_index do |kid,i| # p "b4 #{kid.val} val #{kid.status}" if kid.class==Ender then rslt.addon kid.clone else rslt.addon kid.uf end kid.parent=self # p kid.parent.name # kid.name=i.to_s # p "ftr #{rslt[i].val} val #{rslt[i].status}" end return rslt end
backout()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 631 def backout if parent.nil? return else if self==@parent.children[parent.children.length-1] @status=:done @parent.status=:done @parent.backout else @status=:done @parent.currentchild+=1 @parent.go_down end end end
bottomlevel()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 448 def bottomlevel # p 'bottomlevel' bl=[] self.innerbottomlevel(bl) # puts 'now bl' return bl end
bottomlevel!()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 474 def bottomlevel! # p 'bottomlevel!' bl=[] self.innerbottomlevel!(bl) return bl end
cc()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 1046 def cc @children[@currentchild] end
checkwhere()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 652 def checkwhere # puts "checking where, self is #{self.class} val is #{self.val} status is #{self.status}" if self.class==Threadset then @place=:both elsif self.class==Section then @place=:both else starting=starting? ending=ending? #~ puts "starting:#{starting} ending:#{ending}" case when (starting==true and ending==false) #~ puts 'y1' @place=:starting when (starting==true and ending==true) #~ puts 'y2' @place=:both when (starting==false and ending==true) #~ puts 'y3' @place=:ending when (starting==false and ending==false) #~ puts 'y4' @place=:middle end end end
ending?()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 693 def ending? #~ puts "class:#{self.class} kid ofst:#{@children[@currentchild].offset} kid spc:#{@children[@currentchild].space} ticker:#{Midistack.ticker}" #~ puts "HIII #{@offset} #{@space-1}" if Midistack.ticker==@offset+@space-1 then true else false end end
fynd(addy)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 399 def fynd(addy) innerfynd(addy) return $ss end
fynd!(addy)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 373 def fynd!(addy) innerfynd!(addy) return $ss end
go_down()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 605 def go_down # $namarr.push @name if children[0]==nil or children[0].class==Ender #@name.length==$watchlevel ## #~ $fyl.puts " in go_down, #{self.name}'s status is #{statusempties}" #if first time going down, set the gotime objects start position case statusempties when {Section=> :childrennotempty} @children[@currentchild].go_down when {Section=> :childrenempty} @status=:done backout when {Threadset=>:childrenempty} @status=:wait when {Threadset=>:childrennotempty} # puts 'uo' @children.each {|i| i.go_down} end end
go_up(data)
click to toggle source
~ def starting? ~ if @currentchild==0 and not @children.started then ~ @children.started=true ~ @children.offset=Midistack.ticker ~ puts 'starting- first' ~ return true ~ end ~ if @children.started then ~ if @children.offset==Midistack.ticker ~ puts 'starting' ~ return true ~ else ~ return false ~ end ~ else ~ @children.started=true ~ puts 'starting' ~ @children.offset=Midistack.ticker ~ true ~ end ~ end
# File lib/melody_object/Mo_h_hc.rb, line 735 def go_up(data) #~ $fyl.puts " in checkchildstatus, #{self.name}'s status is #{@status} and his childtypestatus is #{childtypestatus}" #~ puts data.val #~ puts "at top" if @parent.nil? cc.checkwhere ##################### # puts "#{childtypestatus} #{@children[@currentchild].val}" if @children[@currentchild].class==Ender and @children[@currentchild].val!=0 # if @children[@currentchild].val!=0 then # case # when @children[@currentchild].val!=nil then # @children.each{|k| puts "lower #{k.val} #{k.status}" unless k.val==0} # puts "currchildren #{@flag.currentchildren}" unless @flag==nil # when @children[@currentchild].children[0].val!=nil then # @children[@currentchild].children.each{|k| puts "hier #{k.val} #{k.status}" unless k.val==0} # end #end unless @parent.nil? if @parent.name=='1' # puts "#{@name} #{childtypestatus}" else # puts @parent.name end end case childtypestatus when {:lastchild=>:done} #~ $fyl.puts " in checkchildstatus, #{self.name}'s status changing to :done" case cc.place when :starting @status=:notdone when :both @status=:done @currentchild=0 # p "WOW" @children.each {|c| c.status=:notdone c.started=false } # if @flag==nil then puts 'nil' else puts (@flag.currentchildren+1) end # if @flag==nil then puts 'nil' else puts (@flag.versions+1) end # if @flag==nil then puts 'nil' else puts "HI #{(@flag.currentchildren+1) % (@flag.versions+1)}" end @flag.currentchildren=(@flag.currentchildren+1) % (@flag.versions+1) unless @flag==nil #0 unless @flag==nil# @children=@flag.childrenaelist[@flag.currentchildren] unless @flag==nil #0] unless @flag==nil # @children.each {|c| c.status=:notdone c.started=false } # @children.each {|i| # puts "both #{i.val} #{i.status}"} unless @flag==nil # puts "currchildren #{@flag.currentchildren}" unless @flag==nil # puts " YOOOOOOOO #{@flag.currentchildren}" unless @flag==nil # unless @flag==nil # @flag.childrenaelist[@flag.currentchildren].each {|s| puts s.status; puts s.val} # end when :ending @status=:done @currentchild=0 # p "WOW" #maybe i just need to add a clause here which says: change @children (if there's a flag on this object) #could it be that fucking easy? #and then on the front end, create #@childrenlist full of versions of @children #and @flag which will contain the index of what children is current # # # @children.each {|c| c.status=:notdone c.started=false } data=Bouncer.new # if @flag==nil then puts 'nil' else puts (@flag.currentchildren+1) end # if @flag==nil then puts 'nil' else puts (@flag.versions+1) end # if @flag==nil then puts 'nil' else puts "HI #{(@flag.currentchildren+1) % (@flag.versions+1)}" end @flag.currentchildren=(@flag.currentchildren+1) % (@flag.versions+1) unless @flag==nil # unless @flag==nil# = # puts " YOOOOOOOO #{@flag.currentchildren}" unless @flag==nil @children=@flag.childrenaelist[@flag.currentchildren] unless @flag==nil #0] unless @flag==nil # @children.each {|c| c.status=:notdone c.started=false } # @children.each {|i| # puts "ending #{i.val} #{i.status}"} unless @flag==nil # puts "currchildren #{@flag.currentchildren}" unless @flag==nil # unless @flag==nil # @flag.childrenaelist[@flag.currentchildren].each {|s| puts s.status; puts s.val} # end when :middle @status=:wait end pass(data) when {:lastchild=>:notdone} #~ nochange #puts " in checkchildstatus, #{self.name}'s status changing to :notdone" case cc.place when :starting @status=:notdone when :both @status=:notdone when :ending @status=:notdone data=Bouncer.new when :middle @status=:wait end pass(data) when {:notlastchild=>:done} #youre moving on to the next child though you wait #~ nochange #~ $fyl.puts " in checkchildstatus, it says it's gotime, so #{self.name}'s status changing to :notdone" #~ puts 'nlc-d' case cc.place when :starting @status=:notdone when :both @currentchild+=1 @status=:notdone when :ending @currentchild+=1 @status=:notdone data=Bouncer.new when :middle @status=:wait end pass(data) when {:notlastchild=>:notdone} case cc.place when :starting @status=:notdone when :both @status=:notdone when :ending @status=:notdone data=Bouncer.new when :middle @status=:wait end pass(data) when {:notlastchild=>:wait},{:lastchild=>:wait} #nochange #nochange #~ $fyl.puts " in checkchildstatus, #{self.name}'s status changing to :wait" @status=:wait pass(data) when :notallchildrencollected @childhash[@children[@currentchild]]=data #this assumes no sub-threads. if there are any then they blow it up @currentchild+=1 #nochange #stopdata when :allchildrencollected @childhash[@children[@currentchild]]=data @children.each {|i| setsituations(i)} @currentchild=0 passchildrensdata end end
gotime()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 593 def gotime @gotimeobject.status end
halved()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 519 def halved if @children.length==2 then @children.delete_at(1) else @children.each do |d| d.halved end end end
innerbottomlevel(bl)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 456 def innerbottomlevel(bl) # p 'innerbottomlevel' unless @children.empty? @children.each do |d| if d.class==Ender bl.push(d.val) unless 0==d.val else d.innerbottomlevel(bl) end end else if self.class==Ender then bl.push(@val) end end end
innerbottomlevel!(bl)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 481 def innerbottomlevel!(bl) # p 'innerbottomlevel!' unless @children.empty? @children.each do |d| if d.class==Ender bl.push(d) else d.innerbottomlevel!(bl) end end else if self.class==Ender then bl.push(self) end end end
innerfynd(addy)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 407 def innerfynd(addy) unless @children.empty? @children.each do |d| if d.name==addy $ss=d else d.innerfynd(addy) end end else # p 'j' end end
innerfynd!(addy)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 381 def innerfynd!(addy) #puts "#{self.class.to_s} #{@name}" if @name.to_s.length<6 and self.class!=Ender unless @children.empty? @children.each do |d| if d.name==addy $ss=d.uf $ss.parent=nil else d.innerfynd!(addy) end end else # p 'j' end end
klean()
click to toggle source
def anewchildren
rslt=[] @children.each_with_index do |kid,i|
# p “b4 #{kid.val} val #{kid.status}”
if kid.class==Ender then rslt.push kid.clone else rslt.push kid.uf end kid.parent=self p kid.parent.name kid.name=i.to_s # p "ftr #{rslt[i].val} val #{rslt[i].status}" end return rslt
end
end¶ ↑
# File lib/melody_object/Mo_h_hc.rb, line 336 def klean unless @children==nil if @children.length==1 and @children[0].class!=Ender and @parent!=nil #tmp=@children[0] @children[0].parent=@parent @parent.children[parent.children.index(self)]=@children[0] #children.each {|chile| chile.parent=self} end @children.each {|chyle| chyle.klean} end end
lastchild()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 1042 def lastchild @currentchild==@children.length-1 end
localinit(x)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 590 def localinit(x) end
midifeed(bouncer)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 1028 def midifeed(bouncer) if bouncer.val.class==Hash bouncer.val.each_value {|e| midifeed(e)} else #~ $fyl.puts " so feeding a bouncer w #{bouncer.val}" Midistack.feed(bouncer) end end
pass(data)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 1012 def pass(data) #~ puts "#{@name} sez #{@status}, #{gotime}" if @parent.nil? #~ puts "at top, val=#{if data.val.class==Hash then data.val.each_value {|d| d} else data.val end}" unless @status==:wait #~ puts "sez not waiting, val= #{val}" midifeed(data) Midistack.done=true if @status==:done end else #~ puts "#{@name} sez going to parent" @parent.go_up(data) end end
passchildrensdata()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 972 def passchildrensdata #~ $fyl.puts " so how many children does #{self.name} think it has?: #{@children.length}" data=Bouncer.new data.val=Hash.new @children.each do |i| #~ $fyl.puts " in passchildrensdata, (child) #{i.name}'s status is #{statussituation(i)}" case statussituation(i) when {:wait=>:master},{:wait=>:slave},{:wait=>:free} #nochange #nochange #stopdata when {:notdone=>:free},{:notdone=>:slave},{:notdone=>:master} #nochange #nochange data.val[i]=@childhash[i] when {:done=>:master} #~ puts "#{i.name} is done bitch" #nochange @status=:done data.val[i]=@childhash[i] #~ @tripped=false #~ @gotimeobject.curraryval=0 when {:done=>:slave} i.currentchild=0 i.status=:notdone #nochange to self data.val[i]=@childhash[i] end end pass(data) #unless data.val.empty? end
repl(replacer)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 366 def repl(replacer) self.parent.children[parent.children.index(self)]=replacer # unless self.parent==nil replacer.parent=self.parent # unless self.parent==nil return replacer end
runn()
click to toggle source
def prg_chg(track,program)
# File lib/melody_object/Mo_h_hc.rb, line 545 def runn g=@beat #webster=Array.new(6) { (rand(122-97) + 97).chr }.join $midi = Midi_interface.new stop=false trap('INT') {stop=true} until Midistack.done or stop==true x=Time.now.to_f go_down h=x+g #-0.001 GC.start while Time.now.to_f<h sleep 0.0001 end Midistack.play #~ x+=1 end Midistack.stack.each do |d| $midi.note_off(d.val,d.chn,100) d.del=true end GC.start end
setsituations(child)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 924 def setsituations(child) if child.status==:done if children.length==1 child.situation=:master else if child.situation==:free someone_else_is_a_slave=false @children.each {|d| unless d==child if d.situation==:slave someone_else_is_a_slave=true #someone else is a slave! you're either a slave or #a master! end end } if not someone_else_is_a_slave #no one else is a slave- you're a slave! child.situation=:slave else #someone else is a slave- are you a slave or maybe the master? youre the master if #everyone else is a slave everyone_else_a_slave=true #assume everyone is until someone says theyre not @children.each {|d| unless d==child if d.situation!=:slave everyone_else_a_slave=false #not everyone else is a slave, so youre a slave end end } if everyone_else_a_slave child.situation=:master else child.situation=:slave end end end end end end
starting?()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 679 def starting? if @started if Midistack.ticker==@offset true else false end else @offset=Midistack.ticker @started=true true end end
statusempties()
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 601 def statusempties {self.class=>if @children.empty? then :childrenempty else :childrennotempty end} end
statussituation(child)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 597 def statussituation(child) {child.status=>child.situation} end
threadout(*arr)
click to toggle source
# File lib/melody_object/Mo_h_hc.rb, line 348 def threadout(*arr) arr.push self.uf newsec=t(*arr) if self.parent==nil s=Section.new s.addon(newsec) return s else self.parent.children[parent.children.index(self)]=newsec newsec.parent=self.parent # p "a "+newsec.name # p "a "+newsec.parent.name return newsec end end
versionize(versions)
click to toggle source
def versionize(versions) @flag=FlagObject.new(versions) @flag.childrenaelist=[] @flag.childrenaeattriblist=[] @flag.childrenaelist=@children 1.upto(versions) do |v|
tmpchildren=anewchildren @flag.childrenaelist[v]=tmpchildren @flag.childrenaeattriblist[v]=Hash.new
end @children=@flag.childrenaelist end
# File lib/melody_object/Mo_h_hc.rb, line 250 def versionize(versions) s=Section.new end