Module libsox

Lua bindings to libsox

This documentation is partial, and doesn't cover all functionality yet.

Info:

Functions

version () libSoX library version.
sox_init () Initialize effects library.
sox_quit () Close effects library and unload format handler plugins.
buffer (size) Allocates size bytes in storage buffer, default is (32768).
free_buffer (buf) Deallocates the space previously allocated to buffer.
sample_to_float32 (buf, index, clips) Converts SoX native sample to a 32-bit float.
sample_to_float64 (buf, index) Converts SoX native sample to a 64-bit float.
get_levels (buf, block_size) Return audio levels of the current buffer.
signal (ft) Return information already known about audio stream, or NULL if none.
encoding (ft) Return information already known about sample encoding
sox_create_effects_chain (in_enc, out_enc) Initializes an effects chain.
sox_create_effect (eh) Creates an effect using the given handler.
sox_find_effect (name) Finds the effect handler with the given name.
sox_effect_options (effp, argc, argv) Applies the command-line options to the effect.
sox_add_effect (chain, effp, in, out) Adds an effect to the effects chain.
sox_flow_effects (chain) Runs the effects chain.
sox_delete_effects_chain (ecp) Closes an effects chain.
sox_open_read (path) Opens a decoding session for a file.
sox_open_mem_read (buf, buf_sz, signal, filetype) Opens a decoding session for a memory buffer.
sox_open_memstream_write (buf_ptr, buf_sz_ptr, signal) Opens an encoding session for a memstream buffer.
sox_read (ft, buf, len) Reads samples from a decoding session into a sample buffer.
sox_open_write (path, signal, filetype) Opens an encoding session for a file.
sox_write (ft, buf, len) Writes samples to an encoding session from a sample buffer.
sox_seek (ft, offset) Sets the location at which next samples will be decoded.
sox_close () Closes an encoding or decoding session.
msecs (msecs) Blocks the execution of the current thread for at least until the msecs
sleep (secs) Blocks the execution of the current thread for at least until the secs


Functions

version ()
libSoX library version.

Returns:

    string version string "major.minor.revision"

See also:

sox_init ()
Initialize effects library.

Returns:

    boolean true if successful.

See also:

sox_quit ()
Close effects library and unload format handler plugins.

Returns:

    boolean true if successful.

See also:

buffer (size)
Allocates size bytes in storage buffer, default is (32768).

Parameters:

  • size integer size of buffer

Returns:

    userdata Returned buffer handle .
free_buffer (buf)
Deallocates the space previously allocated to buffer.

Parameters:

  • buf userdata the buffer handle
sample_to_float32 (buf, index, clips)
Converts SoX native sample to a 32-bit float.

Parameters:

  • buf userdata Input sample to be converted.
  • index integer index in the buffer array
  • clips integer Number to increment if input sample is too large.
sample_to_float64 (buf, index)
Converts SoX native sample to a 64-bit float.

Parameters:

  • buf userdata Input sample to be converted.
  • index integer index in the buffer array
get_levels (buf, block_size)
Return audio levels of the current buffer.

Parameters:

  • buf userdata Input sample to be analize.
  • block_size integer the size of blocks to be read.

Returns:

  1. number level of right channel.
  2. number level of left channel.
signal (ft)
Return information already known about audio stream, or NULL if none.

Parameters:

  • ft userdata the current handler
encoding (ft)
Return information already known about sample encoding

Parameters:

  • ft userdata the current handler
sox_create_effects_chain (in_enc, out_enc)
Initializes an effects chain.

Parameters:

  • in_enc userdata Input encoding.
  • out_enc userdata Output encoding.

Returns:

    userdata handle Returned must be closed with sox:deleteeffectschain().

See also:

sox_create_effect (eh)
Creates an effect using the given handler.

Parameters:

  • eh userdata Handler to use for effect.

See also:

sox_find_effect (name)
Finds the effect handler with the given name.

Parameters:

  • name string Name of effect to find.

See also:

sox_effect_options (effp, argc, argv)
Applies the command-line options to the effect.

Parameters:

  • effp userdata Effect pointer on which to set options.
  • argc integer Number of arguments in argv.
  • argv userdata or string Array of command-line options.

See also:

sox_add_effect (chain, effp, in, out)
Adds an effect to the effects chain.

Parameters:

  • chain userdata Effects chain to which effect should be added .
  • effp userdata Effect to be added.
  • in userdata Input format.
  • out userdata Output format.

Returns:

    boolean returns true if successful.

See also:

sox_flow_effects (chain)
Runs the effects chain.

Parameters:

  • chain userdata Effects chain to run.

Returns:

    boolean returns true if successful.

See also:

sox_delete_effects_chain (ecp)
Closes an effects chain.

Parameters:

  • ecp userdata Effects chain pointer.

See also:

sox_open_read (path)
Opens a decoding session for a file.

Parameters:

  • path string Path to file to be opened (required).

Returns:

    userdata handle Returned handle must be closed with sox:close(handle).

See also:

sox_open_mem_read (buf, buf_sz, signal, filetype)
Opens a decoding session for a memory buffer.

Parameters:

  • buf string Pointer to audio data buffer (required).
  • buf_sz integer Number of bytes to read from audio data buffer.
  • signal array Information already known about audio stream, or NULL if none.
  • filetype string Information already known about sample encoding, or NULL if none.

Returns:

    userdata handle Returned handle must be closed with sox:close(handle).

See also:

sox_open_memstream_write (buf_ptr, buf_sz_ptr, signal)
Opens an encoding session for a memstream buffer.

Parameters:

  • buf_ptr string Receives pointer to audio data buffer that receives data (required).
  • buf_sz_ptr integer Receives size of data written to audio data buffer (required).
  • signal array Information about desired audio stream (required).

Returns:

    userdata handle Returned handle must be closed with sox:close(handle).

See also:

sox_read (ft, buf, len)
Reads samples from a decoding session into a sample buffer.

Parameters:

  • ft userdata Format pointer.
  • buf userdata Buffer from which to read samples.
  • len integer Number of samples available in buf.

Returns:

    integer Number of samples decoded, or 0 for EOF.

See also:

sox_open_write (path, signal, filetype)
Opens an encoding session for a file. Returned handle must be closed with sox:close().

Parameters:

  • path string Path to file to be written (required).
  • signal array Information about desired audio stream (required).
  • filetype string Previously-determined file type, or NULL to auto-detect.

Returns:

    userdata or nil handle The new session handle, or nil on failure..

See also:

sox_write (ft, buf, len)
Writes samples to an encoding session from a sample buffer.

Parameters:

  • ft userdata Format pointer.
  • buf userdata Buffer from which to read samples.
  • len integer Number of samples available in buf.

Returns:

    integer Number of samples encoded..

See also:

sox_seek (ft, offset)
Sets the location at which next samples will be decoded.

Parameters:

  • ft userdata Format pointer.
  • offset integer Sample offset at which to position reader.

Returns:

    boolean returns true if successful.

See also:

sox_close ()
Closes an encoding or decoding session.

Returns:

    boolean returns true if successful.

See also:

msecs (msecs)
Blocks the execution of the current thread for at least until the msecs

Parameters:

  • msecs integer the number millisecons.
sleep (secs)
Blocks the execution of the current thread for at least until the secs

Parameters:

  • secs integer the number secons.
generated by LDoc 1.4.6 Last updated 2021-03-17 06:13:16