boodle.sample
index
boodle/sample.py

sample: A module containing the Sample class; also the SampleLoader
classes, which know how to load data from various sound files (AIFF,
WAV, etc).
 
Public functions:
 
get() -- load a sample object, given a filename or File object
get_info() -- measure the expected running time and looping params of a sound

 
Modules
       
aifc
bisect
boodle
boopak
os
boodle.stereo
struct
sunau
wave

 
Classes
       
boodle.BoodlerError(builtins.Exception)
SampleError
builtins.object
MixIn
Sample
MixinSample
SampleLoader
AifcLoader
MixinLoader
SunAuLoader
WavLoader

 
class AifcLoader(SampleLoader)
    SampleLoader: Base class for the facility to load a particular
form of sound sample from a file.
 
Subclasses of this are defined and instantiated later in the module.
 
 
Method resolution order:
AifcLoader
SampleLoader
builtins.object

Methods defined here:
raw_load(self, filename, csamp)

Data and other attributes defined here:
suffixlist = ['.aifc', '.aiff', '.aif']

Methods inherited from SampleLoader:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
load(self, filename, suffix)
register_suffixes(self)
reload(self, samp)

Data descriptors inherited from SampleLoader:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from SampleLoader:
suffixmap = {'.aif': <boodle.sample.AifcLoader object>, '.aifc': <boodle.sample.AifcLoader object>, '.aiff': <boodle.sample.AifcLoader object>, '.au': <boodle.sample.SunAuLoader object>, '.mixin': <boodle.sample.MixinLoader object>, '.wav': <boodle.sample.WavLoader object>}

 
class MixIn(builtins.object)
    MixIn: base class for statically declared mix-in samples.
 
To use this, declare a construct:
 
class your_sample_name(MixIn):
    ranges = [
        MixIn.range(...),
        MixIn.range(...),
        MixIn.range(...),
    ]
    default = MixIn.default(...)
 
A range declaration looks like
 
    MixIn.range(maxval, sample)
or
    MixIn.range(minval, maxval, sample)
or
    MixIn.range(minval, maxval, sample, pitch=1.0, volume=1.0)
 
If you don't give a minval, the maxval of the previous range is used.
You may use the constants MixIn.MIN and MixIn.MAX to represent the
limits of the range. The pitch and volume arguments are optional.
 
A default declaration looks like
 
    MixIn.default(sample)
or
    MixIn.default(sample, pitch=1.0, volume=1.0)
 
The default declaration is option. (As are, again, the pitch and
volume arguments.)
 
When your declaration is complete, your_sample_name will magically
be a MixinSample instance (not a class).
 
  Static methods defined here:

 
__class__ = class type(object)
    type(object_or_name, bases, dict)
type(object) -> the object's type
type(name, bases, dict) -> a new type
 
  Methods defined here:
__call__(self, /, *args, **kwargs)
Call self as a function.
__delattr__(self, name, /)
Implement delattr(self, name).
__dir__(self, /)
Specialized __dir__ implementation for types.
__getattribute__(self, name, /)
Return getattr(self, name).
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
__instancecheck__(self, instance, /)
Check if an object is an instance.
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
__sizeof__(self, /)
Return memory consumption of the type object.
__subclasscheck__(self, subclass, /)
Check if a class is a subclass.
__subclasses__(self, /)
Return a list of immediate subclasses.
mro(self, /)
Return a type's method resolution order.

Class methods defined here:
__prepare__(...)
__prepare__() -> dict
used to create the namespace for the class statement

Static methods defined here:
__new__(*args, **kwargs)
Create and return a new object.  See help(type) for accurate signature.

Data descriptors defined here:
__abstractmethods__
__dict__
__text_signature__

Data and other attributes defined here:
__base__ = <class 'object'>
The most base type
__bases__ = (<class 'object'>,)
__basicsize__ = 864
__dictoffset__ = 264
__flags__ = 2148291584
__itemsize__ = 40
__mro__ = (<class 'type'>, <class 'object'>)
__weakrefoffset__ = 368

default(samp, pitch=None, volume=None)
sort_mixin_ranges(ranges)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
MAX = 1000000.0
MIN = 0.0
range = <class 'boodle.sample.MixIn.range'>

 
class MixinLoader(SampleLoader)
    SampleLoader: Base class for the facility to load a particular
form of sound sample from a file.
 
Subclasses of this are defined and instantiated later in the module.
 
 
Method resolution order:
MixinLoader
SampleLoader
builtins.object

Methods defined here:
load(self, filename, suffix)
parseparam(self, filename, dirname, tok)
reload(self, samp)

Data and other attributes defined here:
suffixlist = ['.mixin']

Methods inherited from SampleLoader:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
register_suffixes(self)

Data descriptors inherited from SampleLoader:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from SampleLoader:
suffixmap = {'.aif': <boodle.sample.AifcLoader object>, '.aifc': <boodle.sample.AifcLoader object>, '.aiff': <boodle.sample.AifcLoader object>, '.au': <boodle.sample.SunAuLoader object>, '.mixin': <boodle.sample.MixinLoader object>, '.wav': <boodle.sample.WavLoader object>}

 
class MixinSample(Sample)
    MixinSample(filename, ranges, default, modname=None)
 
Sample: represents a sound file, held in memory.
 
This is really just a container for a native object (csamp), which
is used by the cboodle native module. Samples may only be created
by the SampleLoader classes in this module.
 
 
Method resolution order:
MixinSample
Sample
builtins.object

Methods defined here:
__init__(self, filename, ranges, default, modname=None)
Initialize self.  See help(type(self)) for accurate signature.
find(self, pitch)
get_info(self, pitch=1.0)
queue_note(self, pitch, volume, pan, starttime, chan)
queue_note_duration(self, pitch, volume, pan, starttime, duration, chan)

Methods inherited from Sample:
__repr__(self)
Return repr(self).

Data descriptors inherited from Sample:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from Sample:
reloader = None

 
class Sample(builtins.object)
    Sample(filename, csamp)
 
Sample: represents a sound file, held in memory.
 
This is really just a container for a native object (csamp), which
is used by the cboodle native module. Samples may only be created
by the SampleLoader classes in this module.
 
  Methods defined here:
__init__(self, filename, csamp)
Initialize self.  See help(type(self)) for accurate signature.
__repr__(self)
Return repr(self).
get_info(self, pitch=1.0)
queue_note(self, pitch, volume, pan, starttime, chan)
queue_note_duration(self, pitch, volume, pan, starttime, duration, chan)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
reloader = None

 
class SampleError(boodle.BoodlerError)
    SampleError: Represents problems encountered while finding or
loading sound files.
 
 
Method resolution order:
SampleError
boodle.BoodlerError
builtins.Exception
builtins.BaseException
builtins.object

Data descriptors inherited from boodle.BoodlerError:
__weakref__
list of weak references to the object (if defined)

Methods inherited from builtins.Exception:
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from builtins.Exception:
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__delattr__(self, name, /)
Implement delattr(self, name).
__getattribute__(self, name, /)
Return getattr(self, name).
__reduce__(...)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
__setstate__(...)
__str__(self, /)
Return str(self).
with_traceback(...)
Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
exception cause
__context__
exception context
__dict__
__suppress_context__
__traceback__
args

 
class SampleLoader(builtins.object)
    SampleLoader: Base class for the facility to load a particular
form of sound sample from a file.
 
Subclasses of this are defined and instantiated later in the module.
 
  Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
load(self, filename, suffix)
register_suffixes(self)
reload(self, samp)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
suffixmap = {'.aif': <boodle.sample.AifcLoader object>, '.aifc': <boodle.sample.AifcLoader object>, '.aiff': <boodle.sample.AifcLoader object>, '.au': <boodle.sample.SunAuLoader object>, '.mixin': <boodle.sample.MixinLoader object>, '.wav': <boodle.sample.WavLoader object>}

 
class SunAuLoader(SampleLoader)
    SampleLoader: Base class for the facility to load a particular
form of sound sample from a file.
 
Subclasses of this are defined and instantiated later in the module.
 
 
Method resolution order:
SunAuLoader
SampleLoader
builtins.object

Methods defined here:
raw_load(self, filename, csamp)

Data and other attributes defined here:
suffixlist = ['.au']

Methods inherited from SampleLoader:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
load(self, filename, suffix)
register_suffixes(self)
reload(self, samp)

Data descriptors inherited from SampleLoader:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from SampleLoader:
suffixmap = {'.aif': <boodle.sample.AifcLoader object>, '.aifc': <boodle.sample.AifcLoader object>, '.aiff': <boodle.sample.AifcLoader object>, '.au': <boodle.sample.SunAuLoader object>, '.mixin': <boodle.sample.MixinLoader object>, '.wav': <boodle.sample.WavLoader object>}

 
class WavLoader(SampleLoader)
    SampleLoader: Base class for the facility to load a particular
form of sound sample from a file.
 
Subclasses of this are defined and instantiated later in the module.
 
 
Method resolution order:
WavLoader
SampleLoader
builtins.object

Methods defined here:
raw_load(self, filename, csamp)

Data and other attributes defined here:
suffixlist = ['.wav']

Methods inherited from SampleLoader:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
load(self, filename, suffix)
register_suffixes(self)
reload(self, samp)

Data descriptors inherited from SampleLoader:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from SampleLoader:
suffixmap = {'.aif': <boodle.sample.AifcLoader object>, '.aifc': <boodle.sample.AifcLoader object>, '.aiff': <boodle.sample.AifcLoader object>, '.au': <boodle.sample.SunAuLoader object>, '.mixin': <boodle.sample.MixinLoader object>, '.wav': <boodle.sample.WavLoader object>}

 
Functions
       
adjust_timebase(trimoffset, maxage)
find_loader(suffix)
find_loader(suffix) -> SampleLoader
 
Locate the SampleLoader instance which handles the given file
suffix. (The suffix should be given as a dot followed by lower-case
characters.)
get(sname)
get(sample) -> Sample
 
Load a sample object, given a filename or File object. (You can also
pass a Sample object; it will be returned back to you.)
 
(If the filename is relative, $BOODLER_SOUND_PATH is searched.)
 
The module maintains a cache of sample objects, so if you load the
same filename twice, the second get() call will be fast.
 
This function is not useful, since agent.sched_note() and such methods
call it for you -- they accept filenames as well as sample objects.
This function is available nevertheless.
get_info(samp, pitch=1)
get_info(sample, pitch=1) -> tuple
 
Measure the expected running time and looping parameters of a sound.
The argument can be either a filename, or a sample object (as
returned by get()).
 
The result is a 2-tuple. The first member is the duration of the
sound (in seconds, if played with the given pitch -- by default,
the sound's original pitch). The second member is None, if the
sound has no looping parameters, or a 2-tuple (loopstart, loopend).
 
The result of this function may not be precisely accurate, due
to rounding annoyances. In particular, the duration may not be
exactly equal to the value returned by agent.sched_note(), when
the note is actually played.
unload_unused(deathtime)

 
Data
        aifc_loader = <boodle.sample.AifcLoader object>
big_endian = 0
cache = {}
cboodle = <boodle.DummyDriver>
mixin_loader = <boodle.sample.MixinLoader object>
sound_dirs = ['.']
sunau_loader = <boodle.sample.SunAuLoader object>
wav_loader = <boodle.sample.WavLoader object>