Skip to content

Commit 16ca29b

Browse files
committed
Introduce effects.
Configure the Sweep effect in the UI.
1 parent 7fdbdb0 commit 16ca29b

File tree

11 files changed

+1545
-364
lines changed

11 files changed

+1545
-364
lines changed

tiny-cli/src/main/resources/sfx/editor.ldtk

Lines changed: 689 additions & 334 deletions
Large diffs are not rendered by default.

tiny-cli/src/main/resources/sfx/sfx-editor.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,31 @@ function _init()
142142
table.insert(m.widgets, button)
143143
end
144144

145+
for mode in all(entities["Checkbox"]) do
146+
local button = widgets:create_checkbox(mode)
147+
table.insert(m.widgets, button)
148+
end
149+
150+
for effect in all(entities["Sweep"]) do
151+
local active = wire.find_widget(m.widgets, effect.fields.Enabled)
152+
local acceleration = wire.find_widget(m.widgets, effect.fields.Acceleration)
153+
local sweep = wire.find_widget(m.widgets, effect.fields.Sweep)
154+
155+
wire.produce_to(active, { "value" }, state, { "instrument", "sweep", "active" })
156+
wire.consume_on_update(active, { "value" }, state, { "instrument", "sweep", "active" })
157+
158+
wire.produce_to(acceleration, { "value" }, state, { "instrument", "sweep", "acceleration" })
159+
wire.consume_on_update(acceleration, { "value" }, state, { "instrument", "sweep", "acceleration" })
160+
161+
wire.produce_to(sweep, { "value" }, state, { "instrument", "sweep", "frequency" }, function(source, target, value)
162+
return juice.pow2(200, 2000, value)
163+
end)
164+
wire.consume_on_update(sweep, { "value" }, state, { "instrument", "sweep", "frequency" }, function(source, target, value)
165+
return (value - 200) / (2000 - 200)
166+
end)
167+
168+
end
169+
145170
-- force setting correct values
146171
if (state.on_change) then
147172
state:on_change()

0 commit comments

Comments
 (0)