### Install libsamplerate on Linux Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Install the required system library using the apt package manager. ```bash $ sudo apt install libsamplerate0 ``` -------------------------------- ### Install libsamplerate on MacOS Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Install the required system library using Homebrew. ```bash $ brew install libsamplerate ``` -------------------------------- ### Install gosamplerate Go package Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Download and install the gosamplerate package into your Go workspace. ```bash $ go get github.com/dh1tw/gosamplerate ``` -------------------------------- ### Get Converter Description Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Returns the description of a specific sample rate converter. ```go func GetDescription(converter C.int) (string, error) ``` -------------------------------- ### Get Library Version Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Returns the version number of the underlying libsamplerate. ```go func GetVersion() string ``` -------------------------------- ### Get Converter Name Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Returns the name of a specific sample rate converter. ```go func GetName(converter C.int) (string, error) ``` -------------------------------- ### Get Channel Count Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Retrieves the current channel count for the converter. ```go func (src *Src) GetChannels() (int, error) ``` -------------------------------- ### Get Error Number Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Returns the current error number for the Src instance. ```go func (src *Src) ErrorNo() int ``` -------------------------------- ### Initialize New Converter Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Initializes a new converter object and returns a reference to it. ```go func New(converterType int, channels int, bufferLen int) (Src, error) ``` -------------------------------- ### func Simple Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Converts a single block of audio samples in one go. This is suitable for non-streaming data. ```APIDOC ## func Simple(dataIn []float32, ratio float64, channels int, converterType int) ([]float32, error) ### Description Converts a single block of samples (one or more channels) in one go. The simple API is less capable than the full API (Process()) and must not be used if audio is to be converted in chunks. ### Parameters - **dataIn** ([]float32) - Required - The input audio samples. - **ratio** (float64) - Required - The conversion ratio. - **channels** (int) - Required - The number of audio channels. - **converterType** (int) - Required - The type of converter to use (e.g., SRC_SINC_BEST_QUALITY). ### Response - **[]float32** - The converted audio samples. - **error** - An error object if the conversion fails. ``` -------------------------------- ### Perform Simple Conversion Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Converts a single block of samples. Not suitable for streaming or chunked processing. ```go func Simple(dataIn []float32, ratio float64, channels int, converterType int) ([]float32, error) ``` -------------------------------- ### Set Conversion Ratio Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Sets the conversion ratio, bypassing smooth transitions to achieve a step response. ```go func (src *Src) SetRatio(ratio float64) error ``` -------------------------------- ### Process Streaming Data Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate The full API for time-varying sample rate conversion on streaming data. ```go func (src *Src) Process(dataIn []float32, ratio float64, endOfInput bool) ([]float32, error) ``` -------------------------------- ### Validate Conversion Ratio Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Checks if the provided ratio is valid for conversion. ```go func IsValidRatio(ratio float64) bool ``` -------------------------------- ### Define Sample Rate Converter Constants Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Constants representing different quality levels and algorithms for sample rate conversion. ```go const ( SRC_SINC_BEST_QUALITY = C.SRC_SINC_BEST_QUALITY SRC_SINC_MEDIUM_QUALITY = C.SRC_SINC_MEDIUM_QUALITY SRC_SINC_FASTEST = C.SRC_SINC_FASTEST SRC_ZERO_ORDER_HOLD = C.SRC_ZERO_ORDER_HOLD SRC_LINEAR = C.SRC_LINEAR ) ``` -------------------------------- ### Define Src Struct Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate The structure holding data for the full API. ```go type Src struct { // contains filtered or unexported fields } ``` -------------------------------- ### type Src Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate The Src type provides the full API for time-varying sample rate conversion on streaming data. ```APIDOC ## func New(converterType int, channels int, bufferLen int) (Src, error) ### Description Initializes a new converter object for streaming audio processing. ## func (*Src) Process(dataIn []float32, ratio float64, endOfInput bool) ([]float32, error) ### Description Processes a chunk of audio data. This method allows for time-varying sample rate conversion on streaming data. ### Parameters - **dataIn** ([]float32) - Required - The input audio samples. - **ratio** (float64) - Required - The conversion ratio. - **endOfInput** (bool) - Required - Indicates if this is the final chunk of input. ### Response - **[]float32** - The converted audio samples. - **error** - An error object if the processing fails. ``` -------------------------------- ### Delete Converter Instance Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Cleans up all internal allocations for the provided Src instance. ```go func Delete(src Src) error ``` -------------------------------- ### Reset Converter State Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Resets the internal state of the SRC without modifying quality settings or freeing memory. ```go func (src *Src) Reset() error ``` -------------------------------- ### Convert Error Number to String Source: https://pkg.go.dev/github.com/dh1tw/gosamplerate Converts an error number into a human-readable string. ```go func Error(errNo int) string ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.