@quenty/sounds 7.0.0-canary.331.7eefa75.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -1
- package/LICENSE.md +1 -1
- package/package.json +7 -4
- package/src/Shared/SoundPromiseUtils.lua +28 -4
- package/src/Shared/SoundUtils.lua +44 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,91 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [7.0.0
|
|
6
|
+
# [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.10.0...@quenty/sounds@7.0.0) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [6.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.9.0...@quenty/sounds@6.10.0) (2023-08-23)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* Add missing dependencies ([324e3db](https://github.com/Quenty/NevermoreEngine/commit/324e3dbcd7ed260542eebe24889cbc6cd968d380))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* Sound plays using :Play() always since PlayLocalSound no longer works in Hoarcekat ([58eeb15](https://github.com/Quenty/NevermoreEngine/commit/58eeb15e832c5d13a4a602c87656b233862d8392))
|
|
25
|
+
* Sounds can play back tables ([d33bbee](https://github.com/Quenty/NevermoreEngine/commit/d33bbeed98016b04b0958ce27df5a82f7c9cbf4e))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# [6.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.8.0...@quenty/sounds@6.9.0) (2023-07-28)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [6.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.7.0...@quenty/sounds@6.8.0) (2023-07-10)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* Use RbxAssetId package for SoundUtils ([097438e](https://github.com/Quenty/NevermoreEngine/commit/097438ed87e54c37212c421a58656711598dddb1))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# [6.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.6.0...@quenty/sounds@6.7.0) (2023-06-17)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# [6.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.5.1...@quenty/sounds@6.6.0) (2023-04-10)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## [6.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.5.0...@quenty/sounds@6.5.1) (2023-04-07)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [6.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.4.0...@quenty/sounds@6.5.0) (2023-03-31)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [6.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.3.0...@quenty/sounds@6.4.0) (2023-03-05)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [6.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@6.2.0...@quenty/sounds@6.3.0) (2023-02-27)
|
|
7
91
|
|
|
8
92
|
**Note:** Version bump only for package @quenty/sounds
|
|
9
93
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sounds",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Utility functions involving sounds and their state",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,11 +26,14 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/loader": "
|
|
30
|
-
"@quenty/
|
|
29
|
+
"@quenty/loader": "^7.0.0",
|
|
30
|
+
"@quenty/maid": "^2.6.0",
|
|
31
|
+
"@quenty/promise": "^7.0.0",
|
|
32
|
+
"@quenty/promisemaid": "^2.0.0",
|
|
33
|
+
"@quenty/rbxasset": "^2.0.0"
|
|
31
34
|
},
|
|
32
35
|
"publishConfig": {
|
|
33
36
|
"access": "public"
|
|
34
37
|
},
|
|
35
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "fdeae46099587019ec5fc15317dc673aed379400"
|
|
36
39
|
}
|
|
@@ -7,6 +7,8 @@ local require = require(script.Parent.loader).load(script)
|
|
|
7
7
|
|
|
8
8
|
local Promise = require("Promise")
|
|
9
9
|
local PromiseUtils = require("PromiseUtils")
|
|
10
|
+
local PromiseMaidUtils = require("PromiseMaidUtils")
|
|
11
|
+
local Maid = require("Maid")
|
|
10
12
|
|
|
11
13
|
local SoundPromiseUtils = {}
|
|
12
14
|
|
|
@@ -21,22 +23,44 @@ function SoundPromiseUtils.promiseLoaded(sound)
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
local promise = Promise.new()
|
|
26
|
+
local maid = Maid.new()
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
maid:GiveTask(sound:GetPropertyChangedSignal("IsLoaded"):Connect(function()
|
|
29
|
+
if sound.IsLoaded then
|
|
30
|
+
promise:Resolve()
|
|
31
|
+
end
|
|
32
|
+
end))
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
maid:GiveTask(sound.Loaded:Connect(function()
|
|
28
35
|
if sound.IsLoaded then
|
|
29
36
|
promise:Resolve()
|
|
30
37
|
end
|
|
31
|
-
end)
|
|
38
|
+
end))
|
|
32
39
|
|
|
33
40
|
promise:Finally(function()
|
|
34
|
-
|
|
41
|
+
maid:DoCleaning()
|
|
35
42
|
end)
|
|
36
43
|
|
|
37
44
|
return promise
|
|
38
45
|
end
|
|
39
46
|
|
|
47
|
+
function SoundPromiseUtils.promisePlayed(sound)
|
|
48
|
+
return SoundPromiseUtils.promiseLoaded(sound):Then(function()
|
|
49
|
+
return PromiseUtils.delayed(sound.TimeLength)
|
|
50
|
+
end)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
function SoundPromiseUtils.promiseLooped(sound)
|
|
54
|
+
local promise = Promise.new()
|
|
55
|
+
|
|
56
|
+
PromiseMaidUtils.whilePromise(promise, function(maid)
|
|
57
|
+
maid:GiveTask(sound.DidLoop:Connect(function()
|
|
58
|
+
promise:Resolve()
|
|
59
|
+
end))
|
|
60
|
+
end)
|
|
61
|
+
|
|
62
|
+
return promise
|
|
63
|
+
end
|
|
40
64
|
--[=[
|
|
41
65
|
Promises that all sounds are loaded
|
|
42
66
|
@param sounds { Sound }
|
|
@@ -14,6 +14,7 @@ local SoundService = game:GetService("SoundService")
|
|
|
14
14
|
local RunService = game:GetService("RunService")
|
|
15
15
|
|
|
16
16
|
local SoundPromiseUtils = require("SoundPromiseUtils")
|
|
17
|
+
local RbxAssetUtils = require("RbxAssetUtils")
|
|
17
18
|
|
|
18
19
|
local SoundUtils = {}
|
|
19
20
|
|
|
@@ -28,13 +29,9 @@ local SoundUtils = {}
|
|
|
28
29
|
The sound will be automatically cleaned up after the sound is played.
|
|
29
30
|
:::
|
|
30
31
|
|
|
31
|
-
@param id string | number
|
|
32
32
|
@return Sound
|
|
33
33
|
]=]
|
|
34
|
-
function SoundUtils.playFromId(id: string | number): Sound
|
|
35
|
-
local soundId = SoundUtils.toRbxAssetId(id)
|
|
36
|
-
assert(type(soundId) == "string", "Bad id")
|
|
37
|
-
|
|
34
|
+
function SoundUtils.playFromId(id: string | number | table): Sound
|
|
38
35
|
local sound = SoundUtils.createSoundFromId(id)
|
|
39
36
|
|
|
40
37
|
if RunService:IsClient() then
|
|
@@ -51,34 +48,52 @@ end
|
|
|
51
48
|
--[=[
|
|
52
49
|
Creates a new sound object from the given id
|
|
53
50
|
]=]
|
|
54
|
-
function SoundUtils.createSoundFromId(id: string | number): Sound
|
|
51
|
+
function SoundUtils.createSoundFromId(id: string | number | table): Sound
|
|
55
52
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
56
53
|
assert(type(soundId) == "string", "Bad id")
|
|
57
54
|
|
|
58
55
|
local sound = Instance.new("Sound")
|
|
56
|
+
sound.Archivable = false
|
|
57
|
+
|
|
58
|
+
SoundUtils.applyPropertiesFromId(sound, id)
|
|
59
|
+
|
|
60
|
+
return sound
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
function SoundUtils.applyPropertiesFromId(sound, id)
|
|
64
|
+
local soundId = SoundUtils.toRbxAssetId(id)
|
|
59
65
|
sound.Name = ("Sound_%s"):format(soundId)
|
|
60
66
|
sound.SoundId = soundId
|
|
61
67
|
sound.RollOffMode = Enum.RollOffMode.InverseTapered
|
|
62
68
|
sound.Volume = 0.25
|
|
63
|
-
sound.Archivable = false
|
|
64
69
|
|
|
65
|
-
|
|
70
|
+
if type(id) == "table" then
|
|
71
|
+
for property, value in pairs(id) do
|
|
72
|
+
if property ~= "Parent" and property ~= "RollOffMinDistance" then
|
|
73
|
+
sound[property] = value
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if id.RollOffMinDistance then
|
|
78
|
+
sound.RollOffMinDistance = id.RollOffMinDistance
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if id.Parent then
|
|
82
|
+
sound.Parent = id.Parent
|
|
83
|
+
end
|
|
84
|
+
end
|
|
66
85
|
end
|
|
67
86
|
|
|
68
87
|
--[=[
|
|
69
88
|
Plays back a template given asset id in the parent
|
|
70
89
|
]=]
|
|
71
|
-
function SoundUtils.playFromIdInParent(id: string | number, parent: Instance): Sound
|
|
90
|
+
function SoundUtils.playFromIdInParent(id: string | number | table, parent: Instance): Sound
|
|
72
91
|
assert(typeof(parent) == "Instance", "Bad parent")
|
|
73
92
|
|
|
74
93
|
local sound = SoundUtils.createSoundFromId(id)
|
|
75
94
|
sound.Parent = parent
|
|
76
95
|
|
|
77
|
-
|
|
78
|
-
SoundService:PlayLocalSound(sound)
|
|
79
|
-
else
|
|
80
|
-
sound:Play()
|
|
81
|
-
end
|
|
96
|
+
sound:Play()
|
|
82
97
|
|
|
83
98
|
SoundUtils.removeAfterTimeLength(sound)
|
|
84
99
|
|
|
@@ -128,14 +143,25 @@ end
|
|
|
128
143
|
|
|
129
144
|
--[=[
|
|
130
145
|
Converts a string or number to a string for playback.
|
|
146
|
+
|
|
147
|
+
@function toRbxAssetId
|
|
131
148
|
@param id string? | number
|
|
132
149
|
@return string?
|
|
150
|
+
@within SoundUtils
|
|
133
151
|
]=]
|
|
134
|
-
function SoundUtils.toRbxAssetId(
|
|
135
|
-
if type(
|
|
136
|
-
return (
|
|
152
|
+
function SoundUtils.toRbxAssetId(soundId)
|
|
153
|
+
if type(soundId) == "table" then
|
|
154
|
+
return RbxAssetUtils.toRbxAssetId(soundId.SoundId)
|
|
155
|
+
else
|
|
156
|
+
return RbxAssetUtils.toRbxAssetId(soundId)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
function SoundUtils.isConvertableToRbxAsset(soundId)
|
|
161
|
+
if type(soundId) == "table" then
|
|
162
|
+
return RbxAssetUtils.isConvertableToRbxAsset(soundId.SoundId)
|
|
137
163
|
else
|
|
138
|
-
return
|
|
164
|
+
return RbxAssetUtils.isConvertableToRbxAsset(soundId)
|
|
139
165
|
end
|
|
140
166
|
end
|
|
141
167
|
|