-- --- @class Music -- --- @field source table audio streams, that supports multitrack (kind of) -- --- @field offset number -- music = {} -- music.__index = music -- --- @param path string accepts path to dir with some music files (example: "main_ambient"; "player/theme1" and etc etc) -- local function new(path) -- local dir = Tree.assets.files.audio.music[path] -- --- @type table -- local source = {} -- print(dir) -- for _, v in pairs(dir) do -- print(v.filename) -- source[v.filename] = v.source -- print(v.filename) -- end -- print('[music]: new source: ', table.concat(source, ' ')) -- return setmetatable({ source = source, offset = 0 }, music) -- end -- function music:update() -- for _, v in ipairs(self.source) do -- v:seek() -- end -- end -- --- pause stemfile or music at all -- --- @param filename? string -- function music:pause(filename) -- if filename then -- self.source[filename]:pause() -- else -- for _, v in pairs(self.source) do -- v:pause() -- end -- end -- end -- --- play music stemfile by his name -- --- @param filename string -- --- @return boolean -- function music:play(filename) -- print('[music]: ', table.concat(self.source, ' ')) -- self.source[filename]:seek(self.offset, "seconds") -- return self.source[filename]:play() -- end -- return { new = new }