Advertisement
Guest User

marktobin.lua

a guest
May 5th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. local sh = require('shell')
  2. local fs = require('filesystem')
  3. local args, opts = sh.parse( ... )
  4.  
  5. local note = require('note')
  6.  
  7. -- version 1
  8.  
  9. local infile = io.open(sh.resolve(args[1]), "r")
  10. local outfile = fs.open(sh.resolve(args[2]), "wb")
  11.  
  12. local dict = {['c']= 118,
  13. ['S']= 100,
  14. ['a']= 130,
  15. ['d']= 131,
  16. ['s']= 132,
  17. ['r']= 133,
  18. ['v']= 155,
  19. ['i']= 144,
  20. ['G']= 0,
  21. ['R']= 2,
  22. ['N']= 3,
  23. ['B']= 4 }
  24. local dict2 = {['R']=2, ['N']=3, ['B']=4}
  25.  
  26. for line in infile:lines() do
  27.   print(line)
  28.   for command in string.gmatch(line, "([^ ]+)") do
  29.     for wor, defin in pairs(dict) do
  30.       if string.sub(command, 1, 1) == wor then
  31.         print('benis')
  32.         outfile:write(string.pack("<B", defin))
  33.  
  34.         if not dict2[wor] then
  35.           outfile:write(string.pack("<I1", tonumber(string.sub(command, 2))))
  36.         else
  37.           outfile:write(string.pack("<I1",note.midi(string.sub(command, 2))))
  38.         end
  39.       end
  40.     end
  41.   end
  42. end
  43.  
  44. for i=1,16 do
  45.   outfile:write("<B", 127)
  46. end
  47.  
  48. infile:close()
  49. outfile:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement