Babycat C API Documentation¶
C header structure¶
Babycat’s C bindings are automatically generated by cbindgen. Babycat’s entire API is described in a single C header file named babycat.h
.
This documentation website splits the Babycat C API across multiple pages, but they all represent symbols directly inserted by babycat.h.
Data structures (structs and typedefs)¶
babycat_WaveformArgs: A struct that describes settings for decoding audio.
babycat_Waveform: A typedef struct that represents a single waveform in memory.
babycat_WaveformResult: A struct that contains either an error code or a pointer to a babycat_Waveform.
#define
-ed constants¶
These constants represent default values for structs as well as error codes that can be returned.
Defines
-
babycat_DEFAULT_START_TIME_MILLISECONDS 0¶
The default start time cutoff when decoding audio. We start at the beginning.
-
babycat_DEFAULT_END_TIME_MILLISECONDS 0¶
The default end time cutoff when decoding audio. We continue decoding until the end of the file.
-
babycat_DEFAULT_FRAME_RATE_HZ 0¶
The default frame rate to resample to. By default, we do not change the frame rate’s audio.
-
babycat_DEFAULT_NUM_CHANNELS 0¶
The default number of channels to decode. By default, we decode all of the available channels.
-
babycat_DEFAULT_CONVERT_TO_MONO false¶
By default, we do not flatten all audio channels into a mono channel.
-
babycat_DEFAULT_ZERO_PAD_ENDING false¶
By default, we do not zero-pad the ending of an audio file.
-
babycat_DEFAULT_REPEAT_PAD_ENDING false¶
By default, we do not repeat-pad the ending of an audio file.
-
babycat_DEFAULT_RESAMPLE_MODE 0¶
Sets the default resampler.
-
babycat_DEFAULT_DECODING_BACKEND 0¶
Sets the default audio decoding backend.
-
babycat_RESAMPLE_MODE_LIBSAMPLERATE 1¶
Use this value to resample audio with libsamplerate.
The libsamplerate resampler is not available when Babycat is compiled to the
wasm32-unknown-unknown
WebAssembly target.
-
babycat_RESAMPLE_MODE_BABYCAT_LANCZOS 2¶
Use this value to resample audio with Babycat’s Lanczos resampler.
-
babycat_RESAMPLE_MODE_BABYCAT_SINC 3¶
Use this value to resample audio with Babycat’s sinc resampler.
-
babycat_DECODING_BACKEND_SYMPHONIA 1¶
Sets the decoding backend as [
SymphoniaDecoder
](crate::decoder::SymphoniaDecoder).
-
babycat_DECODING_BACKEND_FFMPEG 2¶
Sets the decoding backend as [
FFmpegDecoder
](crate::decoder::FFmpegDecoder).
-
babycat_DEFAULT_NUM_WORKERS 0¶
The default number of threads to use for multithreaded operations. By default, we will initialize as many threads as logical CPU cores on your machine.
-
babycat_NO_ERROR 0¶
Returned when a given operation has succeeded without any error.
-
babycat_ERROR_FEATURE_NOT_COMPILED 100¶
Returned when you are trying to use a feature at runtime that was not included at compile-time.
For example, you may receive this error if you are trying to resample audio using a method that was not compiled for your target or binding.
-
babycat_ERROR_WRONG_TIME_OFFSET 200¶
Returned when
start_time_milliseconds
orend_time_milliseconds
is invalid.
-
babycat_ERROR_WRONG_NUM_CHANNELS 201¶
Returned when you wanted to decode more channels than the audio actually had.
-
babycat_ERROR_WRONG_NUM_CHANNELS_AND_MONO 202¶
Returned if you specified
convert_to_mono
astrue
andnum_channels
as 1.
-
babycat_ERROR_CANNOT_ZERO_PAD 203¶
Returned if you set
zero_pad_ending
astrue
without also specifyingend_time_milliseconds
.
-
babycat_ERROR_CANNOT_REPEAT_PAD 204¶
Returned if you set
repeat_pad_ending
astrue
without also specifyingend_time_milliseconds
.
-
babycat_ERROR_CANNOT_ZERO_PAD_AND_REPEAT_PAD 205¶
Returned if you try setting both
zero_pad_ending
andrepeat_pad_ending
astrue
.
-
babycat_ERROR_UNKNOWN_INPUT_ENCODING 300¶
Returned when we were not able to detect the encoded input as decodable audio.
-
babycat_ERROR_UNKNOWN_DECODE_ERROR 301¶
Returned when we were not able to decode the given (encoded) audio.
-
babycat_ERROR_UNKNOWN_DECODING_BACKEND 302¶
Returned when we were not able to recognize the given decoding backend.
-
babycat_ERROR_NO_SUITABLE_AUDIO_STREAMS 303¶
-
babycat_ERROR_UNKNOWN_ENCODE_ERROR 400¶
Returned whe we encountered an unknown error when encoding a waveform into particular format.
-
babycat_ERROR_RESAMPLING_ERROR 500¶
Returned when we were not able to resample the audio.
-
babycat_ERROR_WRONG_FRAME_RATE 501¶
Returned when we cannot resample from the input frame rate to the output frame rate.
-
babycat_ERROR_WRONG_FRAME_RATE_RATIO 502¶
Returned if you are trying to upsample or downsample audio by a factor greater than 256.
-
babycat_ERROR_FILENAME_IS_A_DIRECTORY 600¶
Returned if you asked Babycat to read a file, but you gave it a path to a directory.
-
babycat_ERROR_FILE_NOT_FOUND 601¶
Returned if you asked Babycat to read a file that does not exist.
-
babycat_ERROR_UNKNOWN_IO_ERROR 602¶
Returned when something else went wrong while doing I/O.
-
babycat_ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_NUM_CHANNELS 701¶
Returned when we try to append two audio sources that have a different number of channels.
-
babycat_ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_FRAME_RATES 702¶
Returned when we try to append two audio sources that have different frame rates.