diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-09-03 19:20:11 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-09-03 19:20:11 +0200 |
commit | d104bd746605cb38977173beb079ebac7e8fa0ce (patch) | |
tree | 2f3d25cd40f67a946f1fd455cca4187c371143d5 /sndfile.lua | |
parent | 148195537704906dd9a50cea8442a4df0cd8b16f (diff) | |
download | applause2-d104bd746605cb38977173beb079ebac7e8fa0ce.tar.gz |
SndfileStream() supports raw files now, by passing through samplerate, channels and libsndfile format
Diffstat (limited to 'sndfile.lua')
-rw-r--r-- | sndfile.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sndfile.lua b/sndfile.lua index e91fb70..13c952d 100644 --- a/sndfile.lua +++ b/sndfile.lua @@ -1,6 +1,7 @@ -- module table local sndfile = {} +local bit = require "bit" local ffi = require "ffi" ffi.cdef[[ @@ -165,7 +166,8 @@ function sndfile:new(path, mode, samplerate, channels, format) local info = ffi.new("SF_INFO[1]") - if mode ~= "SFM_READ" then + if mode == "SFM_WRITE" or + (format and bit.band(format, ffi.C.SF_FORMAT_TYPEMASK) == ffi.C.SF_FORMAT_RAW) then info[0].samplerate = samplerate or 44100 info[0].channels = channels or 1 info[0].format = format or sndfile.guess_format(path) |