Hydrogenaudio Forums

Lossy Audio Compression => Opus => Topic started by: magicgoose on 2019-08-18 16:44:45

Title: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 16:44:45
I decided to test what happens when encoding 20hz sine wave with Opus (this is something that can easily be in "real music", so why not), and to my big surprise, it fails spectacularly. 

I used this setting "--bitrate 128" and nothing else (all else is on default). 
The bitrate at the end is 263 kbps, almost as high as the source file in 24 bit FLAC. 
It also sounds very obviously different from original, there's a lot of distortion that wasn't there. (yes I did ABX, see below, also, easiest ABX ever even at very low loudness level)

I tried to do the same with quieter signal (to check if maybe encoder is just overflowing something inside) but there's virtually no difference, same problem with inflated bitrate and non transparent sounding.

Also tried using different build of opusenc (the one came from foobar2000 encoder pack), again, same issues.

Is it a legit problem with Opus? Or am I using some outdated version or doing something wrong?

2 versions that I tried:
Quote
opusenc --version
opusenc opus-tools 0.1.10 (using libopus 1.1.2)
Copyright (C) 2008-2017 Xiph.Org Foundation

wine ~/Documents/foobar2000/encoders/opusenc.exe --version
opusenc opus-tools 0.2-3-gf5f571b (using libopus 1.3.1)
Copyright (C) 2008-2018 Xiph.Org Foundation

Code: [Select]
foo_abx 2.0.6c report
foobar2000 v1.4.6
2019-08-18 18:40:16

File A: 20hz 30 seconds.flac
SHA1: 692b1d490bbb37b937fefbf0bcba8998f810990c
File B: 20hz 30 seconds.opus
SHA1: a76f486c75d2675b634a1f49808ab0af9898b00d

Output:
DS : Out: default
Crossfading: NO

18:40:16 : Test started.
18:40:28 : 01/01
18:40:43 : 02/02
18:40:58 : 03/03
18:41:07 : 04/04
18:41:19 : 05/05
18:41:26 : 06/06
18:41:31 : 07/07
18:41:35 : 08/08
18:41:41 : 09/09
18:41:47 : 10/10
18:41:56 : 11/11
18:42:03 : 12/12
18:42:07 : 13/13
18:42:13 : 14/14
18:42:18 : 15/15
18:42:23 : 16/16
18:42:23 : Test finished.

 ----------
Total: 16/16
p-value: 0 (0%)

 -- signature --
1631b7e7986adb72438b4f7b8fc660dd1d8077d4
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 16:51:07
by the way, this sample also "kills" LAME V0, at least the bitrate doesn't get so big, but there's also an easy to hear difference (different kind difference)
it doesn't kill LAME CBR 320, so might be an issue with the VBR quality estimation in LAME.
Vorbis at -q 6 also isn't transparent with this sample, but the difference is definitely less annoying than with Opus or LAME.
(these tests with LAME and Vorbis were done without converting to 44100hz sample rate, perhaps that's a wrong thing to do, I'll try with 44100hz as well)
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 16:59:58
Note that the source is mono (1 channel).
But when I tried to convert it to stereo and re-do the test with Opus, there's no significant changes, all the same issues.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 17:04:55
Just for giggles decided to also check musepack, and... I can't hear any difference if using Musepack (default settings). (doesn't matter if it's 1 or 2 channels)
bitrate is also reasonable (40 kbps), good enough given that other choices produce non transparent result on it (except cbr mp3 @ 320).
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 17:10:57
FDK AAC encoder at VBR mode 4 is also transparent (for me at least) and takes only 7 kbps, clear winner so far.
(didn't test other quality levels of FDK AAC)
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 17:12:00
So...
I'm hoping that this problem gets fixed and Opus will also not choke on it. 
I'm assuming that AAC as a format is working on kind of the same principle, so if AAC can do it, Opus should too?
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: lithopsian on 2019-08-18 17:51:44
You do know that Opus is a lossy codec, right?
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 17:55:56
Yes. But it has a goal to achieve transparency at this bitrate (and it does so on most music, which is great). This is just a problematic sample that triggers some kind of bug, I guess.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: saratoga on 2019-08-18 19:41:31
Opus has a high pass filter, so perhaps you're seeing that filtering your signal.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 20:00:52
IIRC that filter has the transition point much lower than 20 hz. And the difference that I hear isn't in the lack of signal, it's the inverse, I hear higher frequency sounds that weren't there (some kind of distortion). So if it's the filter, then it must be adding some distortion.
Replaygain also confirms that the signal isn't getting any quieter.
Anyway, it's not possible to disable the DC filter in Opus. So even if the bug is related to that filter, seems like there's still no workaround until it's fixed.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-18 20:54:01
Mix it with real song, if it still is problematic then it's worthwhile.
Otherwise 20Hz alone is an inaudible infrasound for which no audio codec should be tuned.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 20:59:21
> Otherwise 20Hz alone is an inaudible infrasound for which no audio codec should be tuned.
It is audible for me. (in Bose QC 35 II headphones). There's clearly a sound, and it isn't much quieter than something like 50Hz for example.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-18 21:18:01
Perhaps 22050 Hz sine is audible for you too, but it is nearly meaningless in everyday audio - such extreme frequencies are masked in everyday audio and there's no ABX test proving that excluding/altering them in lossy codecs is a bad idea.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 21:24:01
> Perhaps 22050 Hz sine is audible for you too

no, even 16000hz becomes hard in isolation, and it has to be louder than everything else to not get masked.
I can try find some music with loud and clear bass though, if that would be much stronger argument.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: lithopsian on 2019-08-18 21:55:32
Opus high pass is at 3Hz, its just to block DC signals which mess things up.  Introduced in 1.1 I think, no high pass before that.  Low frequencies don't take a lot of bits to encode, doubly so because they are barely audible as part of any real audio signal and so don't get allocated a lot of bits in lossy codecs.

Opus encodes in 21 (at this bitrate, using CELT) different frequency bands.  The lowest is 0-200 Hz.  In theory, it allocates bits to the bands in accordance with various weights, and the lowest band is not heavily weighted.  I would still expect that in this case, a lot of bits might go to that band, since it allocates bits between the bands in an attempt to reach the specified bitrate, but I don't understand all the details.  Maybe there is a good reason why that band doesn't get enough bits, or maybe some calculation just blows up in this abnormal case.  At lower bitrates, the low frequencies will be handled by SILK (either SILK alone or in hybrid mode), so it might be interesting to try your test signal at very low bitrates.  It might actually sound better!  Try below 64 kbs and keep going down to see what happens.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-18 21:59:33
> Maybe there is a good reason why that band doesn't get enough bits
just saying, for this case the overall bitrate is certainly more than enough, it's nearly twice the target bitrate.
> maybe some calculation just blows up in this abnormal case
that's what I'm thinking too.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: saratoga on 2019-08-19 03:25:31
IIRC that filter has the transition point much lower than 20 hz. And the difference that I hear isn't in the lack of signal, it's the inverse, I hear higher frequency sounds that weren't there (some kind of distortion). So if it's the filter, then it must be adding some distortion.
Replaygain also confirms that the signal isn't getting any quieter.
Anyway, it's not possible to disable the DC filter in Opus. So even if the bug is related to that filter, seems like there's still no workaround until it's fixed.

It is definitely distortion, I just checked your file:

(https://i.imgur.com/dOUQXIz.png)

Does it happen if you use a higher frequency sin wave?  Like 1 kHz? 

FWIW, this is less than 0.01% distortion, so probably this is of no significance, but interesting that it happens. 
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-19 11:53:52
If amount of this kind of distortion is fixed (not affected by psymodel, just, say, always -40dB compared to the signal) then it's going to be most noticeable when the tone itself is in the area where human ear is less sensitive.

Tried some more with Opus @ 128 kbps:
27.5 Hz (A0 note, lowest "legal" note on a bass in dropped A tuning), easy to ABX.
30.868 Hz (B0 note, lowest on standard tuned 5 string bass), can't ABX anymore, actual bitrate is 239 kbps.
41.204 Hz (E1 note, lowest note on a standard bass tuning), can't ABX, bitrate bloat is still a problem (240kbps)
I assume anything higher than 41Hz would be transparent as well.
1kHz is also transparent. Also has bloated bitrate but less ("only" 199 kbps).

So, the lowest "real note" is affected, but anything higher than that, not so much.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Nichttaub on 2019-08-19 18:34:10
I just tried this in Apple AAC (128k, VBR) and it encoded very nicely with a resultant bit rate of about 42kbps.  When I subtracted the resultant file from the original, there was only a little bit of second harmonic, maybe 60 dB down.  I can hear the tone clearly in my headphones, but there's nothing I could ABX between the two files; it seems like my phones are generating more distortion than the encoder did, so it would be pointless.

I have a fair amount of organ music with isolated, dominant pedal tones between 14 and 30 Hz, so I'm happy to note that AAC handles this well.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Brand on 2019-08-19 19:05:44
@Nichttaub: which encoding settings are you using for AAC? Because when I convert it to 128k VBR (Q64 - in Foobar) I get a 16kbps file that can be easily ABXed. It's not as bad as the Opus one, but still pretty bad.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Porcus on 2019-08-19 20:14:45
The bitrate at the end is 263 kbps, almost as high as the source file in 24 bit FLAC. 
The resulting bitrate, that is. Not "at the end" as in increasing to the end of the file.

Got curious. Used foobar2000 to look for a discontinuity. Found it between bitrates 52 and 53:
Target 52 -> 48
Target 53 -> 113

Checked target 128, got 264 (as yours - fb2k reports both as 264. But yours and and mine do not decode bit-identically; fb2k: difference -42.49 dB)

Now, foo_bitcompare is limited to how many bits PCM internally? Target 150 and up decode identically according to it.
And it is above twice the target until 256->513. Target 320 also produces 513.

Results are "worse" relative to FLAC if I reduce volume, but going 34 dB down (to make it approx. 16 bit "true" resolution) I didn't get .opus higher than 453.


Mix it with real song, if it still is problematic then it's worthwhile.
Otherwise 20Hz alone is an inaudible infrasound for which no audio codec should be tuned.
If you were right, it would be even worse - it would be a VBR lossy codec spending space on something it should have discarded and spent nothing on.
But 20 kHz certainly isn't inaudible.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: lithopsian on 2019-08-19 21:10:32
52 kbps is a believable value to switch to hybrid mode, which would confirm that the bloating occurs in the CELT layer.  Did you listen to the sub-52 version?  I wonder whether the encoder thinks it is speech or music?

P.SA.  The maximum frame length in Opus is equivalent to 510 kbps (with standard frames).  Your 513 presumably represents that plus overhead.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-19 22:46:20

Mix it with real song, if it still is problematic then it's worthwhile.
Otherwise 20Hz alone is an inaudible infrasound for which no audio codec should be tuned.
If you were right, it would be even worse - it would be a VBR lossy codec spending space on something it should have discarded and spent nothing on.
But 20 kHz certainly isn't inaudible.
Every proper mixing should have highpass with very aggresive slope somewhere between 14-40Hz.
I attach your sine mixed with real music. The terrible unreal sine is still garbled but bitrate is correct.
What would be interesting, is testing this issue with real music Nichttaub mentioned (organs with 14-30 Hz pedals).
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-19 23:51:46
> Every proper mixing should have highpass with very aggresive slope somewhere between 14-40Hz

Almost none from my library have that. Also, why would you remove something that can be perceived, even if not always by ear but by body or by shattering glass in windows?
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-20 01:40:40
Before judging check with proper tool like Ultra High Resolution Spectrum Analyzer from MusicScope - you need huge window size for FFT. Large part of my library is clearly highpassed, even records from 80s. Similarly as proper CDDA masters should be 20kHz lowpassed even though some people would hear extreme sine at that frequency.
There are many reasons to do that.
Such low and intense infrasonics are expected only in movie sound effects and rare cases like the ones mentioned by Nichttaub. In 99% of music they are not expected and every good audio engineer will filter them out to keep things in control.

Don't get me wrong, this is some kind of issue and not the first one for Opus. But extreme artificial cases are often misleading in case of psychoacoustic lossy codecs and I'd rather see it tested with real material.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Nichttaub on 2019-08-20 07:25:25
@Nichttaub: which encoding settings are you using for AAC? Because when I convert it to 128k VBR (Q64 - in Foobar) I get a 16kbps file that can be easily ABXed. It's not as bad as the Opus one, but still pretty bad.

The only choice I make is the bitrate and VBR;  I don't turn on any of the other options like HE/AAC because they're really not pertinent to what I need.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Porcus on 2019-08-20 08:39:05
Every proper mixing should have highpass with very aggresive slope somewhere between 14-40Hz.
1) Newsflash for you: we aren't anymore mastering exclusively for vinyl.
2) Again, even if you were right and everything below ... WTF 40? should be removed, then it is nonsense for a VBR lossy codec to spend so much space on it.
3) You are certainly wrong. It is well-established that the true hearing range goes way below 20 Hz (even with headphones) (https://doi.org/10.1121/1.1914605) and there is a lot of useful content below 40 Hz. For one thing, movies have sound too.
But even if you insist that movie soundtracks are worthless and audio codecs should only work on audio-only: Here, the first half of Mount Fuji Doomjazz Corporation: "Space" (https://denovali.com/mountfuji/mp3/01_Space.aiff.mp3). In my room with my speakers, the 19 Hz drone from 3:23 to 5:03 requires a bit of volume, but the short sweep to 22 Hz and back at 5:03 to 5:05 is there at low listening levels (like, ten dB below my usual, which due to neighbors isn't that loud).
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Porcus on 2019-08-20 08:57:11
52 kbps is a believable value to switch to hybrid mode, which would confirm that the bloating occurs in the CELT layer.  Did you listen to the sub-52 version?  I wonder whether the encoder thinks it is speech or music?

Here you have both attached. No need to ABX ...

Further curiosity checks:
* reducing from 24 bits to 16 bits. Opus @ target 128 also chopped off a third.
* slowed it down to 45 seconds (changing pitch with it). Opus approximately kept size (bitrate went down ... something FLAC wasn't that good at).
* other lossless codecs! OptimFrog "best" halves the FLAC filesize. WavPack suffers from that old near-mono-suboptimality and does worse than FLAC, TAK is evidently not good at 24/48.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-20 09:51:23
I'd rather see it tested with all kinds of material, to be honest.

> proper tool like Ultra High Resolution Spectrum Analyzer
would something like iZotope RX Audio Editor be a proper tool? it supports huge window sizes as well.

Sonic Mayhem - "Quake 3 Arena: Noise" - track 03 "Violator"
there's no highpass filtering whatsoever, and near the end there are loud blasts in ~35..10 Hz range
there's also no highpass through the entire album (almost), and the 5th track from it also has tonal sounds going down to ~17 Hz as one of the primary elements. most other tracks from this album also have something happening near 20 Hz too.

OK, but this is "industrial" & "soundtrack", so as some would say, not real music, so let's look at something else...
Manowar - [The Triumph of Steel #07] "The Demon's Whip": the intro sound effects have quite a lot of energy near 20 Hz.
Manowar - "Warriors of the World" (the entire album) - not a whole lot of loud sounds specifically in that range, but the highpass, if any, seems to be not higher than at ~7 Hz.
Dire Straits - "Brothers In Arms" (the entire album) - highpass only at ~20 Hz, some tracks have tonal features going down to ~26 Hz.

I didn't go through all my files, there's probably more examples of "insufficient" highpass and low frequency effects in music.
Also I was not very accurate when saying "almost none from my library have that", but point still holds, it happens and it'd be not very wise to ignore it.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-20 09:57:55
listened to the "20hz 30 seconds target 52.opus", I expected that it'd be free from this issue if it switched to different mode, but no... it's actually so bad, lol
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-20 11:15:20
@porcus: as soon as you actually understand what I wrote there's not much more for me to reply.
1) Newsflash for you: we aren't anymore mastering exclusively for vinyl.
2) Again, even if you were right and everything below ... WTF 40? should be removed, then it is nonsense for a VBR lossy codec to spend so much space on it.
3) You are certainly wrong. It is well-established that the true hearing range goes way below 20 Hz (even with headphones) (https://doi.org/10.1121/1.1914605) and there is a lot of useful content below 40 Hz. For one thing, movies have sound too.
But even if you insist that movie soundtracks are worthless and audio codecs should only work on audio-only: Here, the first half of Mount Fuji Doomjazz Corporation: "Space" (https://denovali.com/mountfuji/mp3/01_Space.aiff.mp3). In my room with my speakers, the 19 Hz drone from 3:23 to 5:03 requires a bit of volume, but the short sweep to 22 Hz and back at 5:03 to 5:05 is there at low listening levels (like, ten dB below my usual, which due to neighbors isn't that loud).
I already addressed all your points, try to catch the whole image instead of nitpicking the details. Please come back with ABX of that doomjazz corporation encoded with Opus@128kbps, that will be interesting.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-20 11:35:45
I'd rather see it tested with all kinds of material, to be honest.

> proper tool like Ultra High Resolution Spectrum Analyzer
would something like iZotope RX Audio Editor be a proper tool? it supports huge window sizes as well.

Sonic Mayhem - "Quake 3 Arena: Noise" - track 03 "Violator"
there's no highpass filtering whatsoever, and near the end there are loud blasts in ~35..10 Hz range
there's also no highpass through the entire album (almost), and the 5th track from it also has tonal sounds going down to ~17 Hz as one of the primary elements. most other tracks from this album also have something happening near 20 Hz too.

OK, but this is "industrial" & "soundtrack", so as some would say, not real music, so let's look at something else...
Manowar - [The Triumph of Steel #07] "The Demon's Whip": the intro sound effects have quite a lot of energy near 20 Hz.
Manowar - "Warriors of the World" (the entire album) - not a whole lot of loud sounds specifically in that range, but the highpass, if any, seems to be not higher than at ~7 Hz.
Dire Straits - "Brothers In Arms" (the entire album) - highpass only at ~20 Hz, some tracks have tonal features going down to ~26 Hz.

I didn't go through all my files, there's probably more examples of "insufficient" highpass and low frequency effects in music.
Also I was not very accurate when saying "almost none from my library have that", but point still holds, it happens and it'd be not very wise to ignore it.
I don't know how it is with iZotope, I just checked 3 songs from my library, Madonna from 90s doesn't seem to be highpassed, Bauhaus track with one of the strongest bass I have in my library has clear rolloff at 50Hz, the 3rd track is a couple years old it has visible rolloff at 33Hz.

Anyway we are missing the point. Mixing a bit of music into your sine made the bloat problem disappear. When such infrasonics are on sane level in real material perhaps they're not ABX-able. Please test with real stuff.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: Brand on 2019-08-20 13:08:56
The only choice I make is the bitrate and VBR;  I don't turn on any of the other options like HE/AAC because they're really not pertinent to what I need.
Do you use Foobar or something else?
I downloaded the latest iTunes and qaac, but I still get the same bad sounding 16k file when I use 128k VBR.
Attaching the settings screenshot and the resulting file, just in case (if I switch to Custom the command line shows --ignorelength -s --no-optimize -V 64 -o %d -).

And FDK AAC is clearly not transparent either (at VBR 4, 128k). Attaching that too.

So to me it looks like Opus, AAC, MP3 and Vorbis all fail at this, at settings where they are usually transparent.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: ajp9 on 2019-08-23 00:25:12
For 48KHz, 20 hertz has a wavelength of 2,000, which is a bit large for psychoacoustic codecs, and Opus was created partly for low delay frames. It could be an improper band-pass problem, but the frames line up, and the wave starts at 0. It's suggested that the encoder is underestimating the necessary bits to encode infrasonic bands without a normal signal, but I tested 1KHz on top of 20 and 10Hz, and I still got harmonic distortion in the lower bands. Maybe it's trying to compensate for transient false positives.

The Apple encoder seems to implement a good approach for the primer, producing less distortion in the first cycle of the sine wave than FDK.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-23 10:14:21
20 Hz is not an infrasonic band yet. Infrasonic, by definition, is something that cannot be heard because it's lower than lowest human hearable frequency.
Anyway, the issue reproduces up to 27.5 Hz, the latter is a legit musical note.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-23 11:47:19
20 Hz is often cited as upper limit of infrasounds. I personally hear down to 14Hz but most often I highpass my music - on non bass(drum) or sfx tracks I often put highpass as high as possible without altering main content, and there's often highpass on master track with quite aggresive slope around 30-50Hz, to keep things clear and under control - unexpected/unwanted content muddies the track and may lead to a number of technical issues with phasing etc.
This thread is not very different from 17kHz sine which most people can hear but would be completely lowpassed by most lossy encodes.
From technical point of view this issue is interesting, but in practice it's irrelevant until something real is found to be ABXable.
Did you try to encode that sine from 16bit source and at much lower levels?
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-23 11:56:58
Define "something real" first
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-23 14:45:36
Some music or soundtrack actually released, even synthesized but anyhow mastered for general playback. Of course we can torment psychoacoustic encoders with artificial, extreme, near clipping sines, sawtooths and square waves, but as well we could judge them purely by spectrograms etc...
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-23 15:17:51
Quote
anyhow mastered for general playback
artificial
extreme
these are highly subjective.

Quote
as well we could judge them purely by spectrograms
no. it's either ABX-able or not, it's that simple.
judging by spectrograms doesn't work, hope I don't need to explain why.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-23 18:21:04
Using Porcus' language - newsflash for you: all codecs are tuned towards something, in case of lossy audio codecs they're best tuned for highly subjective "everyday audio", where 24bit mono 30s nearly clipping 20Hz pure sine doesn't even stand close.
I have a bunch of artificial music from old 8/16-bit computers - PWM sounds, 100% stereo separation, full scale amplitudes, extreme transients, DC offsets, pure sinus, triangle, sawtooth, square waves and white noise - all lossy (in terms of quality) and lossless (in terms of size) audio codecs fail spectacularly. Unexpected?

That being said, I'm interested what actually causes the issue too. And even more - does it affect several real soundtracks mentioned in this thread.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: ajp9 on 2019-08-24 05:56:29
This issue with the encoder is certainly ABX'able because I can hear the harmonic distortion when 20Hz alone without having to increase the volume any further; 20Hz by itself is not easy to hear at any volume. It will affect real soundtracks that have these low frequencies, the question is how much will they be affected until this issue is fixed.

Also, correction from earlier: at 48K, 20Hz has a wavelength of 2,400. That's nearly the size of the largest block possible with Opus — 2,880. And half of 2,880 as a wavelength would make 33⅓Hz, close to 27.5 and where this problem doesn't occur at all. So I'm thinking this has something to do with the blocking scheme, maybe the limits of a discrete transform somewhere. All of the mentioned lossy codecs that can't properly handle this low band range have had to deal with (pre)echo to get them as good as they are. The 3Hz highpass shouldn't affect 20Hz if it's done properly, but it may affect the starting phase.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: rutra80 on 2019-08-24 13:46:38
Instead of theorising lets make another funny test:
Here is mentioned Madonna piece which originally is not highpassed. I lowpassed it so top content is up to 27,5Hz. Unfortunately the content being at natural levels was inaudible (you know the ATH curves for these frequencies right?), so I brought it to insane levels we are dealing with in this thread, by normalising it to -1dB so it is audible.
Please report problems.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: ajp9 on 2019-08-25 05:52:41
First clip (the low frequencies of the song) sounds like a night club from outside. The latter sounds like a jetliner is also passing by in the sky.

Opus 1.3 is just not very accurate outside of the 33-17KHz range. In other tests I've performed, frequencies above 17KHz can be significantly messier than the input. So Opus is good for the most audible range of human hearing, and AAC is better at full range encoding.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: saratoga on 2019-08-25 06:45:23
Quote
anyhow mastered for general playback
artificial
extreme
these are highly subjective.

Quote
as well we could judge them purely by spectrograms
no. it's either ABX-able or not, it's that simple.

People usually expect ABX tests to be performed with real audio.  Using synthetic test signals, all manner of things can be ABXed, but if they don't matter then the test is less interesting. 

It sounds like here either there is some bug in the encoder, or if it is fundamental in how the frequency analysis works, they should just raise the high pass filter cut off a little. 
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-25 19:30:46
not just a little, but all the way up to 30 Hz, it seems.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: jmvalin on 2019-08-26 06:47:19
So I had a look at this to see what's going on. Long story short, the problem isn't really what's in the file (20-Hz tone) as what isn't (anything other than the tone). If I remove the DC rejection filter (which isn't the problem here, it just makes debugging harder), then the decoded file has an SNR around 48 dB -- way more than typically required for transparency in a lossy codec because of the masking. The problem here is that the tone is nearly inaudible, so it cases almost no masking of the residual noise. If there were other content in the file, then that content would easily mask the noise. As far as I can tell, there's no easy fix for that (CELT cannot allocate more than 8 bits/sample, or 48 dB band SNR). Fortunately, it's rather rare to encounter a full-scale 20 Hz-tone with no other content present at the same time.
Title: Re: Something really terrible is happening when encoding 20Hz sine wave
Post by: magicgoose on 2019-08-26 11:55:10
@jmvalin it reproduces also with 27.5 Hz and also if I add quite a lot of white noise on top (which would be loud enough to hear it too). If you want, I can upload a sample.
SimplePortal 1.0.0 RC1 © 2008-2019