Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Room - Clarity function is broken | not working without bands #251

Description

@ngautam0kaggel

Function call a/c to documentation:

  • acoustics.room.c50_from_file(file_name, bands=None)
  • acoustics.room.c80_from_file(file_name, bands=None)
  • acoustics.room.clarity(time, signal, fs, bands=None)

Run time error when calling these functions:

  • Sample function call:

acoustics.room.c50_from_file(files[0], bands=None)

  • Error:
    240         high = third_high(bands[0], bands[-1])
    241 
--> 242     c = np.zeros(bands.size)
    243     for band in range(bands.size):
    244         filtered_signal = bandpass(signal, low[band], high[band], fs, order=8)

AttributeError: 'NoneType' object has no attribute 'size'

Band is a mandatory parameter a/c to code but optional a/c to documents.

Activity

  1. felipeacsi commented on Oct 4, 2021

    @felipeacsi
    Member

    You're right. There is a bug there. It's a very old code so I don't know what I was thinking.

    Anyway, you can use this function:

    from scipy.io import wavfile
    
    def clarity(time, file):
        """
        Clarity from an impulse response file.
        :param time: Time in milliseconds (e.g.: 50, 80).
        :param file: Audio file.
        """
        fs, signal = wav.read(file)
        h2 = signal**2
        t = (time/1000)*fs + 1
        return 10*np.log10((np.sum(h2[:t])/np.sum(h2[t:])))
    

    I hope it helps. Let me know any question.

  2. ngautam0kaggel commented on Oct 5, 2021

    @ngautam0kaggel
    Author

    Thanks for this. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions