Skip to content

andresy/lua---sndfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sndfile: an interface to libsndfile

The package provide a interface to the libsndfile library.

Installation

luarocks install sndfile

Example

> require 'sndfile'
> f = sndfile.SndFile('blah.htk') -- open HTK file
> print(f:info())
{[samplerate] = 16000
 [sections]   = 1
 [subformat]  = string : "PCM16"
 [channels]   = 1
 [seekable]   = true
 [format]     = string : "HTK"
 [frames]     = 49460
 [endian]     = string : "FILE"}
> x = f:readShort(f:info().frames) -- read all frames
> print(x:size()) -- note: there is only one channel

 49460
     1
[torch.LongStorage of size 2]
>
> -- ok, now write the stuff in WAV
> f = sndfile.SndFile('blah.wav', 'w', {samplerate=16000, channels=1, format="WAV", subformat="PCM16"})
> f:string('title', 'dude it is awesome') -- write some title in there
> f:writeShort(x)
> f:close() -- done

For more details, you can check libsndfile documentation. For supported formats, see sndfile.formatlist(), sndfile.subformatlist() and sndfile.endianlist().

About

Interface to the libsndfile library for Torch7

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published