- tools/musicator:\n - markov model generator and pattern generator operational\n- DDR sound generation in-progress
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
mr.one
2026-03-20 20:18:10 +01:00
parent d899a74411
commit 46d3ff2ebc
8 changed files with 1274 additions and 94 deletions

View File

@@ -162,3 +162,43 @@ Songs.custom_song = {
}, 130)
}
]]
function generate_sequence(model_data, length)
local order = model.order
local model_data = model_data.model
-- random start key
local model_keys = {}
for k,_ in pairs(model) do
model_keys[#model_keys + 1] = k
end
local start_key = model_keys[math.ceil(math.random() * #model_keys)]
-- sequence starts with the start key
local seq = unmake_key(start_key)
-- generation loop
while #seq < length do
local current_key = table.concat({unpack(seq, #seq - order + 1, #seq)}, "|")
local chosen = "..."
local key_data = model[current_key]
if key_data then
local r = math.random()
local prob_sum = 0.0
for new_note, new_prob in pairs(key_data.next) do
prob_sum = prob_sum + new_prob
if prob_sum < r then
chosen = new_note
end
end
end
-- print(current_key .. " --> " .. chosen)
seq[#seq+1] = chosen
end
return seq
end