rsi/soundgroups.lua

45 lines
1.4 KiB
Lua
Raw Normal View History

2023-08-27 12:32:38 +00:00
local fs=love.filesystem
group=object:extend()
function group:addDirectory(directory) files=fs.getDirectoryItems(directory)
for i,currentfile in ipairs(files) do
fullpath=directory .."/" ..currentfile
if not fs.isDirectory(fullpath) and not (currentfile:sub(1,1)==".") then
if fs.getInfo(fullpath, file) then
nameOnly=string.match(currentfile, "%P+") --%P matches all non punctuation characters
sound=love.audio.newSource(fullpath, "static")
if sound:typeOf("Source") then
--print("Loaded " .. nameOnly)
2023-08-27 23:00:22 +00:00
-- if sound:getChannelCount()==1 then sound:setRelative(true) end
2023-08-27 12:32:38 +00:00
self[nameOnly]=sound
2023-08-27 23:00:22 +00:00
-- self.sounds[nameOnly] =sound
2023-08-27 12:32:38 +00:00
end --if is a sound
end --if it's a file
end -- if it's not a dot
end --for
end --addDirectory
function group:new(directory)
2023-08-27 23:00:22 +00:00
-- self.sounds={}
2023-08-27 12:32:38 +00:00
self:addDirectory(directory)
end
function group:setEffect(effect)
--print("setting effects on group")
for i,currentsource in pairs(self) do
if currentsource.typeOf~=nil and currentsource:typeOf("Source") then
if currentsource:setEffect(effect) then
--print("effect set on " ..i)
else
print("failed to set effect on " ..i)
end
end --if it's a source
end --for loop
end --setEffect function