-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaudio.lua
49 lines (40 loc) · 1.05 KB
/
audio.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- local audio = {
-- source_tables = {},
-- }
-- local VOICES = 4
-- local SourceTable = leaf.Object:extend()
-- function SourceTable:init(path)
-- self.counter = 1
-- self.voices = {}
-- self.nvoices = VOICES
-- if path:find("gun") then
-- self.nvoices = self.nvoices * 4
-- end
-- for i=1, self.nvoices do
-- self.voices[i] = love.audio.newSource(path)
-- end
-- end
-- function SourceTable:play()
-- local source = self.voices[self.counter]
-- source:play()
-- self.counter = (self.counter % self.nvoices) + 1
-- end
-- function audio.load()
-- audio.source_tables = leaf.fs.recursiveYieldingLoader('sfx', audio.register)
-- end
-- function audio.register(path)
-- local source_table = SourceTable(path)
-- return source_table
-- end
-- function audio.play(name)
-- local source_table = audio.source_tables[name]
-- if source_table then
-- source_table:play()
-- end
-- end
-- return audio
return {
play = function(name)
assets.sfx[name]:play()
end,
}