WriteWAV#
- class acoular.tprocess.WriteWAV
Bases:
TimeOutSaves time signal from one or more channels as mono, stereo, or multi-channel
.wavfile.Inherits from
TimeOutand allows for exporting time-series data from one or more channels to a WAV file. Supports saving mono, stereo, or multi-channel signals to disk with automatic or user-defined file naming.See also
TimeOutABC for signal processing blocks that interact with data from a source.
SamplesGeneratorInterface for generating multi-channel time domain signal processing blocks.
wavePython module for handling WAV files.
- source = Instance(SamplesGenerator)
The input data source. It must be an instance of a
SamplesGenerator-derived class.
- file = File(filter=['*.wav'])
The name of the file to be saved. If none is given, the name will be automatically generated from the source.
- basename = Property(depends_on=['digest'])
The name of the cache file (without extension). It serves as an internal reference for data caching and tracking processed files. (automatically generated)
- channels = List(int)
The list of channels to save. Can only contain one or two channels.
- encoding = Enum('uint8', 'int16', 'int32')
bit depth of the output file
- max_val = Either(None, Float)
Maximum value to scale the output to.
- digest = Property(depends_on=['source.digest', 'channels'])
A unique identifier for the filter, based on its properties. (read-only)
- result(num)
Generate and save time signal data as a WAV file in blocks.
This generator method retrieves time signal data from the
sourceand writes it to a WAV file in blocks of sizenum. The data is scaled and encoded according to the selected bit depth and channel configuration. If no file name is specified, a name is generated automatically. The method yields each block of data after it is written to the file, allowing for streaming or real-time processing.- Parameters:
- num
int Number of samples per block to write and yield.
- num
- Yields:
numpy.ndarrayThe block of time signal data that was written to the WAV file, with shape (
num, number of channels).
- Raises:
ValueErrorIf no channels are specified for output.
WarningIf more than two channels are specified, or if the sample frequency is not an integer. Also warns if clipping occurs due to data range limitations.
See also
save()Save the entire source output to a WAV file in one call.
- save()
Save the entire source output to a WAV file.
This method writes all available time signal data from the
sourceto the specified WAV file in blocks. It calls theresult()method internally and discards the yielded data. The file is written according to the currentchannels,encoding, and scaling settings. If no file name is specified, a name is generated automatically.See also
result()Generator for writing and yielding data block-wise.