Class: MelodyObject
- Inherits:
-
Object
- Object
- MelodyObject
- Defined in:
- lib/melody_object/Mo_h_hc.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#childrenlist ⇒ Object
Returns the value of attribute childrenlist.
-
#chn ⇒ Object
Returns the value of attribute chn.
-
#currentchild ⇒ Object
Returns the value of attribute currentchild.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#gotimeobject ⇒ Object
Returns the value of attribute gotimeobject.
-
#leng ⇒ Object
Returns the value of attribute leng.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nayme(naymelevel = "1") ⇒ Object
Returns the value of attribute nayme.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#place ⇒ Object
Returns the value of attribute place.
-
#seeder ⇒ Object
Returns the value of attribute seeder.
-
#situation ⇒ Object
Returns the value of attribute situation.
-
#space ⇒ Object
Returns the value of attribute space.
-
#started ⇒ Object
Returns the value of attribute started.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
Returns the value of attribute type.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
- #alter_pitch(rsltamt) ⇒ Object
- #alter_versions_all(alter_pitch, alter_pitch_paramobj, amt) ⇒ Object
- #alteri ⇒ Object
- #anewchildren ⇒ Object
- #backout ⇒ Object
- #bottomlevel ⇒ Object
- #bottomlevel! ⇒ Object
- #cc ⇒ Object
- #checkwhere ⇒ Object
- #ending? ⇒ Boolean
- #fynd(addy) ⇒ Object
- #fynd!(addy) ⇒ Object
- #go_down ⇒ Object
- #go_up(data) ⇒ Object
- #gotime ⇒ Object
- #halved ⇒ Object
-
#initialize(seder = 0) ⇒ MelodyObject
constructor
A new instance of MelodyObject.
- #innerbottomlevel(bl) ⇒ Object
- #innerbottomlevel!(bl) ⇒ Object
- #innerfynd(addy) ⇒ Object
- #innerfynd!(addy) ⇒ Object
- #klean ⇒ Object
- #lastchild ⇒ Object
- #localinit(x) ⇒ Object
- #midifeed(bouncer) ⇒ Object
- #pass(data) ⇒ Object
- #passchildrensdata ⇒ Object
- #repl(replacer) ⇒ Object
-
#runn ⇒ Object
def prg_chg(track,program).
- #setsituations(child) ⇒ Object
- #starting? ⇒ Boolean
- #statusempties ⇒ Object
- #statussituation(child) ⇒ Object
- #threadout(*arr) ⇒ Object
-
#versionize(versions) ⇒ Object
def versionize(versions) @flag=FlagObject.new(versions) @flag.childrenaelist=[] @flag.childrenaeattriblist=[] @flag.childrenaelist=@children 1.upto(versions) do |v| tmpchildren=anewchildren @flag.childrenaelist=tmpchildren @flag.childrenaeattriblist=Hash.new end @[email protected] end.
Constructor Details
#initialize(seder = 0) ⇒ MelodyObject
Returns a new instance of MelodyObject.
577 578 579 580 581 582 583 584 585 586 587 588 |
# 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 |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
217 218 219 |
# File 'lib/melody_object/Mo_h_hc.rb', line 217 def children @children end |
#childrenlist ⇒ Object
Returns the value of attribute childrenlist.
234 235 236 |
# File 'lib/melody_object/Mo_h_hc.rb', line 234 def childrenlist @childrenlist end |
#chn ⇒ Object
Returns the value of attribute chn.
227 228 229 |
# File 'lib/melody_object/Mo_h_hc.rb', line 227 def chn @chn end |
#currentchild ⇒ Object
Returns the value of attribute currentchild.
220 221 222 |
# File 'lib/melody_object/Mo_h_hc.rb', line 220 def currentchild @currentchild end |
#flag ⇒ Object
Returns the value of attribute flag.
233 234 235 |
# File 'lib/melody_object/Mo_h_hc.rb', line 233 def flag @flag end |
#gotimeobject ⇒ Object
Returns the value of attribute gotimeobject.
226 227 228 |
# File 'lib/melody_object/Mo_h_hc.rb', line 226 def gotimeobject @gotimeobject end |
#leng ⇒ Object
Returns the value of attribute leng.
228 229 230 |
# File 'lib/melody_object/Mo_h_hc.rb', line 228 def leng @leng end |
#name ⇒ Object
Returns the value of attribute name.
218 219 220 |
# File 'lib/melody_object/Mo_h_hc.rb', line 218 def name @name end |
#nayme(naymelevel = "1") ⇒ Object
Returns the value of attribute nayme.
219 220 221 |
# File 'lib/melody_object/Mo_h_hc.rb', line 219 def nayme @nayme end |
#offset ⇒ Object
Returns the value of attribute offset.
232 233 234 |
# File 'lib/melody_object/Mo_h_hc.rb', line 232 def offset @offset end |
#parent ⇒ Object
Returns the value of attribute parent.
221 222 223 |
# File 'lib/melody_object/Mo_h_hc.rb', line 221 def parent @parent end |
#place ⇒ Object
Returns the value of attribute place.
230 231 232 |
# File 'lib/melody_object/Mo_h_hc.rb', line 230 def place @place end |
#seeder ⇒ Object
Returns the value of attribute seeder.
224 225 226 |
# File 'lib/melody_object/Mo_h_hc.rb', line 224 def seeder @seeder end |
#situation ⇒ Object
Returns the value of attribute situation.
223 224 225 |
# File 'lib/melody_object/Mo_h_hc.rb', line 223 def situation @situation end |
#space ⇒ Object
Returns the value of attribute space.
229 230 231 |
# File 'lib/melody_object/Mo_h_hc.rb', line 229 def space @space end |
#started ⇒ Object
Returns the value of attribute started.
231 232 233 |
# File 'lib/melody_object/Mo_h_hc.rb', line 231 def started @started end |
#status ⇒ Object
Returns the value of attribute status.
222 223 224 |
# File 'lib/melody_object/Mo_h_hc.rb', line 222 def status @status end |
#type ⇒ Object
Returns the value of attribute type.
225 226 227 |
# File 'lib/melody_object/Mo_h_hc.rb', line 225 def type @type end |
#val ⇒ Object
Returns the value of attribute val.
216 217 218 |
# File 'lib/melody_object/Mo_h_hc.rb', line 216 def val @val end |
Instance Method Details
#alter_pitch(rsltamt) ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 |
# 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) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# 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 ⇒ Object
503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# 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 ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# 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 ⇒ Object
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# 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 ⇒ Object
448 449 450 451 452 453 454 |
# 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! ⇒ Object
474 475 476 477 478 479 |
# File 'lib/melody_object/Mo_h_hc.rb', line 474 def bottomlevel! # p 'bottomlevel!' bl=[] self.innerbottomlevel!(bl) return bl end |
#cc ⇒ Object
1046 1047 1048 1049 |
# File 'lib/melody_object/Mo_h_hc.rb', line 1046 def cc @children[@currentchild] end |
#checkwhere ⇒ Object
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# 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? ⇒ Boolean
693 694 695 696 697 698 699 700 701 |
# 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) ⇒ Object
399 400 401 402 403 |
# File 'lib/melody_object/Mo_h_hc.rb', line 399 def fynd(addy) innerfynd(addy) return $ss end |
#fynd!(addy) ⇒ Object
373 374 375 376 377 |
# File 'lib/melody_object/Mo_h_hc.rb', line 373 def fynd!(addy) innerfynd!(addy) return $ss end |
#go_down ⇒ Object
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
# 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) ⇒ Object
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
# 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 ⇒ Object
593 594 595 |
# File 'lib/melody_object/Mo_h_hc.rb', line 593 def gotime @gotimeobject.status end |
#halved ⇒ Object
519 520 521 522 523 524 525 526 527 |
# 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) ⇒ Object
456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# 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) ⇒ Object
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# 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) ⇒ Object
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# 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) ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# 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 ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 |
# 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 ⇒ Object
1042 1043 1044 |
# File 'lib/melody_object/Mo_h_hc.rb', line 1042 def lastchild @currentchild==@children.length-1 end |
#localinit(x) ⇒ Object
590 591 |
# File 'lib/melody_object/Mo_h_hc.rb', line 590 def localinit(x) end |
#midifeed(bouncer) ⇒ Object
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
# 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) ⇒ Object
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
# 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 ⇒ Object
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# 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) ⇒ Object
366 367 368 369 370 |
# 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 ⇒ Object
def prg_chg(track,program)
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# 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) ⇒ Object
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 |
# 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? ⇒ Boolean
679 680 681 682 683 684 685 686 687 688 689 690 691 |
# 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 ⇒ Object
601 602 603 |
# 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) ⇒ Object
597 598 599 |
# File 'lib/melody_object/Mo_h_hc.rb', line 597 def statussituation(child) {child.status=>child.situation} end |
#threadout(*arr) ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# 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) ⇒ Object
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 @[email protected] end
250 251 252 253 |
# File 'lib/melody_object/Mo_h_hc.rb', line 250 def versionize(versions) s=Section.new end |