-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnap8th.lua
More file actions
44 lines (36 loc) · 1 KB
/
Snap8th.lua
File metadata and controls
44 lines (36 loc) · 1 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
SCRIPT_TITLE = "Set selected notes to 8th note length"
function getClientInfo()
return {
name = SV:T(SCRIPT_TITLE),
author = "lag129",
versionNumber = 1,
minEditorVersion = 68354
}
end
function getTranslations(langCode)
if langCode == "ja-jp" then
return {
{ SCRIPT_TITLE, "選択したノートを8分音符にクオンタイズ" }
}
end
return {}
end
function main()
local selection = SV:getMainEditor():getSelection()
local selectedNotes = selection:getSelectedNotes()
if #selectedNotes == 0 then
SV:finish()
return
end
local timeAxis = SV:getProject():getTimeAxis()
for i = 1, #selectedNotes do
local note = selectedNotes[i]
local currentOnset = note:getOnset()
local tempoMark = timeAxis:getTempoMarkAt(currentOnset)
local bpm = tonumber(tempoMark.bpm)
local currentBar = ((60 / bpm) * 4) / 8
local currentBarBlick = timeAxis:getBlickFromSeconds(currentBar)
selectedNotes[i]:setDuration(currentBarBlick)
end
SV:finish()
end