SoundFormat
- class carb.audio.SoundFormat
Bases:
pybind11_object
Provides information about the format of a sound. When a sound is loaded from a file, its format will be implicitly set on load. The actual format can then be retrieved later with get_format() on a sound data object.
Methods
__init__
(self)Attributes
The number of bits per sample of the audio data.
The size in bytes of a single 'block' of encoded data.
The channel mask for the audio data.
The number of channels of data in each frame of the audio data.
The format of each sample of audio data.
the way it was recorded or produced).
The size in bytes of each frame of data in the format.
The number of frames that will be decoded from a single block of data.
The number of bits of valid data that are present in the audio data.
- __init__(self: carb.audio._audio.SoundFormat) None
- property bits_per_sample
The number of bits per sample of the audio data. This is also encoded in the `format` value, but it is given here as well for ease of use in calculations. This represents the number of bits in the decoded samples of the sound stream. This will be 0 for variable bitrate compressed formats.
- property block_size
The size in bytes of a single ‘block’ of encoded data. For PCM data, this is the same as a frame. For formats with a fixed bitrate, this is the size of a single unit of data that can be decoded. For formats with a variable bitrate, this will be 0. Note that certain codecs can be fixed or variable bitrate depending on the encoder settings.
- property channel_mask
The channel mask for the audio data. This specifies which speakers the stream is intended for and will be a combination of one or more of the `Speaker` names or a `SPEAKER_MODE_*` name. This may be calculated from the number of channels present in the original audio data or it may be explicitly specified in the original audio data on load.
- property channels
The number of channels of data in each frame of the audio data.
- property format
The format of each sample of audio data. This is given as a symbolic name so that the data can be interpreted properly. The size of each sample in bits is also given in the `bits_per_sample` value.
- property frame_rate
the way it was recorded or produced).
- Type
The number of frames per second that must be played back for the audio data to sound ‘normal’ (ie
- property frame_size
The size in bytes of each frame of data in the format. A frame consists of one sample per channel. This represents the size of a single frame of decoded data from the sound stream. This will be 0 for variable bitrate compressed formats.
- property frames_per_block
The number of frames that will be decoded from a single block of data. For PCM formats, this will be 1. For formats with a fixed number of frames per block, this will be number of frames of data that will be produced when decoding a single block of data. Note that variable bitrate formats can have a fixed number of frames per block. For formats with a variable number of frames per block, this will be 0. Note that certain codecs can have a fixed or variable number of frames per block depending on the encoder settings.
- property valid_bits_per_sample
The number of bits of valid data that are present in the audio data. This may be used to specify that (for example) a stream of 24-bit sample data is being processed in 32-bit containers. Each sample will actually consist of 32-bit data in the buffer, using the full 32-bit range, but only the top 24 bits of each sample will be valid useful data. This represents the valid number of bits per sample in the decoded data for the sound stream.