A wrapper of libsndfile for the Nim programming language.
The libsndfile API only has a relatively small number of functions, but it
defines quite a few types and enum values. The sndfile Nim module provides
definitions for all types and enums (except those for deprecated and not-yet
implemented functions) and wraps all functions, except the following:
sf_open_fdsf_open_virtualsf_wchar_open
These missing functions may be added in future versions, if it makes sense to use them in Nim.
- The
sf_prefix has been removed from function names, i.e. instead ofsf_read_double, use justread_double(orreadDouble, Nim's identifier naming rules make no distinction). The wrapper code generally uses lowercamelCase. - All values within each enum have been stripped of their unique prefix and
all enums are marked
{.pure.}. This means you should prefix each enum symbol with its enum type name. For exampleSF_FORMAT_WAVbecomesSFFormat.WAV(orSF_Format.Wavetc.). If the value symbol is non-ambiguous, the enum name can be omitted, e.g.GET_LOG_INFOinstead ofSFCommand.GET_LOG_INFO. - typedefs and structs start with a capital letter and retain their
SFprefix, but Nim's identifier naming rules allow to omit underscores and use whatever case after the first letter. For example, instead ofSF_INFO, you can useSFInfo,SF_infoetc. The wrapper code generally usesPascalCase.
| C prefix / name | Nim enum / symbol |
|---|---|
SFM_ |
SFMode |
SF_STR_ |
SFStrType |
SF_LOOP_ |
SFLoopMode |
SFC_ |
SFCommand |
SNDFILE |
SndFile |
sf_count_t |
SFCount |
SF_TRUE |
SFBool.TRUE |
SF_FALSE |
SFBool.FALSE |
SF_STR_FIRST |
SFStrType.low |
SF_STR_LAST |
SFStrType.high |
SF_AMBISONIC_NONE |
SFAmbisonic.NONE |
SF_AMBISONIC_B_FORMAT |
SFAmbisonic.B_FORMAT |
SF_INSTRUMENT.loops |
SFLoop |
SF_INSTRUMENT.loops[n].end |
SFLoops.endPos |
SF_INSTRUMENT.loops[n].start |
SFLoops.startPos |
SF_CUES: Define / allocatearray[<n>, SFCuePoint]as neededSF_BROADCAST_INFO: Set number of entries in thecodingHistoryarray member ofSFBroadcastInfowith-d:sfCodingHistSize=<n>at compile time. The default size is 256.SF_CART_INFO: Set number of entries in thetagTextarray member ofSFCartInfowith-d:sfMaxTagTextSize=<n>at compile time. The default size is 256.
nim-sndfile was written by Julien Aubert and this fork was updated, re-factored and extended by Christopher Arndt, while also applying some patches by James Bradbury.
This software is released under the MIT License. See the file LICENSE.md for more information.