chaudio.arrangers¶
Arrangers (chaudio.arrangers
)¶
Can record inputs, and detect if they change, and regenerate their source automatically
This is essentially “smart” JIT audio production
An Arranger can have another Arranger inserted, and it will keep track of whether the sources have changed, only recalculating if needed.
Classes
Arranger (**kwargs) |
this class is for combining sounds together, given a point, and applying plugins: |
ExtendedArranger (**kwargs) |
Extends the basic arranger (chaudio.arrangers.Arranger ) |
InsertCall (key, val, kwargs) |
Data structure to have handle each time something is inserted, so that the action can be reconstructed later |
-
class
chaudio.arrangers.
InsertCall
(key, val, kwargs)[source]¶ Data structure to have handle each time something is inserted, so that the action can be reconstructed later
-
__init__
(key, val, kwargs)[source]¶ Initializes an insert call
Parameters: - key (obj) – Key used to input
- val (obj) – Value given to set at
key
- kwargs (dict) – Which arguments were given with the insertion
Returns: The result representing an insert call
Return type:
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
chaudio.arrangers.
Arranger
(**kwargs)[source]¶ this class is for combining sounds together, given a point, and applying plugins:
Only has support for inputting at a number of samples, serves as a base class.
chaudio.arrangers.ExtendedArranger
is probably the best for most users-
__init__
(**kwargs)[source]¶ Initializes an arranger
Parameters: kwargs ((keyword arguments)) – Which arguments were given and should be used in operations. Essentially config options. Returns: The result representing an insert call Return type: chaudio.arrangers.InsertCall
-
getarg
(key, default=None)[source]¶ Returns the value stored in key word arguments, or a default if it is not contained
Parameters: - key (obj) – Key, normally a str
- default (obj) – What to return if the key word arguments does not contain the specified key
Returns: The value stored in key word arguments, or a default if it is not contained
Return type: obj
-
setarg
(key, val, replace=True)[source]¶ Sets the argument, specifying whether or not to override
Parameters: - key (obj) – Key, normally a str
- val (obj) – value to store
- replace (bool) – If True, replace if
key
is already contained. If not, only replace if the key is not in the key word arguments
-
add_insert_plugin
(plugin)[source]¶ Adds a plugin that is applied when a clip or value is inserted
See
chaudio.plugins
for some plugins, and a description.Essentially,
plugin
is added to the chain (at the end), which processes the output of the previous plugin (or it is the first, in which case it acts on the data inserted).Parameters: plugin ( chaudio.plugins.Basic
) – What plugin to addReturns: index of the plugin, such that plugin == arranger.insert_plugins[RETURN]
whereRETURN
is the return value of this function.Return type: int
-
add_final_plugin
(plugin)[source]¶ Adds a plugin that is applied to the entire arranger’s computed things.
See
chaudio.plugins
for some plugins, and a description.Essentially,
plugin
is added to the chain (at the end), which processes the output of the previous plugin (or it is the first, in which case it acts on the data inserted).First, each insert has all the insert plugins applied (see method
chaudio.arrangers.Arranger.add_insert_plugin()
), and all of the inserted sources are combined and inserted at their respective places, and all the final plugins are applied.Parameters: plugin ( chaudio.plugins.Basic
) – What plugin to addReturns: index of the plugin, such that plugin == arranger.final_plugins[RETURN]
whereRETURN
is the return value of this function.Return type: int
-
apply_insert
(insert_call)[source]¶ Internal method to apply an insert call object
Essentially change self._source by applying an insert. This method exists so that inserted values can be changed, and internal references can be updated if any change.
Parameters: insert_call ( chaudio.arrangers.InsertCall
) – What data structure to insert
-
insert_sample
(sample, _data, **kwargs)[source]¶ Inserts data at an offset, in sample measurements
Add a insert value which adds
_data
at the offsetsample
. Note that this doesn’t take into account the time in seconds, for that usechaudio.arrangers.ExtendedArranger
, specifically the methodchaudio.arrangers.ExtendedArranger.insert_time()
Parameters: insert_call ( chaudio.arrangers.InsertCall
) – What data structure to insert
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
chaudio.arrangers.
ExtendedArranger
(**kwargs)[source]¶ Extends the basic arranger (
chaudio.arrangers.Arranger
)-
__init__
(**kwargs)[source]¶ Initializes the ExtendedArranger.
Add a insert value which adds
_data
at the offsetsample
. Note that this doesn’t take into account the time in seconds, for that usechaudio.arrangers.ExtendedArranger
, specifically the methodchaudio.arrangers.ExtendedArranger.insert_time()
Keyword arguments:
Hz: int, the samplerate
Timesignature: chaudio.util.TimeSignature
, which is the time signature used. The default is 4/4 in 60 bpm (so that 1 beat == 1 second)Setitem: either “sample”, “time”, or “beat”. This controls how the
chaudio.arrangers.ExtendedArranger.__setitem__()
functionality works (when you call it like extarranger[X] = Y.if
setitem == "sample"
, theX
is treated as the sample (and the behaviour is the same aschaudio.arrangers.Arranger
). This is the default.if
setitem == "time"
, theX
is treated as the time in secondsif
setitem == "beat"
, theX
is treated as a number of beats, and is used in accordance withtimesignature
(see above). Or, it can be a tuple ofmeasures, beats
. For example,extarranger[M, B] = Y
can be used.Parameters: kwargs ((key word arguments)) – Extended arranger adds
hz
,timesignature
, andsetitem
as usage values. See the description above for an explanation of these.
-
insert_time
(t, _data)[source]¶ Inserts audio data at a specified time (in seconds)
Parameters: - t (int, float) – Time, in seconds, to apply the audio at
- _data (list, tuple, np.ndarray,
chaudio.source.Source
,chaudio.arrangers.Arranger
) – This is the data (which can be any generic format, the internal classes will figure out how to make it work out).
-
insert_beat
(beat, _data)[source]¶ Inserts audio data at a specified time (in beats, or in (measures, beats) format)
Parameters: - beat (int, float, tuple) – The number of beats, or a tuple containing
measures, beats
. This is converted to time, whichchaudio.arrangers.ExtendedArranger.insert_time()
is called internally. - _data (list, tuple, np.ndarray,
chaudio.source.Source
,chaudio.arrangers.Arranger
) – This is the data (which can be any generic format, the internal classes will figure out how to make it work out).
- beat (int, float, tuple) – The number of beats, or a tuple containing
-