summaryrefslogtreecommitdiff
path: root/meta/3rd/love2d/library/love/sound.lua
blob: bbe47d102c039345c4461f9dfdb4bc070b2e447b (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---@meta

---
---This module is responsible for decoding sound files. It can't play the sounds, see love.audio for that.
---
---
---[Open in Browser](https://love2d.org/wiki/love.sound)
---
---@class love.sound
love.sound = {}

---
---Attempts to find a decoder for the encoded sound data in the specified file.
---
---
---[Open in Browser](https://love2d.org/wiki/love.sound.newDecoder)
---
---@overload fun(filename: string, buffer?: number):love.Decoder
---@param file love.File # The file with encoded sound data.
---@param buffer? number # The size of each decoded chunk, in bytes.
---@return love.Decoder decoder # A new Decoder object.
function love.sound.newDecoder(file, buffer) end

---
---Creates new SoundData from a filepath, File, or Decoder. It's also possible to create SoundData with a custom sample rate, channel and bit depth.
---
---The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.
---
---
---[Open in Browser](https://love2d.org/wiki/love.sound.newSoundData)
---
---@overload fun(file: love.File):love.SoundData
---@overload fun(decoder: love.Decoder):love.SoundData
---@overload fun(samples: number, rate?: number, bits?: number, channels?: number):love.SoundData
---@param filename string # The file name of the file to load.
---@return love.SoundData soundData # A new SoundData object.
function love.sound.newSoundData(filename) end

---
---An object which can gradually decode a sound file.
---
---
---[Open in Browser](https://love2d.org/wiki/love.sound)
---
---@class love.Decoder: love.Object
local Decoder = {}

---
---Creates a new copy of current decoder.
---
---The new decoder will start decoding from the beginning of the audio stream.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:clone)
---
---@return love.Decoder decoder # New copy of the decoder.
function Decoder:clone() end

---
---Decodes the audio and returns a SoundData object containing the decoded audio data.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:decode)
---
---@return love.SoundData soundData # Decoded audio data.
function Decoder:decode() end

---
---Returns the number of bits per sample.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:getBitDepth)
---
---@return number bitDepth # Either 8, or 16.
function Decoder:getBitDepth() end

---
---Returns the number of channels in the stream.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:getChannelCount)
---
---@return number channels # 1 for mono, 2 for stereo.
function Decoder:getChannelCount() end

---
---Gets the duration of the sound file. It may not always be sample-accurate, and it may return -1 if the duration cannot be determined at all.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:getDuration)
---
---@return number duration # The duration of the sound file in seconds, or -1 if it cannot be determined.
function Decoder:getDuration() end

---
---Returns the sample rate of the Decoder.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:getSampleRate)
---
---@return number rate # Number of samples per second.
function Decoder:getSampleRate() end

---
---Sets the currently playing position of the Decoder.
---
---
---[Open in Browser](https://love2d.org/wiki/Decoder:seek)
---
---@param offset number # The position to seek to, in seconds.
function Decoder:seek(offset) end

---
---Contains raw audio samples.
---
---You can not play SoundData back directly. You must wrap a Source object around it.
---
---
---[Open in Browser](https://love2d.org/wiki/love.sound)
---
---@class love.SoundData: love.Data, love.Object
local SoundData = {}

---
---Returns the number of bits per sample.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getBitDepth)
---
---@return number bitdepth # Either 8, or 16.
function SoundData:getBitDepth() end

---
---Returns the number of channels in the SoundData.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getChannelCount)
---
---@return number channels # 1 for mono, 2 for stereo.
function SoundData:getChannelCount() end

---
---Gets the duration of the sound data.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getDuration)
---
---@return number duration # The duration of the sound data in seconds.
function SoundData:getDuration() end

---
---Gets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getSample)
---
---@overload fun(self: love.SoundData, i: number, channel: number):number
---@param i number # An integer value specifying the position of the sample (starting at 0).
---@return number sample # The normalized samplepoint (range -1.0 to 1.0).
function SoundData:getSample(i) end

---
---Returns the number of samples per channel of the SoundData.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getSampleCount)
---
---@return number count # Total number of samples.
function SoundData:getSampleCount() end

---
---Returns the sample rate of the SoundData.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:getSampleRate)
---
---@return number rate # Number of samples per second.
function SoundData:getSampleRate() end

---
---Sets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order.
---
---
---[Open in Browser](https://love2d.org/wiki/SoundData:setSample)
---
---@overload fun(self: love.SoundData, i: number, channel: number, sample: number)
---@param i number # An integer value specifying the position of the sample (starting at 0).
---@param sample number # The normalized samplepoint (range -1.0 to 1.0).
function SoundData:setSample(i, sample) end