Module audio.sndfile
Read and write audio files.
The sndfile module can also be invoked directly, e.g.
sndfile("mysound.wav", "w")
to create/open a file for writing.
Functions
create (path, config) | Create (or re-open) a soundfile for writing. |
read (path) | Read in a sound file and return an audio.buffer object. |
Class SNDFILE
SNDFILE:write (buf, len) | Write data to a sound file. |
SNDFILE:close () | Close a sound file. |
Functions
- create (path, config)
-
Create (or re-open) a soundfile for writing.
The config table options include "channels" (default 2), "samplerate" (default 44100).
Parameters:
Returns:
- read (path)
-
Read in a sound file and return an audio.buffer object.
Parameters:
- path string filename or full filepath of file to read
Returns:
-
audio.buffer
buffer
see also:
Class SNDFILE
A sound file class.- SNDFILE:write (buf, len)
-
Write data to a sound file.
If buf is a number, len is ignored and a single sample is written.
Parameters:
- buf
- len
Returns:
-
self
- SNDFILE:close ()
- Close a sound file. Closing a soundfile is important to allow other programs to use it. However, it is not always necessary, as garbage collection will automatically close the file. Warning: the soundfile reference should not be used after calling close()