Skip to content

API Reference

Complete reference for all SoundFile classes, functions, and enums.

  • Global Functionssf_read, sf_write, sf_info, sf_check_format, sf_resample
  • SoundFile — Opened audio file handle with read, write, seek, blocks, and metadata
  • SfInfo — Immutable signal properties
  • SfMetadata — Immutable embedded string tags
  • EnumsAudioFormat, SampleFormat, FileMode, ResampleQuality
  • ExceptionsSoundFileException

Quick Reference

Global Functions

FunctionReturnsDescription
sf_read(file, start?, stop?, always2d?, blocksize?)[NDArray, SfInfo]Read audio file into NDArray
sf_write(file, data, sampleRate, format?, subtype?)voidWrite NDArray to audio file
sf_info(file)SfInfoRead file metadata without loading data
sf_metadata(file)SfMetadataRead string tags without loading audio
sf_check_format(format, subtype)boolValidate format/subtype compatibility
sf_resample(data, inRate, outRate, quality?, chunkSize?)NDArrayConvert sample rate

SoundFile Instance

MethodDescription
read(?int $n)Read frames from current position
write(NDArray $data)Write frames
seek(int $offset, int $whence)Move position
tell()Current position
eof()End of file reached
blocks(int $size)Generator yielding NDArrays
close()Close the handle
info()Full file metadata
title() / setTitle()Metadata accessors

SfInfo

MethodReturnsDescription
duration()floatDuration in seconds
nSamples()intTotal sample count
withFrames($n)selfBuilder — change frames

Released under the MIT License.