Skip to content

ENH: Remove signal.spectrogram, replace with vocalpy.spectrogram #88

@NickleDave

Description

@NickleDave
  • The signal.spectrogram code is ... not great (speaking as the author). In example snippets we log transform to visualize as a very crude sort of map to dB
  • Ideally there should be a way to get a Spectrogram by default from some function that looks good. Ofc "looks good" depends on parameters and these can vary depending on species. But seems like we can offer "good enough" for now.
  • Librosa.stft provides better looking spectrograms by default, but for someone who does not think DSP natively (e.g., moi) it is not intuitive to have to do the steps of stft -> amplitude_to_db(np.abs(S))

So I think we should:

  • remove signal.spectrogram
  • add a function vocalpy.spectrogram or spect_from_audio that gives back a Spectrogram from an Audio
    • basically a wrapper around librosa.stft
    • that does the stft -> amplitude_to_db(np.abs(S)) step
    • that additionally uses other librosa helper functions to get times and frequencies for the vocalpy.Spectrogram
    • and of course in the docstring we should point out it's just a wrapper around these functions and ask people to cite librosa

... I'm unsure about whether I want to keep the spectrogram namespace to put other things in or if I want to prefer a flatter namespace. The whole point of this will be to make it as easy as possible to get a vocalpy.Spectrogram to visualize, so I think we should go with flat. The other things I would put in a spectrogram namepsace would be other ways of computing spectrograms, e.g. multi-taper, time-freq replacement, whatever sigsound does (fancy Theunissen thing I am as yet too dumb to understand). But I think those make more sense in the spectral module

Metadata

Metadata

Assignees

No one assigned

    Labels

    Spectrogramissues related to vocalpy.Spectrogram or spectrograms in general

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions