Acoular 25.04 documentation

GenericSignalGenerator

«  SineGenerator   ::   signals   ::   sources  »

GenericSignalGenerator

class acoular.signals.GenericSignalGenerator

Bases: SignalGenerator

Generate signals from a SamplesGenerator or derived object.

The GenericSignalGenerator class enables the integration of arbitrary signals into Acoular processing chains. The signal is fetched from a specified data source and optionally scaled by an amplitude factor. It supports looping the signal to match the desired number of samples and can handle signals with multiple channels (only the first channel is used).

Common use cases include:
  • Injecting custom or pre-recorded signals from HDF5 files.

  • Creating signals using the TimeSamples class.

  • Generating a continuous or repeated signal for simulations.

Notes

If the signal source has more than one channel, only channel 0 is used.

Examples

Inject a random signal into a processing chain:

>>> import acoular as ac
>>> import numpy as np
>>>
>>> data = np.random.rand(1000, 1)
>>> ts = ac.TimeSamples(data=data, sample_freq=51200)
>>> sig = ac.GenericSignalGenerator(source=ts)
>>> output_signal = sig.signal()
source = Instance(SamplesGenerator)

The data source from which the signal is fetched. This can be any object derived from SamplesGenerator.

amplitude = Float(1.0)

Scaling factor applied to the generated signal. Defaults to 1.0.

sample_freq = Delegate('source')

Sampling frequency of the output signal, as provided by the source object.

num_samples = Property()

The number of samples to generate. Default is the number of samples available in the source (source.num_samples). If set explicitly, it can exceed the source length, in which case the signal will loop if loop_signal is True.

loop_signal = Bool(True)

If True (default), the signal is repeated to meet the requested num_samples. If False, the signal stops once the source data is exhausted.

digest = Property(

A unique checksum identifier based on the object properties. (read-only)

signal()

Deliver the signal from the specified source.

Returns:
numpy.array of floats

The resulting signal, scaled by the amplitude attribute, with a length matching num_samples.

Warning

A warning is raised if the source has more than one channel.

«  SineGenerator   ::   signals   ::   sources  »