diff options
Diffstat (limited to 'sndfile.lua')
-rw-r--r-- | sndfile.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sndfile.lua b/sndfile.lua index 263893d..47ea1ff 100644 --- a/sndfile.lua +++ b/sndfile.lua @@ -104,7 +104,17 @@ typedef enum SF_MODE { SFM_RDWR = 0x30 } SF_MODE; +/* These values come from stdio.h */ +typedef enum SF_SEEK { + SEEK_SET = 0, + SEEK_CUR = 1, + SEEK_END = 2 +} SF_SEEK; + SNDFILE* sf_open(const char *path, int mode, SF_INFO *sfinfo); + +sf_count_t sf_seek(SNDFILE *sndfile, sf_count_t frames, int whence); + const char* sf_strerror(SNDFILE *sndfile); int sf_command(SNDFILE *sndfile, int command, void *data, int datasize); @@ -175,6 +185,11 @@ function sndfile:new(path, mode, samplerate, channels, format) return obj end +function sndfile:seek(frames, whence) + whence = whence and ffi.new("SF_SEEK", whence) or ffi.C.SEEK_SET + return lib.sf_seek(self.handle, frames, whence) +end + -- TODO: Maybe support reading multiple samples at once. function sndfile:read() return lib.sf_read_double(self.handle, double_buffer, 1) == 1 and |