Code: Song = {} RenderSong = {} note=nil for i, side in pairs(rs.getSides()) do if peripheral.getType(side) == "note" then note = peripheral.wrap(side) break end end function string:split(delimiter) local result = { } local from = 1 local delim_from, delim_to = string.find( self, delimiter, from ) while delim_from do table.insert( result, string.sub( self, from , delim_from-1 ) ) from = delim_to + 1 delim_from, delim_to = string.find( self, delimiter, from ) end table.insert( result, string.sub( self, from ) ) return result end function Song.getNote(self, column) return Song[column] end file = fs.open("song","r") local line = file.readLine() repeat table.insert(RenderSong,line) line = file.readLine() until line == nil file.close() x=0 while x <= table.getn(RenderSong) do if ( RenderSong[x] ~= nil ) then have = string.split(RenderSong[x],",") if have[1]~="p" then if table.getn(have)==1 then instr = 4 notez = math.floor(((tonumber(have[1])/12)*24)) else instr = tonumber(have[1]) notez = tonumber(have[2]) end note.playNote(instr,notez) end end x=x+1 sleep(0.4) end Example Songs Mary had a little lamb Code: 3 2 1 2 3 3 3 p 2 2 2 p 3 9 9 p 3 2 1 2 3 3 3 p 3 2 2 3 2 1 Pirates of the Carribean? Code: 3 5 6 6 p 6 7 8 8 p 8 9 7 7 p 6 5 5 6 p 3 5 6 6 p 6 7 8 8 p 8 9 7 7 p 6 5 6
Now let's make another program, not on computer craft at all, on your own real-life computer, to convert midi files into this special format!