-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprefs.lua
More file actions
44 lines (36 loc) · 1.16 KB
/
prefs.lua
File metadata and controls
44 lines (36 loc) · 1.16 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
Prefs = {}
-- return a new Prefs instance
-- kicks off all the Renoise preference tooling and
-- loads stored preferences into the global STATE
function Prefs:new()
self.options = renoise.Document.create("HWSamplerPreferences") {
midi_device_index = 1
}
renoise.tool().preferences = self.options
-- load options into state
STATE.midi_device_index = self.options.midi_device_index.value
return self
end
-- reads saved preferences.
-- default argument required and is used (and saved) if
-- the preference doesn't exist
function Prefs:read(pref, default)
local value = nil
if self.options[tostring(pref)] then
value = self.options[tostring(pref)].value
else
self:write(pref, default)
value = default
end
return value
end
-- writes or updates prefernces for later recall
function Prefs:write(pref, value)
-- if the setting exists, update its value
if self.options[tostring(pref)] then
self.options[tostring(pref)].value = value
-- if the settind doesn't exist yet, save it.
else
self.options[tostring(pref)] = value
end
end