TONE_LOW = "\001" TONE_HIGH = "\255" happy_birthday = {262,0.5,262,0.5,294,1,262,1,349,1,330,2,262,0.5,262,0.5,294,1,262,1,392,1,349,2,262,0.5,262,0.5,523,1,440,1,349,1,330,1,294,3,466,1,466,1,440,1,349,1,392,1,349,2} function freq_key(key) --return 440 * math.pow(2, (key-49)/12) return key end function keytone(key) local am = 57600/freq_key(key) return TONE_HIGH:rep(am) .. TONE_LOW:rep(am) end function key_am(key, ammount) print(ammount) return keytone(key):rep(ammount) end function key_time(key, time) return key_am(key, freq_key(key)*time) end function play() local out = "" for i=1,#happy_birthday,2 do out = out..key_time(happy_birthday[i]*5, happy_birthday[i+1]/10) end print(out) end function on.timer() play() timer.stop() end function on.paint(gc) timer.start(1) end