Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displaying spectrogram in the background #38

Open
juergendrachta opened this issue Jun 20, 2020 · 7 comments
Open

displaying spectrogram in the background #38

juergendrachta opened this issue Jun 20, 2020 · 7 comments

Comments

@juergendrachta
Copy link

I'd find it very beneficial to be able to display the calculated spectrogram in the background. It definitely would help adjusting the pitches, when the automated pitch extraction fails.

As an alternative, I'd propose to be able to set an own spectrogram as a background (e.g. I separate the vocals from the songs via Spleeter, and then draw a spectrogram via python's scipy/matplotlib).
Of course, in this case we have to agree on a given format, i.e. how many Hz or ms a pixel represents in the image.

@Tronic
Copy link
Member

Tronic commented Jun 21, 2020

Doesn't the composer already show you a spectrogram? It could, however, use the improved algorithm I made for Performous a few months ago. The old one is noisier. Standard spectrogram (what you see in music players and other such software) is way too low resolution. You need to do FFT reassignment method and use a sufficiently short FFT window (1024 samples @ 48 kHz seems optimal) to get clear results. Harmonics combining (i.e. the pitch detection we have) is also useful for removing unnecessary clutter but I agree that in case of composer it might be sometimes useful to omit that step because occasionally the correct singing frequency gets hidden as a harmonic of another lower frequency instrument (in this case showing a line exactly one octave lower).

@Tronic
Copy link
Member

Tronic commented Jun 21, 2020

That being said, I have what you need implemented in Python so that it paints into an image (Numpy array). It is a bit slow but probably not too much so for composer. Having someone implement this is another thing as AFAIK no-one is working on Composer at this time, and I am not interested in touching the Qt code either. If you are willing to make a PR, I'll help with the algorithmic details.

@juergendrachta
Copy link
Author

juergendrachta commented Jun 21, 2020

Thanks for the response!

I looked through all the menus composer offers, but I only see the option to display the extracted notes from spectrogram and not the spectrogram itself. I looked a bit into the code, and it seems to me, that it's not a one-liner to display the complete spectrogram instead of the detected pitches. Somehow it's understandable to directly draw the extracted notes via some Qt's drawline methods, because than you don't have to think aliasing and re-scaling issues of the spectrogram's pixel graphic.

Because of those issues, I would find it nice, to rather implement a functionality, which allows the user to load a self-built spectrogram in the background, because than the decision if left to the user, which resolution is taken and which audio file is used as basis. Furthermore, I think that is easier to implement.

And about Qt: For me it's quite the same! :-) I'd try to avoid as much as Qt possible - the main reason is, that i almost know no Qt, especially Qt in C++.

And about the FFT and spectrogram building on its own: Where can I find the code you are using for building the spectrogram?
Because maybe I simplify my "workflow", which consists now of

  • separating the vocals (via Spleeter),
  • pitch detection (via the pyin algorithm implement as a Vamp plugin loaded in Python via VamPy, using the same parameters as in Tony),
  • coarse lyrics alignment via Aeneas (event hough not relevant for the pitch extraction) and finally a
  • manual fine tuning (because of course all previous steps are far not perfect), for which the composer would be ideal.

This is how my spectrograms normally look like (generated via plt.specgram(monowav, Fs=FS, NFFT=10*1024, noverlap=8*1024, scale="dB", cmap="gist_ncar") # plot), which would like to be loaded in the composer :-D
image

And thanks for the offer to help in a PR, I'll see how far I can get into the composer source code in my spare time. If I see, that it's easier than expected for a Qt-newbie as me to get a heatmap of a numpy array correctly drawn and aligned correctly with the time and frequency axis, then I'll come back to your offer! (y) :-)

@Tronic
Copy link
Member

Tronic commented Jun 21, 2020

I'll get you some Python code tomorrow. C++ implementation is available in https://github.com/performous/performous/blob/d962d38acaec895b497029e5909ce9b5b9d7149c/game/pitch.cc#L107

@Tronic
Copy link
Member

Tronic commented Jul 1, 2020

Sorry for the delay. I got suddenly flooded with work but will try to get back to in a couple of weeks if you are still interested.

@Tronic Tronic self-assigned this Jul 1, 2020
@MikeEA0
Copy link

MikeEA0 commented Dec 29, 2021

Any progress on this one?

This seems to be a rather useful feature to me, since in the song I am currently trying to time, very often pitches of the instruments are shown rather those of the vocal...

@Tronic
Copy link
Member

Tronic commented Dec 30, 2021

No progress on my part, and unfortunately I won't have time to work on it on foreseeable future. Hoping that someone else could pick this up.

@Tronic Tronic removed their assignment Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants