This repository has been archived by the owner on Aug 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
xEnvelope.lua
88 lines (58 loc) · 2.37 KB
/
xEnvelope.lua
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
--[[===============================================================================================
xEnvelope
===============================================================================================]]--
--[[--
A virtual representation of an envelope (automation, LFO or otherwise)
.
#
Note: the class is modelled over the Renoise EnvelopeSelectionContent,
]]
--=================================================================================================
cLib.require(_clibroot.."cPersistence")
---------------------------------------------------------------------------------------------------
class 'xEnvelope' (cPersistence)
xEnvelope.__PERSISTENCE = {
"points"
}
---------------------------------------------------------------------------------------------------
function xEnvelope:__init()
TRACE("xEnvelope:__init()")
-- the point values - array of {
-- time, -- point time
-- value, -- point value
-- playmode, -- interpolation type (renoise.PatternTrackAutomation.PLAYMODE_XX)
-- }
self.points = {}
-- number, the amount of lines covered if envelope was applied to a pattern
self.number_of_lines = property(self._get_number_of_lines)
end
---------------------------------------------------------------------------------------------------
-- check if the automation specifies any points
-- (shared interface with xEnvelope)
-- @return boolean
function xEnvelope:has_points()
TRACE("xEnvelope:has_points()")
return (#self.points > 0)
end
---------------------------------------------------------------------------------------------------
-- amount of lines covered if envelope was applied to a pattern
-- @return number
function xEnvelope:_get_number_of_lines()
TRACE("xEnvelope:_get_number_of_lines()")
if table.is_empty(self.points) then
return 0
end
local last_time = self.points[#self.points].time
return cLib.round_value(last_time-1)
end
---------------------------------------------------------------------------------------------------
function xEnvelope:__tostring()
return type(self)
.. ",#points=" .. tostring(#self.points)
end
--=================================================================================================
-- Static methods
--=================================================================================================
--[[
TODO: common methods such as shift, mirror, etc.
]]