- Volume changing
- Message system - Tempo changing - Save to clipboard
This commit is contained in:
@@ -5,12 +5,17 @@ function init()
|
||||
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
||||
notes = {"C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B "}
|
||||
pnotes = {"c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"}
|
||||
vcolor = { 1, 9, 5, 4, 6, 12, 14, 15}
|
||||
|
||||
piano_pos=18
|
||||
mousewait=0
|
||||
compas = 0
|
||||
compasos = {}
|
||||
volumens = {}
|
||||
volum = 4
|
||||
tempo = 4
|
||||
for i=0,1279 do compasos[i] = 108 end
|
||||
for i=0,1279 do volumens[i] = 4 end
|
||||
compasos[0] = 49
|
||||
compasos[1] = 49
|
||||
compasos[2] = 49
|
||||
@@ -20,6 +25,8 @@ function init()
|
||||
compasos[10] = 50
|
||||
|
||||
old_mouse_x,old_mouse_y = 0,0
|
||||
message_count = 255
|
||||
message_text = " HOLA"
|
||||
end
|
||||
|
||||
function update()
|
||||
@@ -72,7 +79,7 @@ function update()
|
||||
color(COLOR_BLACK, COLOR_LIGHT_GRAY+flr(oct%2))
|
||||
print("\003",7+i,10+11-(n-piano_pos))
|
||||
end
|
||||
color(COLOR_BLACK,COLOR_LIGHT_RED)
|
||||
color(COLOR_BLACK,vcolor[volumens[(compas*32)+i]])
|
||||
if i==31 or compasos[(compas*32)+i+1]~=n then
|
||||
print("\003",8+i,10+11-(n-piano_pos))
|
||||
else
|
||||
@@ -83,10 +90,11 @@ function update()
|
||||
|
||||
if mousex()>=8 and mousey()>=10 and mousey()<=21 then
|
||||
if mousebutton(1) then
|
||||
volumens[(compas*32)+mousex()-8] = volum
|
||||
compasos[(compas*32)+mousex()-8] = piano_pos+11-(mousey()-10)
|
||||
if old_mouse_x ~= mousex() or old_mouse_y ~= mousey() then
|
||||
local note = piano_pos+11-(mousey()-10)
|
||||
play("l4o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||
play("l4v"..volum.."o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||
end
|
||||
old_mouse_x,old_mouse_y = mousex(),mousey()
|
||||
else
|
||||
@@ -105,16 +113,64 @@ function update()
|
||||
end
|
||||
end
|
||||
|
||||
color(15,0)print("\143",0,0)
|
||||
color(14,0)print("\143",1,0)
|
||||
color(12,0)print("\143",2,0)
|
||||
color(6,0)print("\143",3,0)
|
||||
color(4,0)print("\143",4,0)
|
||||
color(5,4)print("\143",5,0)
|
||||
color(9,0)print("\143",6,0)
|
||||
color(1,0)print("\143",7,0)
|
||||
color(0,0)print("\143",8,0)
|
||||
if btn(KEY_LCTRL) and btnp(KEY_S) then
|
||||
local song = prepare_song(true)
|
||||
toclipboard(song)
|
||||
show_message("SAVED TO CLIPBOARD")
|
||||
end
|
||||
|
||||
-- if btn(KEY_LSHIFT) and btnp(KEY_L) then
|
||||
-- local song = prepare_song(true)
|
||||
-- toclipboard(song)
|
||||
-- show_message("SAVED TO CLIPBOARD")
|
||||
-- end
|
||||
|
||||
color(15,0)print("VOLUM:",0,0)
|
||||
color(1,0)print("\143",0,1)
|
||||
color(9,0)print("\143",1,1)
|
||||
color(5,4)print("\143",2,1)
|
||||
color(4,0)print("\143",3,1)
|
||||
color(6,0)print("\143",4,1)
|
||||
color(12,0)print("\143",5,1)
|
||||
color(14,0)print("\143",6,1)
|
||||
color(15,0)print("\143",7,1)
|
||||
color(15,0)print("\244",volum-1,2)
|
||||
|
||||
if mousex()<8 and mousey()==1 and mousebutton(1) then
|
||||
volum = mousex()+1
|
||||
end
|
||||
|
||||
if not mousedown and mousex()==20 and mousey()==1 and mousebutton(1) and tempo > 0 then
|
||||
tempo = tempo - 1
|
||||
mousedown = true
|
||||
end
|
||||
|
||||
if not mousedown and mousex()==24 and mousey()==1 and mousebutton(1) and tempo < 9 then
|
||||
tempo = tempo + 1
|
||||
mousedown = true
|
||||
end
|
||||
|
||||
if mousedown and not mousebutton(1) then
|
||||
mousedown = false
|
||||
end
|
||||
|
||||
color(15,0)print("TEMPO",20,0)
|
||||
print("\247 0 \246",20,1)
|
||||
print(tostr(tempo),22,1)
|
||||
|
||||
if message_count > 0 then
|
||||
message_color = 15
|
||||
if message_count < 18 then
|
||||
message_color = message_count>>1
|
||||
end
|
||||
color(message_color,0)print(message_text,0,26)
|
||||
message_count = message_count - 1
|
||||
end
|
||||
end
|
||||
|
||||
function show_message(text)
|
||||
message_count = 255
|
||||
message_text = text
|
||||
end
|
||||
|
||||
function search_song_end()
|
||||
@@ -124,6 +180,12 @@ function search_song_end()
|
||||
end
|
||||
|
||||
function play_song(entire_song)
|
||||
local song = prepare_song(entire_song)
|
||||
log(song)
|
||||
play(song)
|
||||
end
|
||||
|
||||
function prepare_song(entire_song)
|
||||
entire_song = entire_song or false
|
||||
local note_size = {1,2,3,4,6,8,12,16,24,32}
|
||||
local note_names = {"c","c#","d", "d#","e","f","f#","g","g#","a","a#","b"}
|
||||
@@ -131,10 +193,15 @@ function play_song(entire_song)
|
||||
|
||||
local current_note = 255
|
||||
local current_octave = 4
|
||||
local current_volume = 4
|
||||
|
||||
local p=compas*32
|
||||
local ends=32+compas*32
|
||||
|
||||
if tempo ~= 4 then
|
||||
song = "t"..tostr(tempo)
|
||||
end
|
||||
|
||||
if entire_song then
|
||||
p=0
|
||||
ends=search_song_end()
|
||||
@@ -142,8 +209,12 @@ function play_song(entire_song)
|
||||
|
||||
while p<ends do
|
||||
current_note = compasos[p]
|
||||
if volumens[p] ~= current_volume then
|
||||
current_volume = volumens[p]
|
||||
song=song.."v"..tostr(current_volume)
|
||||
end
|
||||
local d=0
|
||||
while d<32 and current_note == compasos[p] do d=d+1 p=p+1 end
|
||||
while d<32 and current_note == compasos[p] and current_volume == volumens[p] do d=d+1 p=p+1 end
|
||||
local o = flr(current_note/12)
|
||||
if o<9 and current_octave~=o then
|
||||
current_octave=o
|
||||
@@ -167,6 +238,6 @@ function play_song(entire_song)
|
||||
end
|
||||
end
|
||||
end
|
||||
log(song)
|
||||
play(song)
|
||||
|
||||
return song
|
||||
end
|
||||
Reference in New Issue
Block a user