palace
palace.
Decoder
Generic audio decoder.
name (str) – Audio file or resource name.
context (Optional[Context], optional) – The context from which the decoder is to be created. By default current_context() is used.
current_context()
RuntimeError – If there is neither any context specified nor current.
See also
Buffer
Preloaded PCM samples coming from a Decoder
Note
Due to implementation details, while this creates decoder objects from filenames using contexts, it is the superclass of the ABC (abstract base class) BaseDecoder. Because of this, Decoder may only initialize an internal one. To use registered factories, please call the module-level decode function instead.
BaseDecoder
decode
channel_config
Channel configuration of the audio being decoded.
frequency
Sample frequency, in hertz, of the audio being decoded.
length
Length of audio in sample frames, falling-back to 0.
Zero-length decoders may not be used to load a Buffer.
length_seconds
Length of audio in seconds, falling-back to 0.0.
loop_points
Loop points in sample frames.
start (int) – Inclusive starting loop point.
end (int) – Exclusive starting loop point.
If start >= end, all available samples are included in the loop.
start >= end
play
Stream audio asynchronously from the decoder.
The decoder must NOT have its read or seek called from elsewhere while in use.
read
seek
chunk_len (int) – The number of sample frames to read for each chunk update. Smaller values will require more frequent updates and larger values will handle more data with each chunk.
queue_size (int) – The number of chunks to keep queued during playback. Smaller values use less memory while larger values improve protection against underruns.
source (Optional[Source], optional) – The source object to play audio. If None is given, a new one will be created from the current context.
None
The source used for playing.
Decode and return count sample frames.
count
If less than the requested count samples is returned, the end of the audio has been reached.
sample_length
length of samples of given size
sample_type
Sample type of the audio being decoded.
Seek to pos, specified in sample frames.
pos
Return if the seek was successful.
decoder_factories
Simple object for storing decoder factories.
User-registered factories are tried one after another if RuntimeError is raised, in lexicographical order. Internal decoder factories are always used after registered ones.
RuntimeError
Return the decoder created from the given resource name.
This first tries user-registered decoder factories in lexicographical order, then fallback to the internal ones.
Simple object for storing decoder factories
Audio decoder interface.
Applications may derive from this, implement necessary methods, and use it in places the API wants a BaseDecoder object.
Exceptions raised from BaseDecoder instances are ignored.
sample_types
Names of available sample types.
channel_configs
Names of available channel configurations.
sample_size
Return the size of the given number of sample frames.
ValueError – If either channel_config or sample_type is invalid.
RuntimeError – If the byte size result too large.
Return the number of frames stored in the given byte size.