Mixer#
- class acoular.tprocess.Mixer
Bases:
TimeOutMix signals from multiple sources into a single output.
This class takes a
primary time signal sourceand a list ofadditional sourceswith the same sampling rates and channel counts across allprimary time signal source, and outputs a mixed signal. The mixing process is performed block-wise using a generator.If one of the
additional sourcesholds a shorter signal than the other sources theresult()method will stop yielding mixed time signal at that point.- source = Instance(SamplesGenerator)
The primary time signal source. It must be an instance of a
SamplesGenerator-derived class.
- sources = List(Instance(SamplesGenerator, ()))
A list of additional time signal sources to be mixed with the primary source, each must be an instance of
SamplesGenerator.
- sample_freq = Delegate('source')
The sampling frequency of the primary time signal, delegated from
source.
- num_channels = Delegate('source')
The number of channels in the output, delegated from
source.
- num_samples = Delegate('source')
The number of samples in the output, delegated from
source.
- sdigest = Str()
Internal identifier that tracks changes in the
sourceslist.
- digest = Property(depends_on=['source.digest', 'sdigest'])
A unique identifier for the Mixer instance, based on the
primary sourceand thelist of additional sources.
- validate_sources()
Validate whether the additional sources are compatible with the primary source.
This method checks if all sources have the same sampling frequency and the same number of channels. If a mismatch is detected, a
ValueErroris raised.- Raises:
ValueErrorIf any source in
sourceshas a different sampling frequency or number of channels thansource.
- result(num)
Generate mixed time signal data in blocks of
numsamples.This generator method retrieves time signal data from all sources and sums them together to produce a combined output. The data from each source is processed in blocks of the same size, ensuring synchronized mixing.
Note
Yielding stops when one of the additionally provied signals ends; i.e. if one of the additional sources holds a signal of shorter length than that of the
primary sourcethat (shorter) signal forms the lower bound of the length of the mixed time signal yielded.- Parameters:
- num
int Number of samples per block.
- num
- Yields:
numpy.ndarrayAn array containing the mixed time samples in blocks of shape (
num,num_channels), wherenum_channelsis inhereted from theTimeOutbase class. The last block may contain fewer samples if the total number of samples is not a multiple ofnum.