• Register
  • Help
Results 1 to 9 of 9

Topic: Updated script for K2 Self Mask

Share/Bookmark
  1. #1

    Updated script for K2 Self Mask

    This update will be in next K2 update, but I can give it to you now.
    This update fixes some things in polyphonic playing.
    This script is maybe long, but only does what is needed.

    Code:
    {*********************************************************
    Self Mask
    
    Author: Xavier Bidault
    Date: 28th april. 2005
    Version: 2.00
    Description: If one repeated note is louder than previous ones,
    these ones are masked by this last one. So they are faded out.
    This can save polyphony.
    
    **********************************************************}
    
    on init
    
    declare ui_knob $fadeout (0, 1000, 1) {fade out time of masked note, in ms}
    $fadeout:=10
    make_persistent ($fadeout)
    
    declare %ID0[128]
    declare %ID1[128]
    declare %ID2[128]
    declare %ID3[128]
    declare %ID4[128]
    declare %ID5[128]
    declare %ID6[128]
    declare %ID7[128]
    declare %ID8[128]
    declare %ID9[128]
    declare %ID10[128]
    declare %ID11[128]
    declare %ID12[128]
    declare %ID13[128]
    declare %ID14[128]
    declare %ID15[128]
    declare %ID16[128]
    declare %ID17[128]
    declare %ID18[128]
    declare %ID19[128]
    declare %ID20[128]
    declare %ID21[128]
    declare %ID22[128]
    declare %ID23[128]
    declare %ID24[128]
    declare %ID25[128]
    declare %ID26[128]
    declare %ID27[128]
    declare %ID28[128]
    declare %ID29[128]
    declare %ID30[128]
    declare %ID31[128]
    declare %ID32[128]
    declare %ID33[128]
    declare %ID34[128]
    declare %ID35[128]
    declare %ID36[128]
    declare %ID37[128]
    declare %ID38[128]
    declare %ID39[128]
    declare %ID40[128]
    declare %ID41[128]
    declare %ID42[128]
    declare %ID43[128]
    declare %ID44[128]
    declare %ID45[128]
    declare %ID46[128]
    declare %ID47[128]
    declare %ID48[128]
    declare %ID49[128]
    declare %ID50[128]
    declare %ID51[128]
    declare %ID52[128]
    declare %ID53[128]
    declare %ID54[128]
    declare %ID55[128]
    declare %ID56[128]
    declare %ID57[128]
    declare %ID58[128]
    declare %ID59[128]
    declare %ID60[128]
    declare %ID61[128]
    declare %ID62[128]
    declare %ID63[128]
    declare %ID64[128]
    declare %ID65[128]
    declare %ID66[128]
    declare %ID67[128]
    declare %ID68[128]
    declare %ID69[128]
    declare %ID70[128]
    declare %ID71[128]
    declare %ID72[128]
    declare %ID73[128]
    declare %ID74[128]
    declare %ID75[128]
    declare %ID76[128]
    declare %ID77[128]
    declare %ID78[128]
    declare %ID79[128]
    declare %ID80[128]
    declare %ID81[128]
    declare %ID82[128]
    declare %ID83[128]
    declare %ID84[128]
    declare %ID85[128]
    declare %ID86[128]
    declare %ID87[128]
    declare %ID88[128]
    declare %ID89[128]
    declare %ID90[128]
    declare %ID91[128]
    declare %ID92[128]
    declare %ID93[128]
    declare %ID94[128]
    declare %ID95[128]
    declare %ID96[128]
    declare %ID97[128]
    declare %ID98[128]
    declare %ID99[128]
    declare %ID100[128]
    declare %ID101[128]
    declare %ID102[128]
    declare %ID103[128]
    declare %ID104[128]
    declare %ID105[128]
    declare %ID106[128]
    declare %ID107[128]
    declare %ID108[128]
    declare %ID109[128]
    declare %ID110[128]
    declare %ID111[128]
    declare %ID112[128]
    declare %ID113[128]
    declare %ID114[128]
    declare %ID115[128]
    declare %ID116[128]
    declare %ID117[128]
    declare %ID118[128]
    declare %ID119[128]
    declare %ID120[128]
    declare %ID121[128]
    declare %ID122[128]
    declare %ID123[128]
    declare %ID124[128]
    declare %ID125[128]
    declare %ID126[128]
    declare %ID127[128]
    
    declare %vel0[128]
    declare %vel1[128]
    declare %vel2[128]
    declare %vel3[128]
    declare %vel4[128]
    declare %vel5[128]
    declare %vel6[128]
    declare %vel7[128]
    declare %vel8[128]
    declare %vel9[128]
    declare %vel10[128]
    declare %vel11[128]
    declare %vel12[128]
    declare %vel13[128]
    declare %vel14[128]
    declare %vel15[128]
    declare %vel16[128]
    declare %vel17[128]
    declare %vel18[128]
    declare %vel19[128]
    declare %vel20[128]
    declare %vel21[128]
    declare %vel22[128]
    declare %vel23[128]
    declare %vel24[128]
    declare %vel25[128]
    declare %vel26[128]
    declare %vel27[128]
    declare %vel28[128]
    declare %vel29[128]
    declare %vel30[128]
    declare %vel31[128]
    declare %vel32[128]
    declare %vel33[128]
    declare %vel34[128]
    declare %vel35[128]
    declare %vel36[128]
    declare %vel37[128]
    declare %vel38[128]
    declare %vel39[128]
    declare %vel40[128]
    declare %vel41[128]
    declare %vel42[128]
    declare %vel43[128]
    declare %vel44[128]
    declare %vel45[128]
    declare %vel46[128]
    declare %vel47[128]
    declare %vel48[128]
    declare %vel49[128]
    declare %vel50[128]
    declare %vel51[128]
    declare %vel52[128]
    declare %vel53[128]
    declare %vel54[128]
    declare %vel55[128]
    declare %vel56[128]
    declare %vel57[128]
    declare %vel58[128]
    declare %vel59[128]
    declare %vel60[128]
    declare %vel61[128]
    declare %vel62[128]
    declare %vel63[128]
    declare %vel64[128]
    declare %vel65[128]
    declare %vel66[128]
    declare %vel67[128]
    declare %vel68[128]
    declare %vel69[128]
    declare %vel70[128]
    declare %vel71[128]
    declare %vel72[128]
    declare %vel73[128]
    declare %vel74[128]
    declare %vel75[128]
    declare %vel76[128]
    declare %vel77[128]
    declare %vel78[128]
    declare %vel79[128]
    declare %vel80[128]
    declare %vel81[128]
    declare %vel82[128]
    declare %vel83[128]
    declare %vel84[128]
    declare %vel85[128]
    declare %vel86[128]
    declare %vel87[128]
    declare %vel88[128]
    declare %vel89[128]
    declare %vel90[128]
    declare %vel91[128]
    declare %vel92[128]
    declare %vel93[128]
    declare %vel94[128]
    declare %vel95[128]
    declare %vel96[128]
    declare %vel97[128]
    declare %vel98[128]
    declare %vel99[128]
    declare %vel100[128]
    declare %vel101[128]
    declare %vel102[128]
    declare %vel103[128]
    declare %vel104[128]
    declare %vel105[128]
    declare %vel106[128]
    declare %vel107[128]
    declare %vel108[128]
    declare %vel109[128]
    declare %vel110[128]
    declare %vel111[128]
    declare %vel112[128]
    declare %vel113[128]
    declare %vel114[128]
    declare %vel115[128]
    declare %vel116[128]
    declare %vel117[128]
    declare %vel118[128]
    declare %vel119[128]
    declare %vel120[128]
    declare %vel121[128]
    declare %vel122[128]
    declare %vel123[128]
    declare %vel124[128]
    declare %vel125[128]
    declare %vel126[128]
    declare %vel127[128]
    
    declare %n[128]
    declare %m[128]
    declare $k
    $k:=0
    while ($k<=127)
    %n[$k]:=0
    inc($k)
    end while
    
    end on
    
    on note
    
    select ($EVENT_NOTE)
    
    case 0
    	inc(%n[$EVENT_NOTE])
    	%ID0[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel0[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[0]:=%n[$EVENT_NOTE]
    	while (%m[0]>1)
    		if (%vel0[%m[0]]>%vel0[%m[0]-1])
    			fade_out(%ID0[%m[0]-1], 1000*$fadeout, 1)
    			%ID0[%m[0]-1]:=%ID0[%m[0]]
    			%vel0[%m[0]-1]:=%vel0[%m[0]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[0])
    		else
    			dec(%m[0])
    		end if
    	end while
    
    case 1
    	inc(%n[$EVENT_NOTE])
    	%ID1[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel1[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[1]:=%n[$EVENT_NOTE]
    	while (%m[1]>1)
    		if (%vel1[%m[1]]>%vel1[%m[1]-1])
    			fade_out(%ID1[%m[1]-1], 1000*$fadeout, 1)
    			%ID1[%m[1]-1]:=%ID1[%m[1]]
    			%vel1[%m[1]-1]:=%vel1[%m[1]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[1])
    		else
    			dec(%m[1])
    		end if
    	end while
    
    
    case 2
    	inc(%n[$EVENT_NOTE])
    	%ID2[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel2[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[2]:=%n[$EVENT_NOTE]
    	while (%m[2]>1)
    		if (%vel2[%m[2]]>%vel2[%m[2]-1])
    			fade_out(%ID2[%m[2]-1], 1000*$fadeout, 1)
    			%ID2[%m[2]-1]:=%ID2[%m[2]]
    			%vel2[%m[2]-1]:=%vel2[%m[2]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[2])
    		else
    			dec(%m[2])
    		end if
    	end while
    
    case 3
    	inc(%n[$EVENT_NOTE])
    	%ID3[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel3[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[3]:=%n[$EVENT_NOTE]
    	while (%m[3]>1)
    		if (%vel3[%m[3]]>%vel3[%m[3]-1])
    			fade_out(%ID3[%m[3]-1], 1000*$fadeout, 1)
    			%ID3[%m[3]-1]:=%ID3[%m[3]]
    			%vel3[%m[3]-1]:=%vel3[%m[3]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[3])
    		else
    			dec(%m[3])
    		end if
    	end while
    
    case 4
    	inc(%n[$EVENT_NOTE])
    	%ID4[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel4[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[4]:=%n[$EVENT_NOTE]
    	while (%m[4]>1)
    		if (%vel4[%m[4]]>%vel4[%m[4]-1])
    			fade_out(%ID4[%m[4]-1], 1000*$fadeout, 1)
    			%ID4[%m[4]-1]:=%ID4[%m[4]]
    			%vel4[%m[4]-1]:=%vel4[%m[4]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[4])
    		else
    			dec(%m[4])
    		end if
    	end while
    
    case 5
    	inc(%n[$EVENT_NOTE])
    	%ID5[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel5[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[5]:=%n[$EVENT_NOTE]
    	while (%m[5]>1)
    		if (%vel5[%m[5]]>%vel5[%m[5]-1])
    			fade_out(%ID5[%m[5]-1], 1000*$fadeout, 1)
    			%ID5[%m[5]-1]:=%ID5[%m[5]]
    			%vel5[%m[5]-1]:=%vel5[%m[5]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[5])
    		else
    			dec(%m[5])
    		end if
    	end while
    
    case 6
    	inc(%n[$EVENT_NOTE])
    	%ID6[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel6[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[6]:=%n[$EVENT_NOTE]
    	while (%m[6]>1)
    		if (%vel6[%m[6]]>%vel6[%m[6]-1])
    			fade_out(%ID6[%m[6]-1], 1000*$fadeout, 1)
    			%ID6[%m[6]-1]:=%ID6[%m[6]]
    			%vel6[%m[6]-1]:=%vel6[%m[6]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[6])
    		else
    			dec(%m[6])
    		end if
    	end while
    
    case 7
    	inc(%n[$EVENT_NOTE])
    	%ID7[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel7[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[7]:=%n[$EVENT_NOTE]
    	while (%m[7]>1)
    		if (%vel7[%m[7]]>%vel7[%m[7]-1])
    			fade_out(%ID7[%m[7]-1], 1000*$fadeout, 1)
    			%ID7[%m[7]-1]:=%ID7[%m[7]]
    			%vel7[%m[7]-1]:=%vel7[%m[7]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[7])
    		else
    			dec(%m[7])
    		end if
    	end while
    
    case 8
    	inc(%n[$EVENT_NOTE])
    	%ID8[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel8[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[8]:=%n[$EVENT_NOTE]
    	while (%m[8]>1)
    		if (%vel8[%m[8]]>%vel8[%m[8]-1])
    			fade_out(%ID8[%m[8]-1], 1000*$fadeout, 1)
    			%ID8[%m[8]-1]:=%ID8[%m[8]]
    			%vel8[%m[8]-1]:=%vel8[%m[8]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[8])
    		else
    			dec(%m[8])
    		end if
    	end while
    
    case 9
    	inc(%n[$EVENT_NOTE])
    	%ID9[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel9[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[9]:=%n[$EVENT_NOTE]
    	while (%m[9]>1)
    		if (%vel9[%m[9]]>%vel9[%m[9]-1])
    			fade_out(%ID9[%m[9]-1], 1000*$fadeout, 1)
    			%ID9[%m[9]-1]:=%ID9[%m[9]]
    			%vel9[%m[9]-1]:=%vel9[%m[9]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[9])
    		else
    			dec(%m[9])
    		end if
    	end while
    
    case 10
    	inc(%n[$EVENT_NOTE])
    	%ID10[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel10[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[10]:=%n[$EVENT_NOTE]
    	while (%m[10]>1)
    		if (%vel10[%m[10]]>%vel10[%m[10]-1])
    			fade_out(%ID10[%m[10]-1], 1000*$fadeout, 1)
    			%ID10[%m[10]-1]:=%ID10[%m[10]]
    			%vel10[%m[10]-1]:=%vel10[%m[10]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[10])
    		else
    			dec(%m[10])
    		end if
    	end while
    
    case 11
    	inc(%n[$EVENT_NOTE])
    	%ID11[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel11[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[11]:=%n[$EVENT_NOTE]
    	while (%m[11]>1)
    		if (%vel11[%m[11]]>%vel11[%m[11]-1])
    			fade_out(%ID11[%m[11]-1], 1000*$fadeout, 1)
    			%ID11[%m[11]-1]:=%ID11[%m[11]]
    			%vel11[%m[11]-1]:=%vel11[%m[11]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[11])
    		else
    			dec(%m[11])
    		end if
    	end while
    
    case 12
    	inc(%n[$EVENT_NOTE])
    	%ID12[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel12[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[12]:=%n[$EVENT_NOTE]
    	while (%m[12]>1)
    		if (%vel12[%m[12]]>%vel12[%m[12]-1])
    			fade_out(%ID12[%m[12]-1], 1000*$fadeout, 1)
    			%ID12[%m[12]-1]:=%ID12[%m[12]]
    			%vel12[%m[12]-1]:=%vel12[%m[12]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[12])
    		else
    			dec(%m[12])
    		end if
    	end while
    
    case 13
    	inc(%n[$EVENT_NOTE])
    	%ID13[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel13[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[13]:=%n[$EVENT_NOTE]
    	while (%m[13]>1)
    		if (%vel13[%m[13]]>%vel13[%m[13]-1])
    			fade_out(%ID13[%m[13]-1], 1000*$fadeout, 1)
    			%ID13[%m[13]-1]:=%ID13[%m[13]]
    			%vel13[%m[13]-1]:=%vel13[%m[13]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[13])
    		else
    			dec(%m[13])
    		end if
    	end while
    
    case 14
    	inc(%n[$EVENT_NOTE])
    	%ID14[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel14[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[14]:=%n[$EVENT_NOTE]
    	while (%m[14]>1)
    		if (%vel14[%m[14]]>%vel14[%m[14]-1])
    			fade_out(%ID14[%m[14]-1], 1000*$fadeout, 1)
    			%ID14[%m[14]-1]:=%ID14[%m[14]]
    			%vel14[%m[14]-1]:=%vel14[%m[14]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[14])
    		else
    			dec(%m[14])
    		end if
    	end while
    
    case 15
    	inc(%n[$EVENT_NOTE])
    	%ID15[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel15[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[15]:=%n[$EVENT_NOTE]
    	while (%m[15]>1)
    		if (%vel15[%m[15]]>%vel15[%m[15]-1])
    			fade_out(%ID15[%m[15]-1], 1000*$fadeout, 1)
    			%ID15[%m[15]-1]:=%ID15[%m[15]]
    			%vel15[%m[15]-1]:=%vel15[%m[15]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[15])
    		else
    			dec(%m[15])
    		end if
    	end while
    
    case 16
    	inc(%n[$EVENT_NOTE])
    	%ID16[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel16[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[16]:=%n[$EVENT_NOTE]
    	while (%m[16]>1)
    		if (%vel16[%m[16]]>%vel16[%m[16]-1])
    			fade_out(%ID16[%m[16]-1], 1000*$fadeout, 1)
    			%ID16[%m[16]-1]:=%ID16[%m[16]]
    			%vel16[%m[16]-1]:=%vel16[%m[16]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[16])
    		else
    			dec(%m[16])
    		end if
    	end while
    
    case 17
    	inc(%n[$EVENT_NOTE])
    	%ID17[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel17[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[17]:=%n[$EVENT_NOTE]
    	while (%m[17]>1)
    		if (%vel17[%m[17]]>%vel17[%m[17]-1])
    			fade_out(%ID17[%m[17]-1], 1000*$fadeout, 1)
    			%ID17[%m[17]-1]:=%ID17[%m[17]]
    			%vel17[%m[17]-1]:=%vel17[%m[17]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[17])
    		else
    			dec(%m[17])
    		end if
    	end while
    
    case 18
    	inc(%n[$EVENT_NOTE])
    	%ID18[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel18[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[18]:=%n[$EVENT_NOTE]
    	while (%m[18]>1)
    		if (%vel18[%m[18]]>%vel18[%m[18]-1])
    			fade_out(%ID18[%m[18]-1], 1000*$fadeout, 1)
    			%ID18[%m[18]-1]:=%ID18[%m[18]]
    			%vel18[%m[18]-1]:=%vel18[%m[18]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[18])
    		else
    			dec(%m[18])
    		end if
    	end while
    
    case 19
    	inc(%n[$EVENT_NOTE])
    	%ID19[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel19[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[19]:=%n[$EVENT_NOTE]
    	while (%m[19]>1)
    		if (%vel19[%m[19]]>%vel19[%m[19]-1])
    			fade_out(%ID19[%m[19]-1], 1000*$fadeout, 1)
    			%ID19[%m[19]-1]:=%ID19[%m[19]]
    			%vel19[%m[19]-1]:=%vel19[%m[19]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[19])
    		else
    			dec(%m[19])
    		end if
    	end while
    
    case 20
    	inc(%n[$EVENT_NOTE])
    	%ID20[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel20[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[20]:=%n[$EVENT_NOTE]
    	while (%m[20]>1)
    		if (%vel20[%m[20]]>%vel20[%m[20]-1])
    			fade_out(%ID20[%m[20]-1], 1000*$fadeout, 1)
    			%ID20[%m[20]-1]:=%ID20[%m[20]]
    			%vel20[%m[20]-1]:=%vel20[%m[20]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[20])
    		else
    			dec(%m[20])
    		end if
    	end while
    
    case 21
    	inc(%n[$EVENT_NOTE])
    	%ID21[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel21[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[21]:=%n[$EVENT_NOTE]
    	while (%m[21]>1)
    		if (%vel21[%m[21]]>%vel21[%m[21]-1])
    			fade_out(%ID21[%m[21]-1], 1000*$fadeout, 1)
    			%ID21[%m[21]-1]:=%ID21[%m[21]]
    			%vel21[%m[21]-1]:=%vel21[%m[21]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[21])
    		else
    			dec(%m[21])
    		end if
    	end while
    
    case 22
    	inc(%n[$EVENT_NOTE])
    	%ID22[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel22[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[22]:=%n[$EVENT_NOTE]
    	while (%m[22]>1)
    		if (%vel22[%m[22]]>%vel22[%m[22]-1])
    			fade_out(%ID22[%m[22]-1], 1000*$fadeout, 1)
    			%ID22[%m[22]-1]:=%ID22[%m[22]]
    			%vel22[%m[22]-1]:=%vel22[%m[22]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[22])
    		else
    			dec(%m[22])
    		end if
    	end while
    
    case 23
    	inc(%n[$EVENT_NOTE])
    	%ID23[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel23[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[23]:=%n[$EVENT_NOTE]
    	while (%m[23]>1)
    		if (%vel23[%m[23]]>%vel23[%m[23]-1])
    			fade_out(%ID23[%m[23]-1], 1000*$fadeout, 1)
    			%ID23[%m[23]-1]:=%ID23[%m[23]]
    			%vel23[%m[23]-1]:=%vel23[%m[23]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[23])
    		else
    			dec(%m[23])
    		end if
    	end while
    
    case 24
    	inc(%n[$EVENT_NOTE])
    	%ID24[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel24[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[24]:=%n[$EVENT_NOTE]
    	while (%m[24]>1)
    		if (%vel24[%m[24]]>%vel24[%m[24]-1])
    			fade_out(%ID24[%m[24]-1], 1000*$fadeout, 1)
    			%ID24[%m[24]-1]:=%ID24[%m[24]]
    			%vel24[%m[24]-1]:=%vel24[%m[24]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[24])
    		else
    			dec(%m[24])
    		end if
    	end while
    
    case 25
    	inc(%n[$EVENT_NOTE])
    	%ID25[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel25[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[25]:=%n[$EVENT_NOTE]
    	while (%m[25]>1)
    		if (%vel25[%m[25]]>%vel25[%m[25]-1])
    			fade_out(%ID25[%m[25]-1], 1000*$fadeout, 1)
    			%ID25[%m[25]-1]:=%ID25[%m[25]]
    			%vel25[%m[25]-1]:=%vel25[%m[25]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[25])
    		else
    			dec(%m[25])
    		end if
    	end while
    
    case 26
    	inc(%n[$EVENT_NOTE])
    	%ID26[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel26[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[26]:=%n[$EVENT_NOTE]
    	while (%m[26]>1)
    		if (%vel26[%m[26]]>%vel26[%m[26]-1])
    			fade_out(%ID26[%m[26]-1], 1000*$fadeout, 1)
    			%ID26[%m[26]-1]:=%ID26[%m[26]]
    			%vel26[%m[26]-1]:=%vel26[%m[26]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[26])
    		else
    			dec(%m[26])
    		end if
    	end while
    
    case 27
    	inc(%n[$EVENT_NOTE])
    	%ID27[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel27[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[27]:=%n[$EVENT_NOTE]
    	while (%m[27]>1)
    		if (%vel27[%m[27]]>%vel27[%m[27]-1])
    			fade_out(%ID27[%m[27]-1], 1000*$fadeout, 1)
    			%ID27[%m[27]-1]:=%ID27[%m[27]]
    			%vel27[%m[27]-1]:=%vel27[%m[27]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[27])
    		else
    			dec(%m[27])
    		end if
    	end while
    
    case 28
    	inc(%n[$EVENT_NOTE])
    	%ID28[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel28[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[28]:=%n[$EVENT_NOTE]
    	while (%m[28]>1)
    		if (%vel28[%m[28]]>%vel28[%m[28]-1])
    			fade_out(%ID28[%m[28]-1], 1000*$fadeout, 1)
    			%ID28[%m[28]-1]:=%ID28[%m[28]]
    			%vel28[%m[28]-1]:=%vel28[%m[28]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[28])
    		else
    			dec(%m[28])
    		end if
    	end while
    
    case 29
    	inc(%n[$EVENT_NOTE])
    	%ID29[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel29[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[29]:=%n[$EVENT_NOTE]
    	while (%m[29]>1)
    		if (%vel29[%m[29]]>%vel29[%m[29]-1])
    			fade_out(%ID29[%m[29]-1], 1000*$fadeout, 1)
    			%ID29[%m[29]-1]:=%ID29[%m[29]]
    			%vel29[%m[29]-1]:=%vel29[%m[29]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[29])
    		else
    			dec(%m[29])
    		end if
    	end while
    
    case 30
    	inc(%n[$EVENT_NOTE])
    	%ID30[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel30[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[30]:=%n[$EVENT_NOTE]
    	while (%m[30]>1)
    		if (%vel30[%m[30]]>%vel30[%m[30]-1])
    			fade_out(%ID30[%m[30]-1], 1000*$fadeout, 1)
    			%ID30[%m[30]-1]:=%ID30[%m[30]]
    			%vel30[%m[30]-1]:=%vel30[%m[30]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[30])
    		else
    			dec(%m[30])
    		end if
    	end while
    
    case 31
    	inc(%n[$EVENT_NOTE])
    	%ID31[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel31[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[31]:=%n[$EVENT_NOTE]
    	while (%m[31]>1)
    		if (%vel31[%m[31]]>%vel31[%m[31]-1])
    			fade_out(%ID31[%m[31]-1], 1000*$fadeout, 1)
    			%ID31[%m[31]-1]:=%ID31[%m[31]]
    			%vel31[%m[31]-1]:=%vel31[%m[31]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[31])
    		else
    			dec(%m[31])
    		end if
    	end while
    
    case 32
    	inc(%n[$EVENT_NOTE])
    	%ID32[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel32[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[32]:=%n[$EVENT_NOTE]
    	while (%m[32]>1)
    		if (%vel32[%m[32]]>%vel32[%m[32]-1])
    			fade_out(%ID32[%m[32]-1], 1000*$fadeout, 1)
    			%ID32[%m[32]-1]:=%ID32[%m[32]]
    			%vel32[%m[32]-1]:=%vel32[%m[32]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[32])
    		else
    			dec(%m[32])
    		end if
    	end while
    
    case 33
    	inc(%n[$EVENT_NOTE])
    	%ID33[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel33[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[33]:=%n[$EVENT_NOTE]
    	while (%m[33]>1)
    		if (%vel33[%m[33]]>%vel33[%m[33]-1])
    			fade_out(%ID33[%m[33]-1], 1000*$fadeout, 1)
    			%ID33[%m[33]-1]:=%ID33[%m[33]]
    			%vel33[%m[33]-1]:=%vel33[%m[33]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[33])
    		else
    			dec(%m[33])
    		end if
    	end while
    
    case 34
    	inc(%n[$EVENT_NOTE])
    	%ID34[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel34[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[34]:=%n[$EVENT_NOTE]
    	while (%m[34]>1)
    		if (%vel34[%m[34]]>%vel34[%m[34]-1])
    			fade_out(%ID34[%m[34]-1], 1000*$fadeout, 1)
    			%ID34[%m[34]-1]:=%ID34[%m[34]]
    			%vel34[%m[34]-1]:=%vel34[%m[34]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[34])
    		else
    			dec(%m[34])
    		end if
    	end while
    
    case 35
    	inc(%n[$EVENT_NOTE])
    	%ID35[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel35[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[35]:=%n[$EVENT_NOTE]
    	while (%m[35]>1)
    		if (%vel35[%m[35]]>%vel35[%m[35]-1])
    			fade_out(%ID35[%m[35]-1], 1000*$fadeout, 1)
    			%ID35[%m[35]-1]:=%ID35[%m[35]]
    			%vel35[%m[35]-1]:=%vel35[%m[35]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[35])
    		else
    			dec(%m[35])
    		end if
    	end while
    
    case 36
    	inc(%n[$EVENT_NOTE])
    	%ID36[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel36[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[36]:=%n[$EVENT_NOTE]
    	while (%m[36]>1)
    		if (%vel36[%m[36]]>%vel36[%m[36]-1])
    			fade_out(%ID36[%m[36]-1], 1000*$fadeout, 1)
    			%ID36[%m[36]-1]:=%ID36[%m[36]]
    			%vel36[%m[36]-1]:=%vel36[%m[36]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[36])
    		else
    			dec(%m[36])
    		end if
    	end while
    
    case 37
    	inc(%n[$EVENT_NOTE])
    	%ID37[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel37[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[37]:=%n[$EVENT_NOTE]
    	while (%m[37]>1)
    		if (%vel37[%m[37]]>%vel37[%m[37]-1])
    			fade_out(%ID37[%m[37]-1], 1000*$fadeout, 1)
    			%ID37[%m[37]-1]:=%ID37[%m[37]]
    			%vel37[%m[37]-1]:=%vel37[%m[37]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[37])
    		else
    			dec(%m[37])
    		end if
    	end while
    
    case 38
    	inc(%n[$EVENT_NOTE])
    	%ID38[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel38[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[38]:=%n[$EVENT_NOTE]
    	while (%m[38]>1)
    		if (%vel38[%m[38]]>%vel38[%m[38]-1])
    			fade_out(%ID38[%m[38]-1], 1000*$fadeout, 1)
    			%ID38[%m[38]-1]:=%ID38[%m[38]]
    			%vel38[%m[38]-1]:=%vel38[%m[38]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[38])
    		else
    			dec(%m[38])
    		end if
    	end while
    
    case 39
    	inc(%n[$EVENT_NOTE])
    	%ID39[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel39[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[39]:=%n[$EVENT_NOTE]
    	while (%m[39]>1)
    		if (%vel39[%m[39]]>%vel39[%m[39]-1])
    			fade_out(%ID39[%m[39]-1], 1000*$fadeout, 1)
    			%ID39[%m[39]-1]:=%ID39[%m[39]]
    			%vel39[%m[39]-1]:=%vel39[%m[39]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[39])
    		else
    			dec(%m[39])
    		end if
    	end while
    
    case 40
    	inc(%n[$EVENT_NOTE])
    	%ID40[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel40[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[40]:=%n[$EVENT_NOTE]
    	while (%m[40]>1)
    		if (%vel40[%m[40]]>%vel40[%m[40]-1])
    			fade_out(%ID40[%m[40]-1], 1000*$fadeout, 1)
    			%ID40[%m[40]-1]:=%ID40[%m[40]]
    			%vel40[%m[40]-1]:=%vel40[%m[40]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[40])
    		else
    			dec(%m[40])
    		end if
    	end while
    
    case 41
    	inc(%n[$EVENT_NOTE])
    	%ID41[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel41[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[41]:=%n[$EVENT_NOTE]
    	while (%m[41]>1)
    		if (%vel41[%m[41]]>%vel41[%m[41]-1])
    			fade_out(%ID41[%m[41]-1], 1000*$fadeout, 1)
    			%ID41[%m[41]-1]:=%ID41[%m[41]]
    			%vel41[%m[41]-1]:=%vel41[%m[41]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[41])
    		else
    			dec(%m[41])
    		end if
    	end while
    
    case 42
    	inc(%n[$EVENT_NOTE])
    	%ID42[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel42[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[42]:=%n[$EVENT_NOTE]
    	while (%m[42]>1)
    		if (%vel42[%m[42]]>%vel42[%m[42]-1])
    			fade_out(%ID42[%m[42]-1], 1000*$fadeout, 1)
    			%ID42[%m[42]-1]:=%ID42[%m[42]]
    			%vel42[%m[42]-1]:=%vel42[%m[42]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[42])
    		else
    			dec(%m[42])
    		end if
    	end while
    
    case 43
    	inc(%n[$EVENT_NOTE])
    	%ID43[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel43[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[43]:=%n[$EVENT_NOTE]
    	while (%m[43]>1)
    		if (%vel43[%m[43]]>%vel43[%m[43]-1])
    			fade_out(%ID43[%m[43]-1], 1000*$fadeout, 1)
    			%ID43[%m[43]-1]:=%ID43[%m[43]]
    			%vel43[%m[43]-1]:=%vel43[%m[43]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[43])
    		else
    			dec(%m[43])
    		end if
    	end while
    
    case 44
    	inc(%n[$EVENT_NOTE])
    	%ID44[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel44[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[44]:=%n[$EVENT_NOTE]
    	while (%m[44]>1)
    		if (%vel44[%m[44]]>%vel44[%m[44]-1])
    			fade_out(%ID44[%m[44]-1], 1000*$fadeout, 1)
    			%ID44[%m[44]-1]:=%ID44[%m[44]]
    			%vel44[%m[44]-1]:=%vel44[%m[44]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[44])
    		else
    			dec(%m[44])
    		end if
    	end while
    
    case 45
    	inc(%n[$EVENT_NOTE])
    	%ID45[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel45[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[45]:=%n[$EVENT_NOTE]
    	while (%m[45]>1)
    		if (%vel45[%m[45]]>%vel45[%m[45]-1])
    			fade_out(%ID45[%m[45]-1], 1000*$fadeout, 1)
    			%ID45[%m[45]-1]:=%ID45[%m[45]]
    			%vel45[%m[45]-1]:=%vel45[%m[45]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[45])
    		else
    			dec(%m[45])
    		end if
    	end while
    
    case 46
    	inc(%n[$EVENT_NOTE])
    	%ID46[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel46[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[46]:=%n[$EVENT_NOTE]
    	while (%m[46]>1)
    		if (%vel46[%m[46]]>%vel46[%m[46]-1])
    			fade_out(%ID46[%m[46]-1], 1000*$fadeout, 1)
    			%ID46[%m[46]-1]:=%ID46[%m[46]]
    			%vel46[%m[46]-1]:=%vel46[%m[46]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[46])
    		else
    			dec(%m[46])
    		end if
    	end while
    
    case 47
    	inc(%n[$EVENT_NOTE])
    	%ID47[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel47[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[47]:=%n[$EVENT_NOTE]
    	while (%m[47]>1)
    		if (%vel47[%m[47]]>%vel47[%m[47]-1])
    			fade_out(%ID47[%m[47]-1], 1000*$fadeout, 1)
    			%ID47[%m[47]-1]:=%ID47[%m[47]]
    			%vel47[%m[47]-1]:=%vel47[%m[47]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[47])
    		else
    			dec(%m[47])
    		end if
    	end while
    
    case 48
    	inc(%n[$EVENT_NOTE])
    	%ID48[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel48[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[48]:=%n[$EVENT_NOTE]
    	while (%m[48]>1)
    		if (%vel48[%m[48]]>%vel48[%m[48]-1])
    			fade_out(%ID48[%m[48]-1], 1000*$fadeout, 1)
    			%ID48[%m[48]-1]:=%ID48[%m[48]]
    			%vel48[%m[48]-1]:=%vel48[%m[48]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[48])
    		else
    			dec(%m[48])
    		end if
    	end while
    
    case 49
    	inc(%n[$EVENT_NOTE])
    	%ID49[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel49[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[49]:=%n[$EVENT_NOTE]
    	while (%m[49]>1)
    		if (%vel49[%m[49]]>%vel49[%m[49]-1])
    			fade_out(%ID49[%m[49]-1], 1000*$fadeout, 1)
    			%ID49[%m[49]-1]:=%ID49[%m[49]]
    			%vel49[%m[49]-1]:=%vel49[%m[49]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[49])
    		else
    			dec(%m[49])
    		end if
    	end while
    
    case 50
    	inc(%n[$EVENT_NOTE])
    	%ID50[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel50[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[50]:=%n[$EVENT_NOTE]
    	while (%m[50]>1)
    		if (%vel50[%m[50]]>%vel50[%m[50]-1])
    			fade_out(%ID50[%m[50]-1], 1000*$fadeout, 1)
    			%ID50[%m[50]-1]:=%ID50[%m[50]]
    			%vel50[%m[50]-1]:=%vel50[%m[50]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[50])
    		else
    			dec(%m[50])
    		end if
    	end while
    
    case 51
    	inc(%n[$EVENT_NOTE])
    	%ID51[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel51[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[51]:=%n[$EVENT_NOTE]
    	while (%m[51]>1)
    		if (%vel51[%m[51]]>%vel51[%m[51]-1])
    			fade_out(%ID51[%m[51]-1], 1000*$fadeout, 1)
    			%ID51[%m[51]-1]:=%ID51[%m[51]]
    			%vel51[%m[51]-1]:=%vel51[%m[51]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[51])
    		else
    			dec(%m[51])
    		end if
    	end while
    
    case 52
    	inc(%n[$EVENT_NOTE])
    	%ID52[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel52[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[52]:=%n[$EVENT_NOTE]
    	while (%m[52]>1)
    		if (%vel52[%m[52]]>%vel52[%m[52]-1])
    			fade_out(%ID52[%m[52]-1], 1000*$fadeout, 1)
    			%ID52[%m[52]-1]:=%ID52[%m[52]]
    			%vel52[%m[52]-1]:=%vel52[%m[52]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[52])
    		else
    			dec(%m[52])
    		end if
    	end while
    
    case 53
    	inc(%n[$EVENT_NOTE])
    	%ID53[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel53[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[53]:=%n[$EVENT_NOTE]
    	while (%m[53]>1)
    		if (%vel53[%m[53]]>%vel53[%m[53]-1])
    			fade_out(%ID53[%m[53]-1], 1000*$fadeout, 1)
    			%ID53[%m[53]-1]:=%ID53[%m[53]]
    			%vel53[%m[53]-1]:=%vel53[%m[53]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[53])
    		else
    			dec(%m[53])
    		end if
    	end while
    
    case 54
    	inc(%n[$EVENT_NOTE])
    	%ID54[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel54[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[54]:=%n[$EVENT_NOTE]
    	while (%m[54]>1)
    		if (%vel54[%m[54]]>%vel54[%m[54]-1])
    			fade_out(%ID54[%m[54]-1], 1000*$fadeout, 1)
    			%ID54[%m[54]-1]:=%ID54[%m[54]]
    			%vel54[%m[54]-1]:=%vel54[%m[54]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[54])
    		else
    			dec(%m[54])
    		end if
    	end while
    
    case 55
    	inc(%n[$EVENT_NOTE])
    	%ID55[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel55[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[55]:=%n[$EVENT_NOTE]
    	while (%m[55]>1)
    		if (%vel55[%m[55]]>%vel55[%m[55]-1])
    			fade_out(%ID55[%m[55]-1], 1000*$fadeout, 1)
    			%ID55[%m[55]-1]:=%ID55[%m[55]]
    			%vel55[%m[55]-1]:=%vel55[%m[55]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[55])
    		else
    			dec(%m[55])
    		end if
    	end while
    
    case 56
    	inc(%n[$EVENT_NOTE])
    	%ID56[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel56[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[56]:=%n[$EVENT_NOTE]
    	while (%m[56]>1)
    		if (%vel56[%m[56]]>%vel56[%m[56]-1])
    			fade_out(%ID56[%m[56]-1], 1000*$fadeout, 1)
    			%ID56[%m[56]-1]:=%ID56[%m[56]]
    			%vel56[%m[56]-1]:=%vel56[%m[56]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[56])
    		else
    			dec(%m[56])
    		end if
    	end while
    
    case 57
    	inc(%n[$EVENT_NOTE])
    	%ID57[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel57[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[57]:=%n[$EVENT_NOTE]
    	while (%m[57]>1)
    		if (%vel57[%m[57]]>%vel57[%m[57]-1])
    			fade_out(%ID57[%m[57]-1], 1000*$fadeout, 1)
    			%ID57[%m[57]-1]:=%ID57[%m[57]]
    			%vel57[%m[57]-1]:=%vel57[%m[57]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[57])
    		else
    			dec(%m[57])
    		end if
    	end while
    
    case 58
    	inc(%n[$EVENT_NOTE])
    	%ID58[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel58[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[58]:=%n[$EVENT_NOTE]
    	while (%m[58]>1)
    		if (%vel58[%m[58]]>%vel58[%m[58]-1])
    			fade_out(%ID58[%m[58]-1], 1000*$fadeout, 1)
    			%ID58[%m[58]-1]:=%ID58[%m[58]]
    			%vel58[%m[58]-1]:=%vel58[%m[58]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[58])
    		else
    			dec(%m[58])
    		end if
    	end while
    
    case 59
    	inc(%n[$EVENT_NOTE])
    	%ID59[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel59[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[59]:=%n[$EVENT_NOTE]
    	while (%m[59]>1)
    		if (%vel59[%m[59]]>%vel59[%m[59]-1])
    			fade_out(%ID59[%m[59]-1], 1000*$fadeout, 1)
    			%ID59[%m[59]-1]:=%ID59[%m[59]]
    			%vel59[%m[59]-1]:=%vel59[%m[59]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[59])
    		else
    			dec(%m[59])
    		end if
    	end while
    
    case 60
    	inc(%n[$EVENT_NOTE])
    	%ID60[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel60[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[60]:=%n[$EVENT_NOTE]
    	while (%m[60]>1)
    		if (%vel60[%m[60]]>%vel60[%m[60]-1])
    			fade_out(%ID60[%m[60]-1], 1000*$fadeout, 1)
    			%ID60[%m[60]-1]:=%ID60[%m[60]]
    			%vel60[%m[60]-1]:=%vel60[%m[60]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[60])
    		else
    			dec(%m[60])
    		end if
    	end while
    
    case 61
    	inc(%n[$EVENT_NOTE])
    	%ID61[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel61[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[61]:=%n[$EVENT_NOTE]
    	while (%m[61]>1)
    		if (%vel61[%m[61]]>%vel61[%m[61]-1])
    			fade_out(%ID61[%m[61]-1], 1000*$fadeout, 1)
    			%ID61[%m[61]-1]:=%ID61[%m[61]]
    			%vel61[%m[61]-1]:=%vel61[%m[61]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[61])
    		else
    			dec(%m[61])
    		end if
    	end while
    
    case 62
    	inc(%n[$EVENT_NOTE])
    	%ID62[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel62[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[62]:=%n[$EVENT_NOTE]
    	while (%m[62]>1)
    		if (%vel62[%m[62]]>%vel62[%m[62]-1])
    			fade_out(%ID62[%m[62]-1], 1000*$fadeout, 1)
    			%ID62[%m[62]-1]:=%ID62[%m[62]]
    			%vel62[%m[62]-1]:=%vel62[%m[62]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[62])
    		else
    			dec(%m[62])
    		end if
    	end while
    
    case 63
    	inc(%n[$EVENT_NOTE])
    	%ID63[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel63[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[63]:=%n[$EVENT_NOTE]
    	while (%m[63]>1)
    		if (%vel63[%m[63]]>%vel63[%m[63]-1])
    			fade_out(%ID63[%m[63]-1], 1000*$fadeout, 1)
    			%ID63[%m[63]-1]:=%ID63[%m[63]]
    			%vel63[%m[63]-1]:=%vel63[%m[63]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[63])
    		else
    			dec(%m[63])
    		end if
    	end while
    
    case 64
    	inc(%n[$EVENT_NOTE])
    	%ID64[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel64[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[64]:=%n[$EVENT_NOTE]
    	while (%m[64]>1)
    		if (%vel64[%m[64]]>%vel64[%m[64]-1])
    			fade_out(%ID64[%m[64]-1], 1000*$fadeout, 1)
    			%ID64[%m[64]-1]:=%ID64[%m[64]]
    			%vel64[%m[64]-1]:=%vel64[%m[64]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[64])
    		else
    			dec(%m[64])
    		end if
    	end while
    
    case 65
    	inc(%n[$EVENT_NOTE])
    	%ID65[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel65[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[65]:=%n[$EVENT_NOTE]
    	while (%m[65]>1)
    		if (%vel65[%m[65]]>%vel65[%m[65]-1])
    			fade_out(%ID65[%m[65]-1], 1000*$fadeout, 1)
    			%ID65[%m[65]-1]:=%ID65[%m[65]]
    			%vel65[%m[65]-1]:=%vel65[%m[65]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[65])
    		else
    			dec(%m[65])
    		end if
    	end while
    
    case 66
    	inc(%n[$EVENT_NOTE])
    	%ID66[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel66[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[66]:=%n[$EVENT_NOTE]
    	while (%m[66]>1)
    		if (%vel66[%m[66]]>%vel66[%m[66]-1])
    			fade_out(%ID66[%m[66]-1], 1000*$fadeout, 1)
    			%ID66[%m[66]-1]:=%ID66[%m[66]]
    			%vel66[%m[66]-1]:=%vel66[%m[66]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[66])
    		else
    			dec(%m[66])
    		end if
    	end while
    
    case 67
    	inc(%n[$EVENT_NOTE])
    	%ID67[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel67[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[67]:=%n[$EVENT_NOTE]
    	while (%m[67]>1)
    		if (%vel67[%m[67]]>%vel67[%m[67]-1])
    			fade_out(%ID67[%m[67]-1], 1000*$fadeout, 1)
    			%ID67[%m[67]-1]:=%ID67[%m[67]]
    			%vel67[%m[67]-1]:=%vel67[%m[67]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[67])
    		else
    			dec(%m[67])
    		end if
    	end while
    
    case 68
    	inc(%n[$EVENT_NOTE])
    	%ID68[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel68[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[68]:=%n[$EVENT_NOTE]
    	while (%m[68]>1)
    		if (%vel68[%m[68]]>%vel68[%m[68]-1])
    			fade_out(%ID68[%m[68]-1], 1000*$fadeout, 1)
    			%ID68[%m[68]-1]:=%ID68[%m[68]]
    			%vel68[%m[68]-1]:=%vel68[%m[68]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[68])
    		else
    			dec(%m[68])
    		end if
    	end while
    
    case 69
    	inc(%n[$EVENT_NOTE])
    	%ID69[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel69[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[69]:=%n[$EVENT_NOTE]
    	while (%m[69]>1)
    		if (%vel69[%m[69]]>%vel69[%m[69]-1])
    			fade_out(%ID69[%m[69]-1], 1000*$fadeout, 1)
    			%ID69[%m[69]-1]:=%ID69[%m[69]]
    			%vel69[%m[69]-1]:=%vel69[%m[69]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[69])
    		else
    			dec(%m[69])
    		end if
    	end while
    
    case 70
    	inc(%n[$EVENT_NOTE])
    	%ID70[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel70[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[70]:=%n[$EVENT_NOTE]
    	while (%m[70]>1)
    		if (%vel70[%m[70]]>%vel70[%m[70]-1])
    			fade_out(%ID70[%m[70]-1], 1000*$fadeout, 1)
    			%ID70[%m[70]-1]:=%ID70[%m[70]]
    			%vel70[%m[70]-1]:=%vel70[%m[70]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[70])
    		else
    			dec(%m[70])
    		end if
    	end while
    
    case 71
    	inc(%n[$EVENT_NOTE])
    	%ID71[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel71[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[71]:=%n[$EVENT_NOTE]
    	while (%m[71]>1)
    		if (%vel71[%m[71]]>%vel71[%m[71]-1])
    			fade_out(%ID71[%m[71]-1], 1000*$fadeout, 1)
    			%ID71[%m[71]-1]:=%ID71[%m[71]]
    			%vel71[%m[71]-1]:=%vel71[%m[71]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[71])
    		else
    			dec(%m[71])
    		end if
    	end while
    
    case 72
    	inc(%n[$EVENT_NOTE])
    	%ID72[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel72[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[72]:=%n[$EVENT_NOTE]
    	while (%m[72]>1)
    		if (%vel72[%m[72]]>%vel72[%m[72]-1])
    			fade_out(%ID72[%m[72]-1], 1000*$fadeout, 1)
    			%ID72[%m[72]-1]:=%ID72[%m[72]]
    			%vel72[%m[72]-1]:=%vel72[%m[72]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[72])
    		else
    			dec(%m[72])
    		end if
    	end while
    
    case 73
    	inc(%n[$EVENT_NOTE])
    	%ID73[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel73[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[73]:=%n[$EVENT_NOTE]
    	while (%m[73]>1)
    		if (%vel73[%m[73]]>%vel73[%m[73]-1])
    			fade_out(%ID73[%m[73]-1], 1000*$fadeout, 1)
    			%ID73[%m[73]-1]:=%ID73[%m[73]]
    			%vel73[%m[73]-1]:=%vel73[%m[73]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[73])
    		else
    			dec(%m[73])
    		end if
    	end while
    
    case 74
    	inc(%n[$EVENT_NOTE])
    	%ID74[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel74[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[74]:=%n[$EVENT_NOTE]
    	while (%m[74]>1)
    		if (%vel74[%m[74]]>%vel74[%m[74]-1])
    			fade_out(%ID74[%m[74]-1], 1000*$fadeout, 1)
    			%ID74[%m[74]-1]:=%ID74[%m[74]]
    			%vel74[%m[74]-1]:=%vel74[%m[74]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[74])
    		else
    			dec(%m[74])
    		end if
    	end while
    
    case 75
    	inc(%n[$EVENT_NOTE])
    	%ID75[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel75[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[75]:=%n[$EVENT_NOTE]
    	while (%m[75]>1)
    		if (%vel75[%m[75]]>%vel75[%m[75]-1])
    			fade_out(%ID75[%m[75]-1], 1000*$fadeout, 1)
    			%ID75[%m[75]-1]:=%ID75[%m[75]]
    			%vel75[%m[75]-1]:=%vel75[%m[75]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[75])
    		else
    			dec(%m[75])
    		end if
    	end while
    
    case 76
    	inc(%n[$EVENT_NOTE])
    	%ID76[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel76[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[76]:=%n[$EVENT_NOTE]
    	while (%m[76]>1)
    		if (%vel76[%m[76]]>%vel76[%m[76]-1])
    			fade_out(%ID76[%m[76]-1], 1000*$fadeout, 1)
    			%ID76[%m[76]-1]:=%ID76[%m[76]]
    			%vel76[%m[76]-1]:=%vel76[%m[76]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[76])
    		else
    			dec(%m[76])
    		end if
    	end while
    
    case 77
    	inc(%n[$EVENT_NOTE])
    	%ID77[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel77[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[77]:=%n[$EVENT_NOTE]
    	while (%m[77]>1)
    		if (%vel77[%m[77]]>%vel77[%m[77]-1])
    			fade_out(%ID77[%m[77]-1], 1000*$fadeout, 1)
    			%ID77[%m[77]-1]:=%ID77[%m[77]]
    			%vel77[%m[77]-1]:=%vel77[%m[77]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[77])
    		else
    			dec(%m[77])
    		end if
    	end while
    
    case 78
    	inc(%n[$EVENT_NOTE])
    	%ID78[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel78[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[78]:=%n[$EVENT_NOTE]
    	while (%m[78]>1)
    		if (%vel78[%m[78]]>%vel78[%m[78]-1])
    			fade_out(%ID78[%m[78]-1], 1000*$fadeout, 1)
    			%ID78[%m[78]-1]:=%ID78[%m[78]]
    			%vel78[%m[78]-1]:=%vel78[%m[78]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[78])
    		else
    			dec(%m[78])
    		end if
    	end while
    
    case 79
    	inc(%n[$EVENT_NOTE])
    	%ID79[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel79[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[79]:=%n[$EVENT_NOTE]
    	while (%m[79]>1)
    		if (%vel79[%m[79]]>%vel79[%m[79]-1])
    			fade_out(%ID79[%m[79]-1], 1000*$fadeout, 1)
    			%ID79[%m[79]-1]:=%ID79[%m[79]]
    			%vel79[%m[79]-1]:=%vel79[%m[79]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[79])
    		else
    			dec(%m[79])
    		end if
    	end while
    
    case 80
    	inc(%n[$EVENT_NOTE])
    	%ID80[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel80[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[80]:=%n[$EVENT_NOTE]
    	while (%m[80]>1)
    		if (%vel80[%m[80]]>%vel80[%m[80]-1])
    			fade_out(%ID80[%m[80]-1], 1000*$fadeout, 1)
    			%ID80[%m[80]-1]:=%ID80[%m[80]]
    			%vel80[%m[80]-1]:=%vel80[%m[80]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[80])
    		else
    			dec(%m[80])
    		end if
    	end while
    
    case 81
    	inc(%n[$EVENT_NOTE])
    	%ID81[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel81[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[81]:=%n[$EVENT_NOTE]
    	while (%m[81]>1)
    		if (%vel81[%m[81]]>%vel81[%m[81]-1])
    			fade_out(%ID81[%m[81]-1], 1000*$fadeout, 1)
    			%ID81[%m[81]-1]:=%ID81[%m[81]]
    			%vel81[%m[81]-1]:=%vel81[%m[81]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[81])
    		else
    			dec(%m[81])
    		end if
    	end while
    
    case 82
    	inc(%n[$EVENT_NOTE])
    	%ID82[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel82[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[82]:=%n[$EVENT_NOTE]
    	while (%m[82]>1)
    		if (%vel82[%m[82]]>%vel82[%m[82]-1])
    			fade_out(%ID82[%m[82]-1], 1000*$fadeout, 1)
    			%ID82[%m[82]-1]:=%ID82[%m[82]]
    			%vel82[%m[82]-1]:=%vel82[%m[82]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[82])
    		else
    			dec(%m[82])
    		end if
    	end while
    
    case 83
    	inc(%n[$EVENT_NOTE])
    	%ID83[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel83[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[83]:=%n[$EVENT_NOTE]
    	while (%m[83]>1)
    		if (%vel83[%m[83]]>%vel83[%m[83]-1])
    			fade_out(%ID83[%m[83]-1], 1000*$fadeout, 1)
    			%ID83[%m[83]-1]:=%ID83[%m[83]]
    			%vel83[%m[83]-1]:=%vel83[%m[83]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[83])
    		else
    			dec(%m[83])
    		end if
    	end while
    
    case 84
    	inc(%n[$EVENT_NOTE])
    	%ID84[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel84[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[84]:=%n[$EVENT_NOTE]
    	while (%m[84]>1)
    		if (%vel84[%m[84]]>%vel84[%m[84]-1])
    			fade_out(%ID84[%m[84]-1], 1000*$fadeout, 1)
    			%ID84[%m[84]-1]:=%ID84[%m[84]]
    			%vel84[%m[84]-1]:=%vel84[%m[84]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[84])
    		else
    			dec(%m[84])
    		end if
    	end while
    
    case 85
    	inc(%n[$EVENT_NOTE])
    	%ID85[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel85[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[85]:=%n[$EVENT_NOTE]
    	while (%m[85]>1)
    		if (%vel85[%m[85]]>%vel85[%m[85]-1])
    			fade_out(%ID85[%m[85]-1], 1000*$fadeout, 1)
    			%ID85[%m[85]-1]:=%ID85[%m[85]]
    			%vel85[%m[85]-1]:=%vel85[%m[85]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[85])
    		else
    			dec(%m[85])
    		end if
    	end while
    
    case 86
    	inc(%n[$EVENT_NOTE])
    	%ID86[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel86[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[86]:=%n[$EVENT_NOTE]
    	while (%m[86]>1)
    		if (%vel86[%m[86]]>%vel86[%m[86]-1])
    			fade_out(%ID86[%m[86]-1], 1000*$fadeout, 1)
    			%ID86[%m[86]-1]:=%ID86[%m[86]]
    			%vel86[%m[86]-1]:=%vel86[%m[86]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[86])
    		else
    			dec(%m[86])
    		end if
    	end while
    
    case 87
    	inc(%n[$EVENT_NOTE])
    	%ID87[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel87[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[87]:=%n[$EVENT_NOTE]
    	while (%m[87]>1)
    		if (%vel87[%m[87]]>%vel87[%m[87]-1])
    			fade_out(%ID87[%m[87]-1], 1000*$fadeout, 1)
    			%ID87[%m[87]-1]:=%ID87[%m[87]]
    			%vel87[%m[87]-1]:=%vel87[%m[87]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[87])
    		else
    			dec(%m[87])
    		end if
    	end while
    
    case 88
    	inc(%n[$EVENT_NOTE])
    	%ID88[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel88[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[88]:=%n[$EVENT_NOTE]
    	while (%m[88]>1)
    		if (%vel88[%m[88]]>%vel88[%m[88]-1])
    			fade_out(%ID88[%m[88]-1], 1000*$fadeout, 1)
    			%ID88[%m[88]-1]:=%ID88[%m[88]]
    			%vel88[%m[88]-1]:=%vel88[%m[88]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[88])
    		else
    			dec(%m[88])
    		end if
    	end while
    
    case 89
    	inc(%n[$EVENT_NOTE])
    	%ID89[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel89[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[89]:=%n[$EVENT_NOTE]
    	while (%m[89]>1)
    		if (%vel89[%m[89]]>%vel89[%m[89]-1])
    			fade_out(%ID89[%m[89]-1], 1000*$fadeout, 1)
    			%ID89[%m[89]-1]:=%ID89[%m[89]]
    			%vel89[%m[89]-1]:=%vel89[%m[89]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[89])
    		else
    			dec(%m[89])
    		end if
    	end while
    
    case 90
    	inc(%n[$EVENT_NOTE])
    	%ID90[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel90[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[90]:=%n[$EVENT_NOTE]
    	while (%m[90]>1)
    		if (%vel90[%m[90]]>%vel90[%m[90]-1])
    			fade_out(%ID90[%m[90]-1], 1000*$fadeout, 1)
    			%ID90[%m[90]-1]:=%ID90[%m[90]]
    			%vel90[%m[90]-1]:=%vel90[%m[90]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[90])
    		else
    			dec(%m[90])
    		end if
    	end while
    
    case 91
    	inc(%n[$EVENT_NOTE])
    	%ID91[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel91[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[91]:=%n[$EVENT_NOTE]
    	while (%m[91]>1)
    		if (%vel91[%m[91]]>%vel91[%m[91]-1])
    			fade_out(%ID91[%m[91]-1], 1000*$fadeout, 1)
    			%ID91[%m[91]-1]:=%ID91[%m[91]]
    			%vel91[%m[91]-1]:=%vel91[%m[91]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[91])
    		else
    			dec(%m[91])
    		end if
    	end while
    
    case 92
    	inc(%n[$EVENT_NOTE])
    	%ID92[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel92[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[92]:=%n[$EVENT_NOTE]
    	while (%m[92]>1)
    		if (%vel92[%m[92]]>%vel92[%m[92]-1])
    			fade_out(%ID92[%m[92]-1], 1000*$fadeout, 1)
    			%ID92[%m[92]-1]:=%ID92[%m[92]]
    			%vel92[%m[92]-1]:=%vel92[%m[92]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[92])
    		else
    			dec(%m[92])
    		end if
    	end while
    
    case 93
    	inc(%n[$EVENT_NOTE])
    	%ID93[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel93[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[93]:=%n[$EVENT_NOTE]
    	while (%m[93]>1)
    		if (%vel93[%m[93]]>%vel93[%m[93]-1])
    			fade_out(%ID93[%m[93]-1], 1000*$fadeout, 1)
    			%ID93[%m[93]-1]:=%ID93[%m[93]]
    			%vel93[%m[93]-1]:=%vel93[%m[93]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[93])
    		else
    			dec(%m[93])
    		end if
    	end while
    
    case 94
    	inc(%n[$EVENT_NOTE])
    	%ID94[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel94[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[94]:=%n[$EVENT_NOTE]
    	while (%m[94]>1)
    		if (%vel94[%m[94]]>%vel94[%m[94]-1])
    			fade_out(%ID94[%m[94]-1], 1000*$fadeout, 1)
    			%ID94[%m[94]-1]:=%ID94[%m[94]]
    			%vel94[%m[94]-1]:=%vel94[%m[94]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[94])
    		else
    			dec(%m[94])
    		end if
    	end while
    
    case 95
    	inc(%n[$EVENT_NOTE])
    	%ID95[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel95[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[95]:=%n[$EVENT_NOTE]
    	while (%m[95]>1)
    		if (%vel95[%m[95]]>%vel95[%m[95]-1])
    			fade_out(%ID95[%m[95]-1], 1000*$fadeout, 1)
    			%ID95[%m[95]-1]:=%ID95[%m[95]]
    			%vel95[%m[95]-1]:=%vel95[%m[95]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[95])
    		else
    			dec(%m[95])
    		end if
    	end while
    
    case 96
    	inc(%n[$EVENT_NOTE])
    	%ID96[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel96[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[96]:=%n[$EVENT_NOTE]
    	while (%m[96]>1)
    		if (%vel96[%m[96]]>%vel96[%m[96]-1])
    			fade_out(%ID96[%m[96]-1], 1000*$fadeout, 1)
    			%ID96[%m[96]-1]:=%ID96[%m[96]]
    			%vel96[%m[96]-1]:=%vel96[%m[96]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[96])
    		else
    			dec(%m[96])
    		end if
    	end while
    
    case 97
    	inc(%n[$EVENT_NOTE])
    	%ID97[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel97[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[97]:=%n[$EVENT_NOTE]
    	while (%m[97]>1)
    		if (%vel97[%m[97]]>%vel97[%m[97]-1])
    			fade_out(%ID97[%m[97]-1], 1000*$fadeout, 1)
    			%ID97[%m[97]-1]:=%ID97[%m[97]]
    			%vel97[%m[97]-1]:=%vel97[%m[97]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[97])
    		else
    			dec(%m[97])
    		end if
    	end while
    
    case 98
    	inc(%n[$EVENT_NOTE])
    	%ID98[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel98[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[98]:=%n[$EVENT_NOTE]
    	while (%m[98]>1)
    		if (%vel98[%m[98]]>%vel98[%m[98]-1])
    			fade_out(%ID98[%m[98]-1], 1000*$fadeout, 1)
    			%ID98[%m[98]-1]:=%ID98[%m[98]]
    			%vel98[%m[98]-1]:=%vel98[%m[98]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[98])
    		else
    			dec(%m[98])
    		end if
    	end while
    
    case 99
    	inc(%n[$EVENT_NOTE])
    	%ID99[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel99[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[99]:=%n[$EVENT_NOTE]
    	while (%m[99]>1)
    		if (%vel99[%m[99]]>%vel99[%m[99]-1])
    			fade_out(%ID99[%m[99]-1], 1000*$fadeout, 1)
    			%ID99[%m[99]-1]:=%ID99[%m[99]]
    			%vel99[%m[99]-1]:=%vel99[%m[99]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[99])
    		else
    			dec(%m[99])
    		end if
    	end while
    
    case 100
    	inc(%n[$EVENT_NOTE])
    	%ID100[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel100[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[100]:=%n[$EVENT_NOTE]
    	while (%m[100]>1)
    		if (%vel100[%m[100]]>%vel100[%m[100]-1])
    			fade_out(%ID100[%m[100]-1], 1000*$fadeout, 1)
    			%ID100[%m[100]-1]:=%ID100[%m[100]]
    			%vel100[%m[100]-1]:=%vel100[%m[100]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[100])
    		else
    			dec(%m[100])
    		end if
    	end while
    
    case 101
    	inc(%n[$EVENT_NOTE])
    	%ID101[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel101[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[101]:=%n[$EVENT_NOTE]
    	while (%m[101]>1)
    		if (%vel101[%m[101]]>%vel101[%m[101]-1])
    			fade_out(%ID101[%m[101]-1], 1000*$fadeout, 1)
    			%ID101[%m[101]-1]:=%ID101[%m[101]]
    			%vel101[%m[101]-1]:=%vel101[%m[101]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[101])
    		else
    			dec(%m[101])
    		end if
    	end while
    
    case 102
    	inc(%n[$EVENT_NOTE])
    	%ID102[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel102[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[102]:=%n[$EVENT_NOTE]
    	while (%m[102]>1)
    		if (%vel102[%m[102]]>%vel102[%m[102]-1])
    			fade_out(%ID102[%m[102]-1], 1000*$fadeout, 1)
    			%ID102[%m[102]-1]:=%ID102[%m[102]]
    			%vel102[%m[102]-1]:=%vel102[%m[102]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[102])
    		else
    			dec(%m[102])
    		end if
    	end while
    
    case 103
    	inc(%n[$EVENT_NOTE])
    	%ID103[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel103[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[103]:=%n[$EVENT_NOTE]
    	while (%m[103]>1)
    		if (%vel103[%m[103]]>%vel103[%m[103]-1])
    			fade_out(%ID103[%m[103]-1], 1000*$fadeout, 1)
    			%ID103[%m[103]-1]:=%ID103[%m[103]]
    			%vel103[%m[103]-1]:=%vel103[%m[103]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[103])
    		else
    			dec(%m[103])
    		end if
    	end while
    
    case 104
    	inc(%n[$EVENT_NOTE])
    	%ID104[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel104[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[104]:=%n[$EVENT_NOTE]
    	while (%m[104]>1)
    		if (%vel104[%m[104]]>%vel104[%m[104]-1])
    			fade_out(%ID104[%m[104]-1], 1000*$fadeout, 1)
    			%ID104[%m[104]-1]:=%ID104[%m[104]]
    			%vel104[%m[104]-1]:=%vel104[%m[104]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[104])
    		else
    			dec(%m[104])
    		end if
    	end while
    
    case 105
    	inc(%n[$EVENT_NOTE])
    	%ID105[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel105[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[105]:=%n[$EVENT_NOTE]
    	while (%m[105]>1)
    		if (%vel105[%m[105]]>%vel105[%m[105]-1])
    			fade_out(%ID105[%m[105]-1], 1000*$fadeout, 1)
    			%ID105[%m[105]-1]:=%ID105[%m[105]]
    			%vel105[%m[105]-1]:=%vel105[%m[105]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[105])
    		else
    			dec(%m[105])
    		end if
    	end while
    
    case 106
    	inc(%n[$EVENT_NOTE])
    	%ID106[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel106[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[106]:=%n[$EVENT_NOTE]
    	while (%m[106]>1)
    		if (%vel106[%m[106]]>%vel106[%m[106]-1])
    			fade_out(%ID106[%m[106]-1], 1000*$fadeout, 1)
    			%ID106[%m[106]-1]:=%ID106[%m[106]]
    			%vel106[%m[106]-1]:=%vel106[%m[106]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[106])
    		else
    			dec(%m[106])
    		end if
    	end while
    
    case 107
    	inc(%n[$EVENT_NOTE])
    	%ID107[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel107[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[107]:=%n[$EVENT_NOTE]
    	while (%m[107]>1)
    		if (%vel107[%m[107]]>%vel107[%m[107]-1])
    			fade_out(%ID107[%m[107]-1], 1000*$fadeout, 1)
    			%ID107[%m[107]-1]:=%ID107[%m[107]]
    			%vel107[%m[107]-1]:=%vel107[%m[107]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[107])
    		else
    			dec(%m[107])
    		end if
    	end while
    
    case 108
    	inc(%n[$EVENT_NOTE])
    	%ID108[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel108[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[108]:=%n[$EVENT_NOTE]
    	while (%m[108]>1)
    		if (%vel108[%m[108]]>%vel108[%m[108]-1])
    			fade_out(%ID108[%m[108]-1], 1000*$fadeout, 1)
    			%ID108[%m[108]-1]:=%ID108[%m[108]]
    			%vel108[%m[108]-1]:=%vel108[%m[108]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[108])
    		else
    			dec(%m[108])
    		end if
    	end while
    
    case 109
    	inc(%n[$EVENT_NOTE])
    	%ID109[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel109[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[109]:=%n[$EVENT_NOTE]
    	while (%m[109]>1)
    		if (%vel109[%m[109]]>%vel109[%m[109]-1])
    			fade_out(%ID109[%m[109]-1], 1000*$fadeout, 1)
    			%ID109[%m[109]-1]:=%ID109[%m[109]]
    			%vel109[%m[109]-1]:=%vel109[%m[109]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[109])
    		else
    			dec(%m[109])
    		end if
    	end while
    
    case 110
    	inc(%n[$EVENT_NOTE])
    	%ID110[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel110[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[110]:=%n[$EVENT_NOTE]
    	while (%m[110]>1)
    		if (%vel110[%m[110]]>%vel110[%m[110]-1])
    			fade_out(%ID110[%m[110]-1], 1000*$fadeout, 1)
    			%ID110[%m[110]-1]:=%ID110[%m[110]]
    			%vel110[%m[110]-1]:=%vel110[%m[110]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[110])
    		else
    			dec(%m[110])
    		end if
    	end while
    
    case 111
    	inc(%n[$EVENT_NOTE])
    	%ID111[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel111[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[111]:=%n[$EVENT_NOTE]
    	while (%m[111]>1)
    		if (%vel111[%m[111]]>%vel111[%m[111]-1])
    			fade_out(%ID111[%m[111]-1], 1000*$fadeout, 1)
    			%ID111[%m[111]-1]:=%ID111[%m[111]]
    			%vel111[%m[111]-1]:=%vel111[%m[111]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[111])
    		else
    			dec(%m[111])
    		end if
    	end while
    
    case 112
    	inc(%n[$EVENT_NOTE])
    	%ID112[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel112[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[112]:=%n[$EVENT_NOTE]
    	while (%m[112]>1)
    		if (%vel112[%m[112]]>%vel112[%m[112]-1])
    			fade_out(%ID112[%m[112]-1], 1000*$fadeout, 1)
    			%ID112[%m[112]-1]:=%ID112[%m[112]]
    			%vel112[%m[112]-1]:=%vel112[%m[112]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[112])
    		else
    			dec(%m[112])
    		end if
    	end while
    
    case 113
    	inc(%n[$EVENT_NOTE])
    	%ID113[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel113[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[113]:=%n[$EVENT_NOTE]
    	while (%m[113]>1)
    		if (%vel113[%m[113]]>%vel113[%m[113]-1])
    			fade_out(%ID113[%m[113]-1], 1000*$fadeout, 1)
    			%ID113[%m[113]-1]:=%ID113[%m[113]]
    			%vel113[%m[113]-1]:=%vel113[%m[113]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[113])
    		else
    			dec(%m[113])
    		end if
    	end while
    
    case 114
    	inc(%n[$EVENT_NOTE])
    	%ID114[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel114[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[114]:=%n[$EVENT_NOTE]
    	while (%m[114]>1)
    		if (%vel114[%m[114]]>%vel114[%m[114]-1])
    			fade_out(%ID114[%m[114]-1], 1000*$fadeout, 1)
    			%ID114[%m[114]-1]:=%ID114[%m[114]]
    			%vel114[%m[114]-1]:=%vel114[%m[114]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[114])
    		else
    			dec(%m[114])
    		end if
    	end while
    
    case 115
    	inc(%n[$EVENT_NOTE])
    	%ID115[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel115[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[115]:=%n[$EVENT_NOTE]
    	while (%m[115]>1)
    		if (%vel115[%m[115]]>%vel115[%m[115]-1])
    			fade_out(%ID115[%m[115]-1], 1000*$fadeout, 1)
    			%ID115[%m[115]-1]:=%ID115[%m[115]]
    			%vel115[%m[115]-1]:=%vel115[%m[115]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[115])
    		else
    			dec(%m[115])
    		end if
    	end while
    
    case 116
    	inc(%n[$EVENT_NOTE])
    	%ID116[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel116[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[116]:=%n[$EVENT_NOTE]
    	while (%m[116]>1)
    		if (%vel116[%m[116]]>%vel116[%m[116]-1])
    			fade_out(%ID116[%m[116]-1], 1000*$fadeout, 1)
    			%ID116[%m[116]-1]:=%ID116[%m[116]]
    			%vel116[%m[116]-1]:=%vel116[%m[116]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[116])
    		else
    			dec(%m[116])
    		end if
    	end while
    
    case 117
    	inc(%n[$EVENT_NOTE])
    	%ID117[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel117[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[117]:=%n[$EVENT_NOTE]
    	while (%m[117]>1)
    		if (%vel117[%m[117]]>%vel117[%m[117]-1])
    			fade_out(%ID117[%m[117]-1], 1000*$fadeout, 1)
    			%ID117[%m[117]-1]:=%ID117[%m[117]]
    			%vel117[%m[117]-1]:=%vel117[%m[117]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[117])
    		else
    			dec(%m[117])
    		end if
    	end while
    
    case 118
    	inc(%n[$EVENT_NOTE])
    	%ID118[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel118[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[118]:=%n[$EVENT_NOTE]
    	while (%m[118]>1)
    		if (%vel118[%m[118]]>%vel118[%m[118]-1])
    			fade_out(%ID118[%m[118]-1], 1000*$fadeout, 1)
    			%ID118[%m[118]-1]:=%ID118[%m[118]]
    			%vel118[%m[118]-1]:=%vel118[%m[118]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[118])
    		else
    			dec(%m[118])
    		end if
    	end while
    
    case 119
    	inc(%n[$EVENT_NOTE])
    	%ID119[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel119[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[119]:=%n[$EVENT_NOTE]
    	while (%m[119]>1)
    		if (%vel119[%m[119]]>%vel119[%m[119]-1])
    			fade_out(%ID119[%m[119]-1], 1000*$fadeout, 1)
    			%ID119[%m[119]-1]:=%ID119[%m[119]]
    			%vel119[%m[119]-1]:=%vel119[%m[119]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[119])
    		else
    			dec(%m[119])
    		end if
    	end while
    
    case 120
    	inc(%n[$EVENT_NOTE])
    	%ID120[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel120[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[120]:=%n[$EVENT_NOTE]
    	while (%m[120]>1)
    		if (%vel120[%m[120]]>%vel120[%m[120]-1])
    			fade_out(%ID120[%m[120]-1], 1000*$fadeout, 1)
    			%ID120[%m[120]-1]:=%ID120[%m[120]]
    			%vel120[%m[120]-1]:=%vel120[%m[120]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[120])
    		else
    			dec(%m[120])
    		end if
    	end while
    
    case 121
    	inc(%n[$EVENT_NOTE])
    	%ID121[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel121[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[121]:=%n[$EVENT_NOTE]
    	while (%m[121]>1)
    		if (%vel121[%m[121]]>%vel121[%m[121]-1])
    			fade_out(%ID121[%m[121]-1], 1000*$fadeout, 1)
    			%ID121[%m[121]-1]:=%ID121[%m[121]]
    			%vel121[%m[121]-1]:=%vel121[%m[121]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[121])
    		else
    			dec(%m[121])
    		end if
    	end while
    
    case 122
    	inc(%n[$EVENT_NOTE])
    	%ID122[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel122[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[122]:=%n[$EVENT_NOTE]
    	while (%m[122]>1)
    		if (%vel122[%m[122]]>%vel122[%m[122]-1])
    			fade_out(%ID122[%m[122]-1], 1000*$fadeout, 1)
    			%ID122[%m[122]-1]:=%ID122[%m[122]]
    			%vel122[%m[122]-1]:=%vel122[%m[122]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[122])
    		else
    			dec(%m[122])
    		end if
    	end while
    
    case 123
    	inc(%n[$EVENT_NOTE])
    	%ID123[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel123[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[123]:=%n[$EVENT_NOTE]
    	while (%m[123]>1)
    		if (%vel123[%m[123]]>%vel123[%m[123]-1])
    			fade_out(%ID123[%m[123]-1], 1000*$fadeout, 1)
    			%ID123[%m[123]-1]:=%ID123[%m[123]]
    			%vel123[%m[123]-1]:=%vel123[%m[123]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[123])
    		else
    			dec(%m[123])
    		end if
    	end while
    
    case 124
    	inc(%n[$EVENT_NOTE])
    	%ID124[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel124[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[124]:=%n[$EVENT_NOTE]
    	while (%m[124]>1)
    		if (%vel124[%m[124]]>%vel124[%m[124]-1])
    			fade_out(%ID124[%m[124]-1], 1000*$fadeout, 1)
    			%ID124[%m[124]-1]:=%ID124[%m[124]]
    			%vel124[%m[124]-1]:=%vel124[%m[124]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[124])
    		else
    			dec(%m[124])
    		end if
    	end while
    
    case 125
    	inc(%n[$EVENT_NOTE])
    	%ID125[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel125[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[125]:=%n[$EVENT_NOTE]
    	while (%m[125]>1)
    		if (%vel125[%m[125]]>%vel125[%m[125]-1])
    			fade_out(%ID125[%m[125]-1], 1000*$fadeout, 1)
    			%ID125[%m[125]-1]:=%ID125[%m[125]]
    			%vel125[%m[125]-1]:=%vel125[%m[125]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[125])
    		else
    			dec(%m[125])
    		end if
    	end while
    
    case 126
    	inc(%n[$EVENT_NOTE])
    	%ID126[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel126[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[126]:=%n[$EVENT_NOTE]
    	while (%m[126]>1)
    		if (%vel126[%m[126]]>%vel126[%m[126]-1])
    			fade_out(%ID126[%m[126]-1], 1000*$fadeout, 1)
    			%ID126[%m[126]-1]:=%ID126[%m[126]]
    			%vel126[%m[126]-1]:=%vel126[%m[126]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[126])
    		else
    			dec(%m[126])
    		end if
    	end while
    
    case 127
    	inc(%n[$EVENT_NOTE])
    	%ID127[%n[$EVENT_NOTE]]:=$EVENT_ID
    	%vel127[%n[$EVENT_NOTE]]:=$EVENT_VELOCITY
    	%m[127]:=%n[$EVENT_NOTE]
    	while (%m[127]>1)
    		if (%vel127[%m[127]]>%vel127[%m[127]-1])
    			fade_out(%ID127[%m[127]-1], 1000*$fadeout, 1)
    			%ID127[%m[127]-1]:=%ID127[%m[127]]
    			%vel127[%m[127]-1]:=%vel127[%m[127]]
    			dec(%n[$EVENT_NOTE])
    			dec(%m[127])
    		else
    			dec(%m[127])
    		end if
    	end while
    
    end select
    end on

  2. #2

    Re: Updated script for K2 Self Mask

    Keep em` coming. I know these scripts willl be useful for developers and Piano enthusiasts. Good work, Rich

  3. #3

    Re: Updated script for K2 Self Mask


  4. #4

    Re: Updated script for K2 Self Mask

    What does it do?


    giga...

  5. #5

    Re: Updated script for K2 Self Mask

    Read first post :
    Description: If one repeated note is louder than previous ones,
    these ones are masked by this last one. So they are faded out.
    This can save polyphony.

  6. #6

    Re: Updated script for K2 Self Mask

    Xav
    here is the self mask code from PSR. You can add the declaration piece, this is just the logic. You are welcome to use this code , just mention my name please

    best regards
    Kornel

    Code:
    		$loop := 0
    		while ( $loop < $selfMaskBufferSize )
    			if( %selfMaskNote[ $loop ] = $EVENT_NOTE and %selfMaskVelocity[ $loop ] <= $EVENT_VELOCITY )
    				fade_out( %selfMaskId[ $loop ] , $FadeOut , 1 )
    				%selfMaskNote[ $loop ] := 0
    				%selfMaskId[ $loop ] := 0
    			end if
    			inc( $loop )
    		end while
    		if( %selfMaskId[ $selfMaskPtr ] > 0 )
    			fade_out( %selfMaskId[ $selfMaskPtr ] , $FadeOut , 1 )
    		end if
    		%selfMaskId[ $selfMaskPtr ] := $EVENT_ID
    		%selfMaskNote[ $selfMaskPtr ] := $EVENT_NOTE
    		%selfMaskVelocity[ $selfMaskPtr ] := $EVENT_VELOCITY
    		$selfMaskPtr := ( $selfMaskPtr + 1 ) mod $selfMaskBufferSize

  7. #7

    Re: Updated script for K2 Self Mask

    When I wrote mine, I tougth about something like this. There are 2 problems (IMO):
    - each time you hit a key, you have a "long" "while" loop working, even if it's unneeded.
    - if you choose $selfMaskBufferSize quite small to shorten the "while" loop, it can be good, but if it's too small, you can have problems with cancelled notes that shoudn't be masked when $selfMaskPtr restart to zero.

    Now this said, sure it's a very short script and when mine use 1% cpu, yours will use 2% with $selfMaskBufferSize equal to 512. So that's very very great.

  8. #8

    Re: Updated script for K2 Self Mask

    in the practical world "long" is nothing for a CPU
    think about how many new notes you play in 4-5 seconds, and how many notes die down naturally before that time, you will see that even <200 buffer may work for most cases

  9. #9

    Smile Re: Updated script for K2 Self Mask

    Thanks Xav and Kornel.. Regards, Rich

Go Back to forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •