Skip to content

Commit

Permalink
- NEW BPM now goes up to 480. Rage.
Browse files Browse the repository at this point in the history
- NEW Parameter for "popup patience."
- NEW Disconnecting grid no longer freezes playback.
- FIX Hives and raves with `0` metabolism no longer freeze playback.
- FIX `Cell:has()` properly navel-gazes.
- FIX Harden `s:one_shot()` logic.
  • Loading branch information
tyleretters committed Sep 1, 2020
1 parent b04cefd commit 4f046cd
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 151 deletions.
2 changes: 1 addition & 1 deletion arcologies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--
--
-- ........................................
-- v1.0.2
-- v1.0.3
-- <3 @tyleretters
-- nor.the-rn.info
-- GNU GPL v3.0
Expand Down
12 changes: 8 additions & 4 deletions lib/Cell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Cell:is(name)
end

function Cell:has(name)
return fn.table_find(self.structure_attribute_map[self.structure_value], name) ~= nil or false
return tonumber(fn.table_find(self.structure_attribute_map[self.structure_value], name)) ~= nil and true or false
end

function Cell:change(name)
Expand Down Expand Up @@ -119,13 +119,14 @@ behaviors encapsulated in their own classes. and as of writing this
theres only ~40 lines of code below...
]]

-- somtimes when a cell changes, attributes need to be cleaned up
-- sometimes when a cell changes, attributes need to be cleaned up
function Cell:change_checks()
if self:is("SHRINE") then self:setup_notes(1) end
if self:is("TOPIARY") then self:setup_notes(8) end
if self:is("CASINO") then self:setup_notes(8) end
if self:is("FOREST") then self:setup_notes(8) end
self:set_max_state_index(self:is("CRYPT") and 6 or 8)
if self:is("CRYPT") then self:set_state_index(1) end
self:cycle_state_index(0)
end

Expand All @@ -137,8 +138,10 @@ function Cell:is_spawning()
return self.turing[fn.cycle((counters.this_beat() - self.offset) % self.metabolism, 0, self.metabolism)]
elseif self:is("SOLARIUM") and self.flag then
return true
elseif (((counters.this_beat() - self.offset) % self.metabolism) == 1 and self.metabolism ~= 0) or self.metabolism == 1 then
if self:is("HIVE") or self:is("RAVE") then
elseif self:is("HIVE") or self:is("RAVE") then
if self.metabolism == 0 then
return false
elseif (((counters.this_beat() - self.offset) % self.metabolism) == 1 and self.metabolism ~= 0) or self.metabolism == 1 then
return true
end
end
Expand All @@ -161,6 +164,7 @@ function Cell:teardown()
end
end

-- for solariums
function Cell:compare_capacity_and_charge()
if self.charge >= self.capacity then
self.flag = true
Expand Down
2 changes: 1 addition & 1 deletion lib/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config = {}
config["settings"] = {
["version_major"] = 1,
["version_minor"] = 0,
["version_patch"] = 2,
["version_patch"] = 3,
["playback"] = 0,
["length"] = 16,
["root"] = 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/counters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function counters.optician()
if counters.ui.frame % 4 == 0 then
counters.ui.quarter_frame = counters.ui.quarter_frame +1
end
if fn.no_grid() and not g.disconnect_dismissed then page:set_error(1) else page:clear_error() end
if not g.disconnect_dismissed then page:set_error(1) else page:clear_error() end
fn.dirty_screen(true)
redraw()
end
Expand Down
140 changes: 10 additions & 130 deletions lib/dev.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@ end
function dev:scene(i)

if i == 1 then
page:select(3)
page:select(2)
menu:select_item(4)
keeper:select_cell(4, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:open_port("w")
keeper:deselect_cell()
-- keeper:deselect_cell()
params:set("bpm", 120)

elseif i == 2 then
sound:set_random_root()
sound:set_random_scale()
keeper:select_cell(4, 1)
keeper.selected_cell:open_port("s")
keeper:select_cell(4, 4)
keeper.selected_cell:change("AVIARY")
keeper.selected_cell:open_port("n")
-- keeper.selected_cell:change("FOREST")
-- keeper.selected_cell:open_port("n")
-- keeper:select_cell(4, 1)
-- keeper.selected_cell:open_port("s")

-- keeper.selected_cell:open_port("e")
-- keeper.selected_cell:open_port("s")
-- keeper.selected_cell:open_port("w")
Expand All @@ -52,133 +53,12 @@ function dev:scene(i)
keeper.selected_cell:open_port("w")

page:select(2)




elseif i == 4 then
-- fn.seed_cells()
-- params:set("seed", 4)
-- fn.seed_cells()
page:select(4)

elseif i == 10 then
-- ode to joy
params:set("bpm", 240)
sound:set_scale(47)
page:select(2)
keeper:select_cell(1, 4)
keeper.selected_cell:open_port("e")
keeper.selected_cell:set_metabolism(16)

keeper:select_cell(5, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(65) -- yeah these are very wrong


keeper:select_cell(6, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(65) -- yeah these are very wrong

keeper:select_cell(7, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(66) -- yeah these are very wrong

keeper:select_cell(8, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(68) -- yeah these are very wrong

keeper:select_cell(9, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(68) -- yeah these are very wrong

keeper:select_cell(10, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(66) -- yeah these are very wrong

keeper:select_cell(11, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(65) -- yeah these are very wrong

keeper:select_cell(12, 4)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(63) -- yeah these are very wrong

keeper:select_cell(12, 5)
keeper.selected_cell:open_port("n")
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(61) -- yeah these are very wrong

keeper:select_cell(11, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(61) -- yeah these are very wrong

keeper:select_cell(10, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(63) -- yeah these are very wrong

keeper:select_cell(9, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(65) -- yeah these are very wrong

keeper:select_cell(8, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(65) -- yeah these are very wrong

keeper:select_cell(7, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(63) -- yeah these are very wrong

keeper:select_cell(6, 5)
keeper.selected_cell:open_port("w")
keeper.selected_cell:open_port("e")
keeper.selected_cell:open_port("s")
keeper.selected_cell:change("SHRINE")
keeper.selected_cell:set_note(63) -- yeah these are very wrong

keeper:deselect_cell()

fn.seed_cells()
page:select(3)
sound:toggle_playback()

else
print('else block')
Expand Down
4 changes: 2 additions & 2 deletions lib/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ function fn.id()
end

function fn.grid_width()
return g.cols
return g.last_known_width
end

function fn.grid_height()
return g.rows
return g.last_known_height
end

function fn.index(x, y)
Expand Down
4 changes: 4 additions & 0 deletions lib/g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function g.init()
g.is_pasting = false
g.paste_counter = 15
g.disconnect_dismissed = true
g.last_known_width = g.cols
g.last_known_height = g.rows
for x = 1, fn.grid_width() do
g.counter[x] = {}
for y = 1, fn.grid_height() do
Expand All @@ -23,6 +25,8 @@ end

function grid.add()
g.init()
g.last_known_width = g.cols
g.last_known_height = g.rows
fn.dirty_grid(true)
end

Expand Down
1 change: 0 additions & 1 deletion lib/graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function graphics.init()
graphics.structure_y = 24
graphics.total_cells = fn.grid_height() * fn.grid_width()
graphics.analysis_pixels = {}
graphics.ui_wait_threshold = 0.5
graphics.cell_attributes = config.attributes
graphics.splash_lines_open = {}
graphics.splash_lines_close = {}
Expand Down
8 changes: 7 additions & 1 deletion lib/parameters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function parameters.init()

parameters.bpm_to_seconds = 0
params:add{ type = "number", id = "bpm", name = "BPM",
min = 20, max = 240, default = 120,
min = 20, max = 480, default = 120,
action = function(i) parameters.bpm_to_seconds = 60 / i end
}
params:hide("bpm")
Expand All @@ -25,6 +25,12 @@ function parameters.init()
params:add_option("crypts_directory", "CRYPT(S)", filesystem.crypts_names, 1)
params:set_action("crypts_directory", function(index) filesystem:set_crypt(index) end)


params:add{ type = "number", id = "popup_patience", name = "POPUP PATIENCE",
min = 0.5, max = 4.0, default = 0.5,
}


parameters.is_splash_screen_on = true
params:add_option("splash_screen", "SPLASH SCREEN", {"ENABLED", "DISABLED"})
params:set_action("splash_screen", function(index) parameters.is_splash_screen_on = index == 1 and true or false end)
Expand Down
2 changes: 1 addition & 1 deletion lib/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ end

function popup:enc_wait()
enc_counter[popup.number]["waiting"] = true
clock.sleep(graphics.ui_wait_threshold)
clock.sleep(params:get("popup_patience"))
enc_counter[popup.number]["waiting"] = false
enc_counter[popup.number]["this_clock"] = nil
popup:done()
Expand Down
18 changes: 10 additions & 8 deletions lib/softcut.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ end

function s:one_shot(index, level)
local voice = index -- voices are hard-coupled for now
softcut.buffer(voice, 2)
softcut.play(voice, 0)
softcut.level(voice, level)
softcut.position(voice, s.clip[index].min)
softcut.loop_start(voice, s.clip[index].min)
softcut.loop_end(voice, s.clip[index].max)
softcut.loop(voice, 0)
softcut.play(voice, 1)
if tonumber(index) then -- some edge cases were happening where nil indexes were coming in
softcut.buffer(voice, 2)
softcut.play(voice, 0)
softcut.level(voice, level)
softcut.position(voice, s.clip[index].min)
softcut.loop_start(voice, s.clip[index].min)
softcut.loop_end(voice, s.clip[index].max)
softcut.loop(voice, 0)
softcut.play(voice, 1)
end
end

return s
3 changes: 2 additions & 1 deletion lib/traits/notes_trait.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ notes_trait.init = function(self)
end

self.set_note = function(self, note, index)
self.notes[index] = note
local i = index ~= nil and index or 1
self.notes[i] = note
self.callback('set_note')
end

Expand Down

0 comments on commit 4f046cd

Please sign in to comment.