Technical Note of "Split/Merge AudioVisual" 2
Artist: Kenji Kojima Technical Note 1, 2, 3   This note is under CC License BY-NC-SA 3.0

index@kenjikojima.com


Please consider making a donation to support Kenji Kojima's works
Converting numbers to musical notes
You can use a library "makeSMF" for converting numbers to musical notes. It's downloaded from "http://udimac.web.fc2.com/stack/tool.html". Copy and paste the button "makeSmfLib" onto the fist card of the stack project. The library must be inserted the script into front when the stack is opened.

	
on openStack
    insert the script of btn "makeSmfLib" into front
end openStack

You do not need to know details of the library "makeSMF". But it plays a video clip file by QuickTime automatically, then you have to modify the script. Open the script of "makeSMF", and block some lines.

on playPmd notes, playTempo, instNum
   put specialFolderPath( "Temporary" ) & "/playPmdTemp.mid" into tempFilePath
   
   
-- block the script. You do not need for the videoclip script. 
-- a midi file is made into specialFolderPath("Temporary"). 
/*
   if ( notes is "stop" ) or ( notes is "clear" ) then
      try
         play stop vc tempFilePath
      end try
      if notes is "clear" then
         delete file tempFilePath
      end if
      setPlayBtn false
   else
      try
         stop playing vc tempFilePath
      end try
*/
	
-- You need this line. 
makeSMF notes, playTempo, instNum, tempFilePath
      
     
/*  
      play vc tempFilePath
      if the result contains "no" then
         put the result &return& "Requestment QuickTime3" into aMsg
         answer aMsg
         playPmd "clear"
         exit playPmd
      end if
      setPlayBtn true
      checkPlayEnd
   end if
*/
end playPmd

Making midi script of makeSMF is a little complicated. Therefore I would like to skip explanation details of them. I used only music note numbers and the length of musical note. We already have image "pix1" numbers (random numbers key) and image "pix2" numbers (ciphered mosaic image). Now I only use image "pix1" numbers. However the numbers are RGB values then I have to make them a half of the value. RGB Values assigned 0 to 255, but musical notes is 0 to 127. About a half of the numbers are odd numbers and others are even numbers. When I convert musical notes to RGB values, I have to know the differences. I would like to add the note length of them. "e" is a quarter note and "s" is an eighth note of MakeSMF script. You remember 60 is the middle C of the scale. Make a player "music1". It will play a music.

on mouseUp
   put "140 11 217 190 84 123 238 209 186 136 105 66 246 63 219 208 156 212 213 240 118 165 235 236 249 " & \ 
	"73 125 198 230 46 34 204 229 176 114 85 90 155 39 102 16 179 168 81 31 110 95 155 " into tNumbers
   put evenOddScore(tNumbers) into tScore

   -- "playPmd" is a command creating midi file in makeSMF
   -- the 1st parameter is the score, 2nd is the tempo, 3rd is instrumental number "1" is piano
   playPmd tScore, 120, 1
   set the filename of player "music1" to specialFolderPath( "Temporary" ) & "/playPmdTemp.mid" 	
end mouseUp

function evenOddScore pNum
   repeat for each word tWord in pNum
      if tWord mod 2 is 1 then
         -- tWord is odd number, a quater note
         put tWord div 2 & "e" & space after tScore
      else
         -- tWord is even number, an eighth note
         put tWord div 2 & "s" & space after tScore
      end if
   end repeat
   return tScore
end evenOddScore


Created a midi music file
This mp3 file of "music1" was converted from a midi file.
The original midi file is here. But the recent web browser can not play a midi music.





Technical Note 1, 2, 3