GithubHelp home page GithubHelp logo

pytta's Introduction

PyTTa License PyTTa Python supported versions PyTTa PyPI version PyTTa PyPI downloads PyTTa build workflow status

PyTTa (Python in Technical Acoustics)

The project began as an effort to create audio, acoustics, and vibration data acquiring and analysis toolbox to a free cost level, high-end results, combining the passion for programming with the expertise in Acoustics and Vibration of the Acoustics Engineers from the Federal University of Santa Maria (Southern Brazil).

We are students, teachers, engineers, passionate and inquiring people, on the first steps of a journey throughout the Python path to bring Acoustics to the Open Seas, Open Sources, and Open World!

Usage

We strongly recommend using Anaconda Python Distribution, as it integrates an IDE (Spyder) and lots of packages over which PyTTa is based on as Numpy, Scipy, Matplotlib, and PyPI (pip). The latter is used to install Sounddevice and PyTTa itself.

The toolbox offers some main classes intended to do measurements (Rec, PlayRec, and FRFMeasurement), handle streaming functionalities (Monitor and Streaming), handle signals/processed data (SignalObj and Analysis), filter (OctFilter), communicate with some hardware (LJU3EI1050), and also new features containing an object-oriented implementation.

There are some assistant functions intended to manipulate and visualize signals and analyses stored as SignalObj and Analysis objects. These functions are called from the toolbox's top level.

The top-level modules offer tools that receive as arguments and return PyTTa objects. Utilities comprise signal synthesis (pytta.generate), room acoustics parameters calculation (pytta.rooms), and some other calculations according to standards (pytta.iso3741).

The sub-packages contains some expansion of the toolbox, as general utilities (pytta.utils) and applications built from the toolbox's basic functionalities (pytta.roomir).

PyTTa is now a multi-paradigm toolbox, which may change in the future. We aim from this point on to be more Pythonic, and therefore, more objected-oriented.

Documentation

This package aims to be an easy interface between acousticians and vibrational engineers in the use of Python for study, engineering, or any other ends that it may suit. From import to each function and attribute we wrote a little documentation that may be useful for understanding everything available, and what is just a means to an end.

To begin, one can try:

>>> import pytta
>>> pytta.list_devices()
>>> pytta.default()

This set of commands will print the available audio I/O devices and the default parameters as they are on the default class object.

To read everything ready for use on the package, and assuming the use of Spyder IDE, one can press "ctrl+i" with the cursor in front of the module, submodule, class, methods, or function names; this will open the help menu with the documentation of the respective item.

>>> pytta|
>>> pytta.properties|
>>> pytta.generate|
>>> pytta.functions|
>>> pytta.classes|
>>> pytta.apps|
>>> pytta.utils|

The | represents the cursor position to press "ctrl+i" to use the Spyder help widget.

Inside each submodule, the user will find instructions on the available tools, and how to access them.

The documentation is also available at Read The Docs: https://pytta.readthedocs.io/

Dependencies

  • Numpy;
  • Scipy;
  • Matplotlib;
  • Sounddevice;
  • Soundfile;
  • H5py; and
  • Numba.

Installation

To install the last version compiled to pip, which can be slightly behind of development branch, do:

>>> pip install pytta

If you want to check the most up to date beta version, please get the development branch source code, clone our repository to your local git, or even install it from pip, as follows:

>>> pip install git+https://github.com/pyttamaster/pytta@development

Contributing as a user

Using the toolbox, you are already contributing. If you experience any bugs, have any suggestions or ideas, have anything to say about it, please consider sending us a message.

Contributing as a developer

Please read our CodingGuidelines and Contributing files.

Contact

Contact us at [email protected] .

Acknowledge

If you use PyTTA in your research, work, paper, or university assignment, acknowledge and cite us if possible.

BibTex file PyTTa.bib

More information

Acoustical Engineering UFSM Website

UFSM Website

Download Spyder (with Anaconda)

Or Miniconda

pytta's People

Contributors

bemurta avatar carolgaudeoso avatar chum4k3r avatar eric-brandao avatar juli-sleeps-well avatar jvcarli avatar marcosvreis avatar mtslazarin avatar pyttamaster avatar rinaldipp avatar tuliochiodi avatar willdfonseca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytta's Issues

ImpulsiveResponse class maintenance

We should do something related to this class to make things simpler. My idea is to inherit SignalObj keeping the current properties and methods as they are (with deprecation warning), trying to don't generate compatibility issues with previously saved h5pytta files.

Error with RoomAnalysis

I tried the reverberation_time example, and I get the following error:

[/usr/local/lib/python3.7/dist-packages/scipy/signal/filter_design.py](https://localhost:8080/#) in iirfilter(N, Wn, rp, rs, btype, analog, ftype, output, fs)
   2344     if not analog:
   2345         if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
-> 2346             raise ValueError("Digital filter critical frequencies "
   2347                              "must be 0 < Wn < 1")
   2348         fs = 2.0

ValueError: Digital filter critical frequencies must be 0 < Wn < 1

Any hints?

Best,
N

Double / Abs(sin) in frequency using Pytta with electromagnetic filed excitation

Hi here :)

I use Pyyta for vibrational analysis of free reeds in iron (musical acoustic) and the machanical excitation is made thanks to a magnetic fields generated with a custom solenoid I made for thze occasion.
This magnetic field is not taking into account the polarisation my tension generated with my soundcard and Amplified with an proper amp so the frequency of the excitation is double of the signal generated by Pyyta, whereas the accelerometer used as sensors see the real frequency.

Even if I have this factor two, I get a shifted curve of my resonnant pike when I compare the measure I made with a Signal generor manually.

Do you have any idea / solution to have my curves not shifter ?
Should I need to use loopback signal to improve my results ?

Thanks a lot in advance !

Quantities that it could be measured with Pytta

Hi Here,
I was wondering what is possibkle to measure with Pytta and what it is not :

Measuring the transient of a system with step sine or step excitation signal,

Measure the Quality factor, or sustension factor,
Plotting the enveloppe of the time signals to do transient analysis, (I have found already a python script for that)

From the enveloppe : Measure the settling time or response time of the system,
Finding the slope of the transient enveloppe,
Bifuraction analysis : measuring Self sustained oscillation threshold, self sustained oscillation hysteresis, multiple bifuractions states, ...

Plot the signals in phase plane ( easy to implement when you have position or acceleration) -> plot Pos vs velocity / plot Velocity vs Acceleration and plot Acc / Pos

Evaluate the inharmonicity of signal,

Modal extraction exctaction of signal.

This are open questions, and even if I am new in python, I could try to developp this

RoomAnalysis T30 estimation fails.

I created a function to geht the T30 from an impulse response (a waveform in a numpy array):

import pytta

def get_rt30(waveform):
    myRT = pytta.RoomAnalysis(waveform,
                              nthOct=3,
                              minFreq=float(2e1),
                              maxFreq=float(2e4))
    return myRT.T30()

When I call it, I get an error that I can't really make sense of:

get_rt30(waveform.detach().cpu().numpy()) # loaded the waveform with torchaudio

The error (running on Google Colab):

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

[<ipython-input-6-84a09afb8196>](https://localhost:8080/#) in <module>()
     21         #print(waveform.squeeze().shape)
     22         waveform = waveform.squeeze()
---> 23         category_mappings.append(get_rt30(waveform.detach().cpu().numpy()))
     24         embeddings.append(emb)
     25 

3 frames

[/usr/local/lib/python3.7/dist-packages/pytta/classes/_instanceinfo.py](https://localhost:8080/#) in __init__(self)
     29             if varnames == ():
     30                 break
---> 31             if frame.f_locals[varnames[0]] not in (self, self.__class__):
     32                 break
     33                 # if the frame is inside a method of this instance,

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Any hints ?

Best,
N

roomir docstrings

To do:

  • MeasurementPostProccess methods docstrings (laza)
  • Final review (carol)

Using loopback in FRF measurement

Hi,

in the reaserch gate paper : https://www.researchgate.net/publication/336207488_PyTTa_Open_source_toolbox_for_acoustic_measurement_and_signal_processing

It is said that it's possible to use a loopback, certainly to avoid shift of frequency. But I did not find any test / exemple in the docs / forums to explain how to implementate this in the code.

I am actually making a FRF from vibrations, input is a electromagnéctic exiter (which works at Frequency /2 due to magnetic pole ) and I have a accelerometer to measure the response.
I have a shift of frequency about 10Hz right now (I compare with a signal generator and the Pyyta results)

I wonder also if it's possible to make a FRF from impulse excitation.

Thanks a lot

My code is inspired by frf exemple below :

import pytta


if __name__ == '__main__':

    device = pytta.get_device_from_user()

    sweep = pytta.generate.sweep(fftDegree=20,samplingRate=15000, freqMin=39.4, freqMax=42)  # Generate sine sweep SignalObj
    #sweep = pytta.generate.sweep(fftDegree=20, samplingRate=15000, freqMin=41, freqMax=43,startMargin=0.05, stopMargin=0.05,method='linear')  # Generate sine sweep SignalObj

    measurementParams = {
        'excitation': sweep,  # Passes the sweep signal as excitation signal
        'samplingRate': 15000,  # Frequency of sampling
        'freqMin': 20,  # Minimum frequency of interest NOT WORKING
        'freqMax': 20000,  # Maximum frequency of interest NOT WORKING
        'device': [1,5],  # Device number provided at runtime
        'inChannels': [1,2],  # List of hardware channels to be used
        'outChannels': [1],  # List of hardware channels to be used
        'comment': 'Testing; 1, 2.'  # just a comentary
    }

    ms = pytta.generate.measurement('frf',  # Generates the configuration for an impulse response measurement
                                    **measurementParams)

    #%% Run the measurement and process data, return an ImpulseResponse object
    med1 = ms.run()

    #%% Shows the data
    med1.plot_time()
    med1.plot_freq(smooth=True)

    #%% Save the measurement
    path = 'data\\'
    name = 'myir'
    filename = f'{path}{name}'

    # Save PyTTaObj as HDF5 file
    pytta.save(filename, med1)

    # Export wave file of SignalObj
    pytta.write_wav(filename+'.wav', med1.IR)

PyTTa licensing

Right now it is registered within setup.py file that PyTTa is distributed under the MIT license, but still there is no LICENSE file at the repository.

Which license should be used?

The main choices are GPLv3, that ensures all software based on PyTTa must also be distributed under GPLv3, or MIT which is a full permissive license and requires only that the PyTTa package is redistributed under the same license.

In my opinion we can go with MIT.

SNR and THD measurements

any plans to add utils to add SNR, THD, THD+N measurements for conducted measurements, i.e. line in/out signals?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.