-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.lua
More file actions
94 lines (74 loc) · 2.68 KB
/
plugin.lua
File metadata and controls
94 lines (74 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- draw() is the the entry point
function draw()
imgui.Begin("Record Keypresses")
-- Make long note sensitivity input
local ln_sens = get("ln_sens", 100)
_, ln_sens = imgui.InputInt("Long Note Sensitivity", ln_sens)
state.SetValue("ln_sens", ln_sens)
-- Make audio offset input
local aud_off = get("aud_off", -50)
_, aud_off = imgui.InputInt("Audio Offset", aud_off)
state.SetValue("aud_off", aud_off)
-- Debug
imgui.Text("Debug" .. tostring(ln_sens))
-- Make toggle recording button
local isRecording = get("isRecording", false)
if isRecording then
local stopRecordButton = imgui.Button("Stop Recording")
if stopRecordButton then
-- Stopped Recording
state.SetValue("isRecording", false)
end
else
local startRecordButton = imgui.Button("Start Recording")
if startRecordButton then
-- Started Recording!
-- Create new layer
actions.CreateLayer(utils.CreateEditorLayer("Recorded Layer"))
state.SetValue("isRecording", true)
end
end
-- Recording!
if isRecording then
-- Check Key Presses
local column_keys = {
[keys.D] = 1,
[keys.F] = 2,
[keys.J] = 3,
[keys.K] = 4
}
for key, column in pairs(column_keys) do
-- Save that key was pressed
if utils.IsKeyPressed(key) then
state.SetValue("pressed" .. tostring(key), state.SongTime)
end
-- Check that key was released
if utils.IsKeyReleased(key) then
-- Get time that key was pressed
local startTime = get("pressed" .. tostring(key), -1)
local timeDiff = state.SongTime - startTime
if timeDiff > ln_sens then
-- Making a long note
actions.PlaceHitObject(utils.CreateHitObject(
startTime + aud_off,
column,
state.SongTime + aud_off
)
)
else
-- Making a short note
actions.PlaceHitObject(utils.CreateHitObject(
startTime + aud_off,
column
)
)
end
end
end
end
imgui.End()
-- Create window with option to start recording, long note sensitivity
end
function get(identifier, defaultValue)
return state.GetValue(identifier) or defaultValue
end