Analyze, visualize and process sound field data recorded by spherical microphone arrays.

Overview

Sound Field Analysis toolbox for Python

Mentioned in Awesome Python for Scientific Audio icon_travis icon_appveyor

The sound_field_analysis toolbox (short: sfa) is a Python port of the Sound Field Analysis Toolbox (SOFiA) toolbox, originally by Benjamin Bernschütz [1]. The main goal of the sfa toolbox is to analyze, visualize and process sound field data recorded by spherical microphone arrays. Furthermore, various types of test-data may be generated to evaluate the implemented functions. It is an essential building block of ReTiSAR, an implementation of real time binaural rendering of spherical microphone array data.

Requirements

We use Python 3.9 for development. Chances are that earlier version will work too but this is currently untested.

The following external libraries are required:

Installation

For performance and convenience reasons we highly recommend to use Conda (miniconda for simplicity) to manage your Python installation. Once installed, you can use the following steps to receive and use sfa, depending on your use case:

  • From PyPI / pip:

    Install into an existing environment (without example Jupyter Notebooks):
    pip install sound_field_analysis
  • By cloning (or downloading) the repository and setting up a new environment:

    git clone https://github.com/AppliedAcousticsChalmers/sound_field_analysis-py.git
    cd sound_field_analysis-py/
    Create a new Conda environment from the specified dependencies:
    conda env create --file environment.yml --force
    Activate the environment:
    source activate sfa
    Optional: Install additional dependencies for development purposes (locally run Jupyter Notebooks with example, run tests, generate documentation):
    conda env update --file environment_dev.yml

Documentation

https://appliedacousticschalmers.github.io/sound_field_analysis-py/ and offline as PDF.

Note: Verify the version number of the documentation to see if it reflects the latest changes.

Examples

The following examples are available as Jupyter Notebooks, either statically on GitHub or interactively on nbviewer. You can of course also simply download the examples and run them locally!

Exp1: Ideal plane wave

Ideal unity plane wave simulation and 3D plot.

View interactively on nbviewer

AE1_img

Exp2: Measured plane wave

A measured plane wave from AZ=180°, EL=90° in the anechoic chamber using a cardioid mic.

View interactively on nbviewer

AE2_img

Exp4: Binaural rendering

Render a spherical microphone array impulse response measurement binaurally. The example shows examples for loading miro or SOFA files.

View interactively on nbviewer

AE4_img

Version history

unreleased
  • Update miro_to_struct() to work in modern Matlab versions
  • Update MIRO struct loading for SphericalGrid (forgiving empty radius and quadrature weights)
  • Add optional automatic limitation of y-axis range in plot2D()
  • Implement frac_oct_smooth_fd() with fractional octave smoothing of magnitude spectra
  • Add option for fractional octave smoothing of magnitude spectra to plot2D()
  • Fix Exp4 to replace removed deg2rad and rad2deg utility functions
v2021.2.4
  • Implement option to use real spherical harmonic basis functions
  • Update Exp4 to optionally utilize real spherical harmonics
  • Fix testing of spherical harmonics against reference Matlab implementation
  • Add testing for generation of real spherical harmonics
  • Add evaluation of performance for generation of complex and real spherical harmonics
  • Add evaluation of performance for spatial sound field decomposition
  • Remove deg2rad and rad2deg utility functions (replaced by NumPy equivalent)
  • Update Conda environment setup to combine all development dependencies
  • Update online and offline documentation
v2021.1.12
  • Update MIRO struct loading for SphericalGrid (quadrature weights are now optional)
  • Fix to prevent Python 3.8 syntax warnings
  • Improve Exp4 (general code structure and utilizing Spherical Head Filter and Spherical Harmonics Tapering)
v2020.1.30
  • Update README and PyPI package
v2019.11.6
  • Update internal documentation and string formatting
v2019.8.15
  • Change version number scheme to CalVer
  • Improve Exp4
  • Update read_SOFA_file()
  • Update 2D plotting functions
  • Improve write_SSR_IRs()
  • Improve Conda environment setup for Jupyter Notebooks
  • Update miro_to_struct()
2019-07-30 (v0.9)
  • Implement SOFA import
  • Update Exp4 to contain SOFA import
  • Delete obsolete Exp3
  • Add named tuple HRIRSignal
  • Implement cart2sph() and sph2cart() utility functions
  • Add Conda environment file for convenient installation of required packages
2019-07-11 (v0.8)
  • Implement Spherical Harmonics coefficients tapering
  • Update Spherical Head Filter to consider tapering
2019-06-17 (v0.7)
  • Implement Bandwidth Extension for Microphone Arrays (BEMA)
  • Edit read_miro_struct(), named tuple ArraySignal and miro_to_struct.m to load center measurements
2019-06-11 (v0.6)
2019-05-23 (v0.5)
  • Implement Spherical Head Filter
  • Implement Spherical Fourier Transform using pseudo-inverse
  • Extract real time capable spatial Fourier transform
  • Extract reversed m index function (Update Exp4)

Contribute

See CONTRIBUTE.rst for full details.

License

This software is licensed under the MIT License (see LICENSE for full details).

References

The sound_field_analysis toolbox is based on the Matlab/C++ Sound Field Analysis Toolbox (SOFiA) toolbox by Benjamin Bernschütz. For more information you may refer to the original publication:

[1] Bernschütz, B., Pörschmann, C., Spors, S., and Weinzierl, S. (2011). SOFiA Sound Field Analysis Toolbox. Proceedings of the ICSA International Conference on Spatial Audio

The Lebedev grid generation was adapted from an implementation by Richard P. Muller.

Comments
  • Examples fail because of plot.plot3Dgrid()

    Examples fail because of plot.plot3Dgrid()

    With a recent Anaconda environment plot.plot3Dgrid() throws:

      File "/home/chris/git/sound_field_analysis-py/examples/Exp1_IdealPlaneWave.py", line 76, in <module>
        fig = plot.plot3Dgrid(rows=1, cols=2, viz_data=[vizMTX_ideal, vizMTX_simulated], style='shape')
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/sound_field_analysis/plot.py", line 442, in plot3Dgrid
        fig.append_trace(genVisual(viz_data[IDX], style=style, normalize=normalize), cur_row, cur_col)
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/plotly/basedatatypes.py", line 1214, in append_trace
        self.add_trace(trace=trace, row=row, col=col)
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/plotly/basedatatypes.py", line 1061, in add_trace
        cols=[col] if col is not None else None
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/plotly/basedatatypes.py", line 1128, in add_traces
        BaseFigure._validate_rows_cols('rows', n, rows)
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/plotly/basedatatypes.py", line 986, in _validate_rows_cols
        name=name, n=n, invalid=vals)
    
      File "/home/chris/anaconda3/envs/sfpy/lib/python3.6/site-packages/plotly/basedatatypes.py", line 973, in _raise_invalid_rows_cols
        raise ValueError(rows_err_msg)
    
    ValueError: 
            If specified, the rows parameter must be a list or tuple of integers
            of length 1 (The number of traces being added)
    
            Received: [1]
    
    opened by chris-hld 4
  • Rework uncertainties in package structure

    Rework uncertainties in package structure

    • [x] from . import * in __init__.py (giving problems with dependency plotly being optional)
    • [x] additions in .gitignore
    • [x] removal of (redundant) py-files next to Jupyter examples
    • [ ] any other problems?
    opened by HaHeho 4
  • Add license_file entry

    Add license_file entry

    This will bundle LICENSE file when building sdist and wheels, which in turn is required by conda-forge (see https://github.com/conda-forge/sound_field_analysis-feedstock/pull/9)

    opened by chohner 3
  • Change to a more liberal license?

    Change to a more liberal license?

    Is this project using code that forces you to use the GPL?

    If not, you should consider using a more liberal license. Using the GPL is quite uncommon in the Python community.

    opened by mgeier 3
  • gen.idealWave() fails on Windows Python 3.5 (x64)

    gen.idealWave() fails on Windows Python 3.5 (x64)

    AE1_IdealPlaneWave.py IdealWave Generator

    Warning (from warnings module): File "..\sound_field_analysis\sph.py", line 211 return spbessel(n, krm) - (dspbessel(n, krs) / dsphankel(n, krs)) * sphankel(n, krm) RuntimeWarning: invalid value encountered in true_divide

    Pnm array([[ nan +nanj, nan +nanj, nan +nanj, ..., nan +nanj, nan +nanj, nan +nanj], [ -1.00190316e+00 -4.01338101e-01j, -1.00190316e+00 -4.01338101e-01j, 5.12236469e-01 +1.91487108e-01j, ..., 6.52963332e-03 -1.64046583e-02j, -1.08142422e-02 +1.36008399e-02j, 1.40579797e-02 -9.74383232e-03j], [ -6.92814146e-01 +5.44606927e-01j, -6.92814146e-01 +5.44606927e-01j, 3.44521495e-01 -2.84031596e-01j, ..., -8.93413350e-03 -1.13143217e-02j, 5.20235025e-03 +1.31993436e-02j, -1.15078374e-03 -1.39183956e-02j], ..., [ 7.26591711e-04 +4.19497607e-04j, 7.26591711e-04 +4.19497607e-04j, 1.63248223e-01 +8.93309060e-02j, ..., -2.69596410e-02 -1.67026871e-03j, 2.49565221e-02 +9.15335749e-03j, -2.09675451e-02 -1.56539103e-02j], [ 5.64477988e-04 -3.25901761e-04j, 5.64477988e-04 -3.25901761e-04j, 1.23514572e-01 -7.51338336e-02j, ..., -1.15960307e-02 +1.74897009e-02j, 1.58525723e-02 -1.32352485e-02j, -1.86766700e-02 +8.02636522e-03j], [ -8.58983149e-11 -2.66097525e-04j, -8.58983149e-11 -2.66097525e-04j, -1.35151513e-03 -5.90056253e-02j, ..., 3.81651320e-03 +7.66988620e-03j, -1.44347421e-03 -8.30636448e-03j, -9.74610662e-04 +8.24157494e-03j]])

    Same thing happens on Anaconda on windows 64

    opened by colbhaidh 2
  • Create meaningful error message when loading MIRO data that contains

    Create meaningful error message when loading MIRO data that contains "elevation"

    Note that the miro data has a field termed "elevation" but it seems to contain colatitudes as there are no negative values. We are kind of fixing this when converting miro to Matlab struct:

    https://github.com/AppliedAcousticsChalmers/sound_field_analysis-py/blob/master/examples/miro_to_struct.m#L23

    The implementation should produce a warning when a field "elevation" is detected instead of breaking down with an error. Also, negative values in a field "colatitude" or only positive values in a field "elevation" should produce a warning

    opened by JensAhrens 1
  • Update PyPI distribution

    Update PyPI distribution

    • [x] adjustments done by @JensAhrens
    • [x] adjustments to Exp3_Import_SOFA.py documentation by @HaHeho
    • [x] raise version number
    • [x] access login credentials
    • [x] update author information
    opened by HaHeho 0
  • Generating sine sound field?

    Generating sine sound field?

    Hi, is there a way of generating a simple signal sound wave, even a simple sine, using this library? Because as I could have seen in the ideal_wave example there is no signal that can be put in input. Thank you in advance :)

    question 
    opened by DvDream 5
  • Include option to install examples

    Include option to install examples

    Currently, they are not part of the Pypi package.

    Reconsider https://github.com/AppliedAcousticsChalmers/sound_field_analysis-py/blob/d87cce9e5c52ff0de847519d508c4abe933f8b51/setup.py#L26

    opened by JensAhrens 0
  • Check tests

    Check tests

    Not all of them seem to work properly (anymore)?

    • [x] Investigate three test files
    • [ ] Fix test_generators.py
    • [ ] Setup CI testing with GitHub Acions
    opened by HaHeho 0
Owner
Division of Applied Acoustics at Chalmers University of Technology
Division of Applied Acoustics at Chalmers University of Technology
:sound: Play and Record Sound with Python :snake:

Play and Record Sound with Python This Python module provides bindings for the PortAudio library and a few convenience functions to play and record Nu

spatialaudio.net 750 Dec 31, 2022
Sound-Equalizer- This is a Sound Equalizer GUI App Using Python's PyQt5

Sound-Equalizer- This is a Sound Equalizer GUI App Using Python's PyQt5. It gives you the ability to play, pause, and Equalize any one-channel wav audio file and play 3 different instruments.

Mustafa Megahed  1 Jan 10, 2022
This is a short program that takes the input from your microphone and uses OpenGL to draw a live colourful pattern

Visual-Music This is a short program that takes the input from your microphone and uses OpenGL to draw a live colourful pattern Installation and Setup

Tom Jebbo 1 Dec 26, 2021
A simple python script to play bell sound in your system infinitely, just for fun and experimental purposes

A simple python script to play bell sound in your system infinitely, just for fun and experimental purposes

نافع الهلالي 1 Oct 29, 2021
GNOME powered sound conversion

SoundConverter A simple sound converter application for the GNOME environment. It reads anything the GStreamer library can read, and writes Ogg Vorbis

Gautier Portet 188 Dec 17, 2022
Graphical interface to control granular sound synthesis.

Granular sound synthesis interface SoundGrain is a graphical interface where users can draw and edit trajectories to control granular sound synthesis

Olivier Bélanger 122 Dec 10, 2022
Open Sound Strip, Sequence or Record in Audacity

Audacity Tools For Blender Sound editing in Blender Video Sequence Editor with Audacity integrated. Send/receive the full edited sequence or single st

null 64 Dec 31, 2022
Reading list for research topics in sound event detection

Sound event detection aims at processing the continuous acoustic signal and converting it into symbolic descriptions of the corresponding sound events present at the auditory scene.

Soham 64 Jan 5, 2023
A python script that can play .mp3 URLs upon the ringing or motion detection of a Ring doorbell. The sound plays through Sonos speakers.

Ring x Sonos A python script that plays .mp3 files whenever a doorbell is rung or a doorbell detects motion. Features Music! Authors @braden Running T

braden 0 Nov 12, 2021
extract unpack asset file (form unreal engine 4 pak) with extenstion *.uexp which contain awb/acb (cri/cpk like) sound or music resource

Uexp2Awb extract unpack asset file (form unreal engine 4 pak) with extenstion .uexp which contain awb/acb (cri/cpk like) sound or music resource. i ju

max 6 Jun 22, 2022
PyAbsorp is a python module that has the main focus to help estimate the Sound Absorption Coefficient.

This is a package developed to be use to find the Sound Absorption Coefficient through some implemented models, like Biot-Allard, Johnson-Champoux and

Michael Markus Ackermann 8 Oct 19, 2022
Library for working with sound files of the format: .ogg, .mp3, .wav

Library for working with sound files of the format: .ogg, .mp3, .wav. By work is meant - playing sound files in a straight line and in the background, obtaining information about the sound file (author, performer, duration, bitrate, and so on). Playing goes through the pygame, and getting information through the mutagen.

Romanin 2 Dec 15, 2022
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 577 Dec 26, 2022
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 435 Feb 17, 2021
voice assistant made with python that search for covid19 data(like total cases, deaths and etc) in a specific country

covid19-voice-assistant voice assistant made with python that search for covid19 data(like total cases, deaths and etc) in a specific country installi

Miguel 2 Dec 5, 2021
A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.

Audiomentations A Python library for audio data augmentation. Inspired by albumentations. Useful for deep learning. Runs on CPU. Supports mono audio a

Iver Jordal 1.2k Jan 7, 2023
A library for augmenting annotated audio data

muda A library for Musical Data Augmentation. muda package implements annotation-aware musical data augmentation, as described in the muda paper. The

Brian McFee 214 Nov 22, 2022
A small project where I identify notes and key harmonies in a piece of music and use them further to recreate and generate the same piece of music through Python

A small project where I identify notes and key harmonies in a piece of music and use them further to recreate and generate the same piece of music through Python

null 5 Oct 7, 2022
nicfit 425 Jan 1, 2023