Parallel Processing¶
soundscapy.audio.parallel_processing
¶
Functions for parallel processing of binaural audio files.
It includes functions to load and analyze binaural files, as well as to process multiple files in parallel using concurrent.futures.
| FUNCTION | DESCRIPTION |
|---|---|
tqdm_write_sink |
Custom sink for loguru that writes messages using tqdm.write(). |
load_analyse_binaural |
Load and analyze a single binaural audio file. |
parallel_process |
Process multiple binaural files in parallel. |
tqdm_write_sink
¶
Custom sink for loguru that writes messages using tqdm.write().
This ensures that log messages don't interfere with tqdm progress bars.
Source code in src/soundscapy/audio/parallel_processing.py
load_analyse_binaural
¶
load_analyse_binaural(
wav_file: Path,
levels: dict[str, float] | list[float] | None,
analysis_settings: AnalysisSettings,
resample: int | None = None,
*,
parallel_mosqito: bool = True,
) -> pd.DataFrame
Load and analyze a single binaural audio file.
| PARAMETER | DESCRIPTION |
|---|---|
wav_file
|
Path to the WAV file.
TYPE:
|
levels
|
Dictionary with calibration levels for each channel. |
analysis_settings
|
Analysis settings object.
TYPE:
|
resample
|
Sampling rate to resample the audio to before analysis.
TYPE:
|
parallel_mosqito
|
Whether to process MoSQITo metrics in parallel. Defaults to True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with analysis results. |
Source code in src/soundscapy/audio/parallel_processing.py
parallel_process
¶
parallel_process(
wav_files: list[Path],
results_df: DataFrame,
levels: dict,
analysis_settings: AnalysisSettings,
max_workers: int | None = None,
resample: int | None = None,
*,
parallel_mosqito: bool = True,
) -> pd.DataFrame
Process multiple binaural files in parallel.
| PARAMETER | DESCRIPTION |
|---|---|
wav_files
|
List of WAV files to process. |
results_df
|
Initial results DataFrame to update.
TYPE:
|
levels
|
Dictionary with calibration levels for each file.
TYPE:
|
analysis_settings
|
Analysis settings object.
TYPE:
|
max_workers
|
Maximum number of worker processes. If None, it will default to the number of processors on the machine.
TYPE:
|
resample
|
Sampling rate to resample the audio to before analysis.
TYPE:
|
parallel_mosqito
|
Whether to process MoSQITo metrics in parallel within each file. Defaults to True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Updated results DataFrame with analysis results for all files. |