Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require'audio'
- m = m or {}
- m.delay = function(n)
- local ct = os.clock()
- while os.clock() <= ct + n do end
- return true
- end
- m.play = function()
- io.write('\a-')
- end
- m.metronome = function(s)
- s = 60 / s
- while true do
- m.play()
- m.delay(s)
- end
- end
- local w = function(...)
- f:write(..., '\n')
- end
- m.new = function(file, r, tempo)
- r = tostring(r)
- tempo = tempo or 60
- file = file .. '.rtm'
- local f = io.open(file, 'w')
- f:write('require\'music\'\n')
- f:write('local rstr = \'' .. r .. '\'\n')
- f:write('local tempo = ' .. tempo .. '\n')
- f:write([[local play = function()
- for k = 1, #rstr do
- if rstr.sub(rstr, k, k) == '1' then
- play(12, 60 / tempo)
- io.write('-')
- else
- io.write('_')
- m.delay(60 / tempo)
- end
- end
- end]])
- f:write('\nplay()')
- f:close()
- end
- m.anew = function(file, r, tempo)
- r = string.lower(tostring(r))
- tempo = tempo or 60
- file = file .. '.artm'
- local f = io.open(file, 'w')
- f:write('require\'music\'\n')
- f:write('local rstr = \'' .. r .. '\'\n')
- f:write('local tempo = ' .. tempo .. '\n')
- f:write([[local play = function()
- for k = 1, #rstr do
- if rstr.sub(rstr, k, k) == 'r' then
- play(12, 60 / tempo)
- else
- play(0, 60 / tempo)
- end
- end
- end]])
- f:write('\nplay()')
- f:close()
- end
Advertisement
Add Comment
Please, Sign In to add comment