cboxdoerfer / ddb_musical_spectrum

Musical spectrum for the DeaDBeeF audio player
GNU General Public License v2.0
58 stars 7 forks source link

highest frequencies appear to remain "empty" #11

Closed ohnonot closed 4 years ago

ohnonot commented 8 years ago

thanks for this plugin!

looking at the plugin's output, it seems that the highest frequencies are always zero. please see screenshot (other plugins added to show that the error is indeed with this pugin and not the sound itself. boosted high frequencies on equalizer to make the issue more visible; disabling the eq does not solve it).

this happens for various files; i tried mp3, flac and streams (aac i think).

it would seem that the spectrum scans more frequencies than my system is able to reproduce?

i cannot find any settings (either in this plugin's settings or in deadbeef's) that would change this.

any way to solve this would be appreciated.

forgot to mention, all this is happening on archlinux, alsa and nothing else, simple openbox environment.

cboxdoerfer commented 8 years ago

Can you paste a screenshot of the config dialog of the musical spectrum plugin?

ohnonot commented 8 years ago

yes, here it is (there's a second preferences dialog when one right-clicks the spectrum itself: that one is already included in the first screenshot). additionally, here are screenshots of the alsa output plugin's and the resampler's (secret rabbit hole) preferences. i played with all of these and some more, could hear the changes, but the spectrum remains unaffected by this, i.e. there's always a gap at the right end (unless a complete application restart is required each time?).

not sure if my hunch that this has to do with the output samplerate is right? according to e.g. this there's nothing to do because alsa uses the samplerate of the original file. i have no additional alsa configuration. maybe my sound hardware comes into it?

$ sudo lspci -nnvvvk | grep -iA20 audio
00:1f.3 Audio device [0403]: Intel Corporation Sunrise Point-H HD Audio [8086:a170] (rev 31)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:f982]
    Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
    Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Latency: 32
    Interrupt: pin A routed to IRQ 316
    Region 0: Memory at df120000 (64-bit, non-prefetchable) [size=16K]
    Region 4: Memory at df100000 (64-bit, non-prefetchable) [size=64K]
    Capabilities: [50] Power Management version 3
        Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot+,D3cold+)
        Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
    Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Address: 00000000fee0f00c  Data: 41c1
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel
cboxdoerfer commented 8 years ago

Thx, sorry didn't notice the config dialog in your first screenshot, just looked at the spectrum itself.

The gap at the right end is there because the spectrum goes up to B10 (~31600Hz), and most audio clips don't have any data in those high frequencies. But I see how that can be annoying, so I'll add an option to make the frequency range configurable.

ohnonot commented 8 years ago

but the cutoff is very sharp, and always at the same position, regardless of the music? how can all my music simply have no data at all in that range? and if your plugin is hardwired to represent a wide range of frequencies, wouldn't the gap be even wider then?

in any case, an option to simply make this configurable sounds like a good solution to me, and i for one am eagerly awaiting it!

cboxdoerfer commented 8 years ago

but the cutoff is very sharp, and always at the same position, regardless of the music? how can all my music simply have no data at all in that range?

Because your music has most likely a sample rate of 44100 Hz, the Nyquist frequency therefore is 22050 Hz. That's the highest frequency at which you can reconstruct a signal with a 44100 Hz sampling rate (without any errors). That's why there is a cut after 22050 Hz.

and if your plugin is hardwired to represent a wide range of frequencies, wouldn't the gap be even wider then?

No, because the scale isn't linear but logarithmic.

cboxdoerfer commented 8 years ago

oh, i can see what is happening now. i just created a 96kHz samplerate test file with audacity, and lo and behold, there's no gap! i have practically no such files in my music collection, i guess.

Yes, that's exactly what supposed to happen. A file with a 96kHz sampling rate can have frequencies up to 48kHz. However you really don't need that, since no human being is able to hear that. 44.1kHz sample rate is really enough for listening to music.

most my files are 44.1kHz or 48kHz. judging from that, i guess your plugin scans a bit beyond that, say til 50kHz or 60 kHz?

It scans up to ~31.6kHz - that's the B10 note. A file with 44.1kHz can hold frequencies up to 22kHz. The gap that you see is the difference between 31.6kHz and 22kHz.

is it possible to adapt that range automatically to each file's samplerate? that would be the most elegant solution.

Yeah, that's possible. I'll think about adding that.

ohnonot commented 8 years ago

so it's possible that an incompetently encoded file (e.g. a cd rip - originally 44.1kHz - ripped to 96kHz flac) really has these "empty frequencies" towards the top. in that case adapting the range automatically to each file's samplerate isn't so good, either.

i guess the best solution is to simply cut off at 22kHz. or add an option to do that.

sorry i'm talking about your code like i actually know something about it... :D

thanks anyhow, i learned something.

ohnonot commented 8 years ago

of course it would make sense to add an option to limit the frequency range at both ends.

Empatheon commented 7 years ago

Yes, the plugin is one among my favourites, but I have found at least one case when it's bluntly inaccurate.

Check out Opus codec files playback. Opus by default uses sampling rate of 48000Hz - which should give us up to 24kHz in audio frequency, right? But the problem is, Opus in fact cuts out everything higher than 20kHz, due to its technical objectives. You can check this type of files by any acoustic spectrum analyser (like Spek) and you will find out, there is nothing above 20kHz.

Yet ddb_musical_spectrum frequently shows, that there is "life" in between 20-24kHz, while that is impossible.

cboxdoerfer commented 7 years ago

@Empatheon, thx I can confirm that. I also found a bug with wrong frequencies shown in tooltips, but this has nothing to do with it.

I'll have a look at both issues right now.

Empatheon commented 7 years ago

Happy to help. Keep up the good work, you are doing magnificent job - this plugin is really great piece of software overall.

Ah, there is one more minor annoyance - when you do play files of different sample rates after each other, musical_spectrum assumes last known sampling rate. For example - if you freshly start Deadbeef and start playback with a 96khz sampling rate file, it will show frequencies up to 22kHz (assuming sampling rate is 44,1khz), even when there is more high-pitched content. If you restart the playback of that file, plugin will adapt to the real sampling rate.

I don't know if that is avoidable, but in the end it is a triffle - mostly when I listen to the music, I don't pay much attention to any graphical representations of sound, and when I need to check frequency content of track, I can restart it, to be sure, it is displayed properly.

Cheers and thank you for work.

SonicoXD commented 4 years ago

Wanted to know if this is still in the to-do list. The plugin is great, and the latest addition (peaks) is working great! On foobar it is possible to change the maximum frequency, and it really helps to remove that black space on the right.

cboxdoerfer commented 4 years ago

@SonicoXD, I've been actively working on that in the past weeks. The code (among other improvements) can be found in the new_config_dialog branch. If you want to try it out the frequency range can be configured with the new "Notes" config entry:

2019-11-27-094205_376x350_scrot

But you should expect bugs since this is a work-in-progress. (Some new config entries in the new config dialog are also just place holders right now and don't work at all)

SonicoXD commented 4 years ago

@cboxdoerfer just tried it and it's working fine. The only bug I got is that the spectrum freezes when the last track finishes playing. It can easily be seen here, as this track doesn't end in silence. image If another song is played it works fine again. Oh, and by the way, if possible, it would be great if the solid spectrum could use all the space available, as the musical spectrum does :) Of course, as you said, some entries won't do anything. Wish you the best of luck, and thanks for this amazing spectrum!

cboxdoerfer commented 4 years ago

@SonicoXD:

The only bug I got is that the spectrum freezes when the last track finishes playing.

Should be fixed now in new_config_dialog branch.

it would be great if the solid spectrum could use all the space available, as the musical spectrum does :)

If I understand you correctly this also should work now.

I also implemented all the missing features for the new config dialog, including a couple more features, and if I don't find any serious bugs in the upcoming days it'll be merged to master.

cboxdoerfer commented 4 years ago

Merged to master.