$ luarocks install diffrhythm.ai luarocks install diffrhythm.ai
local diffrhythm = require("diffrhythm.ai")
local rhythm1 = { 1, 0, 1, 0, 1, 0, 1, 0 } -- Simple alternating rhythm
local rhythm2 = { 1, 0, 0, 1, 0, 1, 0, 0 } -- Slightly different rhythm
local similarity = diffrhythm.compare_rhythms(rhythm1, rhythm2)
print("Similarity score:", similarity) -- Output will be a value between 0 and 1
local diffrhythm = require("diffrhythm.ai")
local length = 16
local density = 0.6 -- Probability of a beat occurring
local random_rhythm = diffrhythm.generate_random_rhythm(length, density)
print("Random Rhythm:", table.concat(random_rhythm, ", "))
local diffrhythm = require("diffrhythm.ai")
local rhythm = { 1, 0, 1, 1, 0, 0, 1, 0 }
local shift_amount = 2
local shifted_rhythm = diffrhythm.shift_rhythm(rhythm, shift_amount)