Class el.AudioBuffer
An audio buffer
Functions
AudioBuffer:free () | Free used memory. |
AudioBuffer:isFloat () | Returns true if audio data is 32bit float. |
AudioBuffer:isDouble () | Returns true if audio data is 64bit float. |
AudioBuffer:channels () | Channel count |
AudioBuffer:length () | returns the number of samples in the buffer |
AudioBuffer:clear () | Clears the entire audio buffer. |
AudioBuffer:clear (channel) | Clears one channel in the audio buffer. |
AudioBuffer:clear (start, count) | Clears a range of samples on all channels. |
AudioBuffer:clear (channel, start, count) | Clears a range of samples on one channel |
AudioBuffer:cleared () | Returns true if the buffer has been cleared |
AudioBuffer:get (channel, frame) | Get a single value from the buffer |
AudioBuffer:set (channel, frame, value) | Set a single sample in the buffer |
AudioBuffer:applyGain (gain) | Apply gain to all channels and samples |
AudioBuffer:applyGain (channel, gain) | Apply gain to a single channel |
AudioBuffer:applyGain (start, count, gain) | Applies a gain multiple to a region of all the channels. |
AudioBuffer:applyGain (channel, start, count, gain) | Apply gain to a single channel with range |
AudioBuffer:fade (startgain, endgain) | Fade the buffer from starting gain to ending gain |
AudioBuffer:fade (channel, start, count, gain1, gain2) | Fade the buffer from starting gain to ending gain |
Constructors
AudioBuffer.new () | Creates a empty audio buffer. |
AudioBuffer.new (nchannels, nframes) | Creates a new audio buffer with the specified channel and sample counts |
Functions
- AudioBuffer:free ()
- Free used memory. Invoke this to free the buffer when it is no longer needed. Once called, the buffer is no longer valid and WILL crash the interpreter if used after the fact.
- AudioBuffer:isFloat ()
- Returns true if audio data is 32bit float. Call this to find out audio data precision.
- AudioBuffer:isDouble ()
- Returns true if audio data is 64bit float. Call this to find out audio data precision.
- AudioBuffer:channels ()
-
Channel count
Returns:
-
the number of channels held in the buffer
- AudioBuffer:length ()
-
returns the number of samples in the buffer
Returns:
-
size of the buffer in samples
- AudioBuffer:clear ()
- Clears the entire audio buffer.
- AudioBuffer:clear (channel)
-
Clears one channel in the audio buffer.
Parameters:
- channel integer The channel to clear
- AudioBuffer:clear (start, count)
-
Clears a range of samples on all channels.
Parameters:
- start integer Sample index to start on
- count integer Number of samples to clear
- AudioBuffer:clear (channel, start, count)
-
Clears a range of samples on one channel
Parameters:
- channel integer The channel to clear
- start integer Sample index to start on
- count integer Number of samples to clear
- AudioBuffer:cleared ()
-
Returns true if the buffer has been cleared
Returns:
-
true if already cleared
- AudioBuffer:get (channel, frame)
-
Get a single value from the buffer
Parameters:
- channel The channel to get from
- frame The sample index to get
Returns:
-
the number of channels held in the buffer
- AudioBuffer:set (channel, frame, value)
-
Set a single sample in the buffer
Parameters:
- channel The channel to set on
- frame The frame index to set
- value The value to set
- AudioBuffer:applyGain (gain)
-
Apply gain to all channels and samples
Parameters:
- gain number Gain to apply to all channels
- AudioBuffer:applyGain (channel, gain)
-
Apply gain to a single channel
Parameters:
- channel integer Channel to apply gain to
- gain number Gain to apply to a channel
- AudioBuffer:applyGain (start, count, gain)
-
Applies a gain multiple to a region of all the channels.
For speed, this doesn't check whether the sample numbers
are in-range, so be careful!
Parameters:
- start integer Sample index to start at
- count integer Number of samples to process
- gain number Amount of gain to apply
- AudioBuffer:applyGain (channel, start, count, gain)
-
Apply gain to a single channel with range
Parameters:
- channel integer Channel to apply gain to
- start integer Sample index to start at
- count integer Number of samples to process
- gain number Amount of gain to apply
- AudioBuffer:fade (startgain, endgain)
-
Fade the buffer from starting gain to ending gain
Parameters:
- startgain number Starting gain
- endgain number End gain
- AudioBuffer:fade (channel, start, count, gain1, gain2)
-
Fade the buffer from starting gain to ending gain
Parameters:
- channel integer Channel to apply to
- start integer Sample to start at
- count integer Number of samples to process
- gain1 number Starting gain
- gain2 number End gain
Constructors
- AudioBuffer.new ()
-
Creates a empty audio buffer.
Returns:
-
An empty buffer.
Usage:
local buf = AudioBuffer.new() -- do someting with
buf
- AudioBuffer.new (nchannels, nframes)
-
Creates a new audio buffer with the specified channel and sample counts
Parameters:
- nchannels integer Number of channels
- nframes integer Number of samples in each channel
Returns:
-
Newly created audio buffer
Usage:
-- 2 channels, 2048 samples local buf = AudioBuffer.new (2, 2048) -- do someting with
buf