-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathorgn.lua
105 lines (84 loc) · 2.53 KB
/
orgn.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
-- ====== ====== ====== == =
-- = = = = = = = =
-- = = ====== = == = = =
-- ====== = = ====== = ==
--
-- a 3-operator FM synth with
-- fx. inspired by yamaha
-- portasound keyboards
--
-- version 1.1 @andrew
-- https://norns.community/
-- authors/andrew/orgn
--
-- K1-K2: page focus
-- E1-E3: various
--
-- required: midi keyboard
-- or grid
--
-- grid documentation available
-- on norns.community
--global variables
pages = 3 --you can add more pages here for the norns encoders
--adjust these variables for midigrid / nonvari grids
g = grid.connect()
grid_width = (g and g.device and g.device.cols >= 16) and 16 or 8
varibright = (g and g.device and g.device.cols >= 16) and true or false
--external libs
tab = require 'tabutil'
cs = require 'controlspec'
mu = require 'musicutil'
pattern_time = require 'pattern_time'
--git submodule libs
nest = include 'lib/nest/core'
Key, Enc = include 'lib/nest/norns'
Text = include 'lib/nest/text'
Grid = include 'lib/nest/grid'
multipattern = include 'lib/nest/util/pattern-tools/multipattern'
of = include 'lib/nest/util/of'
to = include 'lib/nest/util/to'
PatternRecorder = include 'lib/nest/examples/grid/pattern_recorder'
tune, Tune = include 'orgn/lib/tune/tune'
tune.setup { presets = 8, scales = include 'orgn/lib/tune/scales' }
--script lib files
orgn, orgn_gfx = include 'orgn/lib/orgn' --engine params & graphics
demo = include 'orgn/lib/demo' --egg
Orgn = include 'orgn/lib/ui' --nest v2 UI components (norns screen / grid)
map = include 'orgn/lib/params' --create script params
m = include 'orgn/lib/midi' --midi keyboard input
engine.name = "Orgn"
--set up global patterns
function pattern_time:resume()
if self.count > 0 then
self.prev_time = util.time()
self.process(self.event[self.step])
self.play = 1
self.metro.time = self.time[self.step] * self.time_factor
self.metro:start()
end
end
pattern, mpat = {}, {}
for i = 1,5 do
pattern[i] = pattern_time.new()
mpat[i] = multipattern.new(pattern[i])
end
--set up nest v2 UI
local _app = {
grid = Orgn.grid{ wide = grid_width > 8, varibright = varibright },
norns = Orgn.norns(),
}
nest.connect_grid(_app.grid, g, 240)
nest.connect_enc(_app.norns)
nest.connect_key(_app.norns)
nest.connect_screen(_app.norns, 24)
--init/cleanup
function init()
orgn.init()
params:read()
params:set('demo start/stop', 0)
params:bang()
end
function cleanup()
params:write()
end