palace
palace.
Buffer
Buffer of preloaded PCM samples coming from a Decoder.
Decoder
Cached buffers must be freed using destroy before destroying context. Alternatively, this can be used as a context manager that calls destroy upon completion of the block, even if an error occurs.
destroy
context
name (str) – Audio file or resource name. Multiple calls with the same name will return the same buffer.
context (Optional[Context], optional) – The context from which the buffer is to be created and cached. By default current_context() is used.
current_context()
name
Audio file or resource name.
str
RuntimeError – If there is neither any context specified nor current.
channel_config
Buffer’s sample configuration.
Free the buffer’s cache.
This invalidates all other Buffer objects with the same name.
frequency
Buffer’s frequency in hertz.
from_decoder
Return a buffer created by reading the given decoder.
decoder (Decoder) – The decoder from which the buffer is to be cached.
name (str) – The name to give to the buffer. It may alias an audio file, but it must not currently exist in the buffer cache.
context (Optional[Context], optional) – The context from which the buffer is to be created. By default current_context() is used.
RuntimeError – If there is neither any context specified nor current; or if name is already used for another buffer.
length
Length of the buffer in sample frames.
length_seconds
Length of the buffer in seconds.
loop_points
Loop points for looping sources.
If AL_SOFT_loop_points extension is not supported by the current context, start = 0 and end = length respectively. Otherwise, start < end <= length.
AL_SOFT_loop_points
start = 0
end = length
start < end <= length
start (int) – Starting point, in sample frames (inclusive).
end (int) – Ending point, in sample frames (exclusive).
Note
The buffer must not be in use when this property is set.
play
Play source using the buffer.
source
Return the source used for playing. If None is given, create a new one.
None
One buffer may be played from multiple sources simultaneously.
sample_type
Buffer’s sample type.
size
Storage size used by the buffer, in bytes.
The size in bytes may not be what you expect from the length, as it may take more space internally than the channel_config and sample_type suggest.
source_count
Number of sources currently using the buffer.
Context.update needs to be called to reliably ensure the count is kept updated for when sources reach their end. This is equivalent to calling len(self.sources).
Context.update
len(self.sources)
sources
Source objects currently playing the buffer.
Source
cache
Cache given audio resources asynchronously.
Duplicate names and buffers already cached are ignored. Cached buffers must be freed before destroying the context.
The resources will be scheduled for caching asynchronously, and should be retrieved later when needed by initializing Buffer corresponding objects. Resources that cannot be loaded, for example due to an unsupported format, will be ignored and a later Buffer initialization will raise an exception.
If context is not given, current_context() will be used.
See also
free
Free cached audio resources given their names
Buffer.destroy
Free the buffer’s cache
Free cached audio resources given their names.