Audio Phantom Sound - 4 kHz + 6 kHz

Questions about codecs, DVD playback, web plugins...
Forum rules
Before you post please read how to get help
Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Thu May 09, 2019 3:55 pm

Hi,

I can't seem to find any solution for this problem, I don't even know how to search for it since nothing shows up (I'm usually able to find a solution).

The problem is that when I play a 4 kHz sound and 6 kHz sound separately, everything seems fine, but when I play them together, some other phantom sound is also heard, I've checked if it was my headphones mixing the frequencies, but the resultant frequency is not in between the 2 frequencies, sometimes it's lower and sometimes it's higher depending on the test (5 kHz + 6 kHz, 4 kHz + 6 kHz, 4 kHz + 5 kHz).

[EDIT]: No, this didn't fix the issue, I can distinguish between the 2 sounds perfectly on Windows and Mac, only Linux seems to be giving these issues.
Last edited by Dampi05 on Mon May 13, 2019 2:18 pm, edited 3 times in total.

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Thu May 09, 2019 4:18 pm

How are you playing the sounds, with and through what, and what are those sounds? If pure sine waves this would be N/A but based on the title alone I initially thought of a shared harmonic at 12 kHz. Not for the other tests you mention and its anyway probably N/A but if you can provide something reproducible someone might have an idea...

[EDIT] And/or this? http://szhorvat.net/pelican/combination-tones.html

User avatar
jimallyn
Level 18
Level 18
Posts: 8945
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by jimallyn » Sun May 12, 2019 2:13 am

Any time two (or more) tones are run through a nonlinear device, additional frequencies are generated. For starters, you will get the sum and difference frequencies, but nonlinearities also create harmonics (2 times the input frequency, 3 times the input frequency, and so on), and then you will get the sums and differences of all those frequencies. With digital audio, add in to the mix another frequency you may not have thought of: the sampling rate. Of course, there is nothing that is perfectly linear, so any audio device is going to generate harmonics and sum and difference frequencies. Most of the time, our audio devices are linear enough that the distortion products are very low level and we don't hear them. How loud are these other sounds you are hearing? Are they subtle, so you have to listen carefully to hear them? Or are they in-your-face obvious? How are the sounds generated, and what program is playing them? If you reduce the level of the two original tones, does the level of the phantom also drop? Does it drop at the same rate as the original tones, or does it drop faster?
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Sun May 12, 2019 4:59 am

jimallyn wrote:
Sun May 12, 2019 2:13 am
Any time two (or more) tones are run through a nonlinear device, additional frequencies are generated.
And to be clear about the definition of "device" there: including the middle ear; c.f. the above szhorvat.net link.

User avatar
jimallyn
Level 18
Level 18
Posts: 8945
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by jimallyn » Sun May 12, 2019 8:22 pm

And the digital to analog converters, and the amplifiers, and the speakers, and so on.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
absque fenestris
Level 6
Level 6
Posts: 1199
Joined: Sat Nov 12, 2016 8:42 pm
Location: Confoederatio Helvetica

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by absque fenestris » Sun May 12, 2019 9:45 pm

rene wrote:
Thu May 09, 2019 4:18 pm
How are you playing the sounds, with and through what, and what are those sounds? If pure sine waves this would be N/A but based on the title alone I initially thought of a shared harmonic at 12 kHz. Not for the other tests you mention and its anyway probably N/A but if you can provide something reproducible someone might have an idea...

[EDIT] And/or this? http://szhorvat.net/pelican/combination-tones.html
Thank you rene for referring to the link from Szabolcs Horvát.
Has clarified some questions that have arisen during my music experiments.
Linux Mint 18.3 Sylvia (Mate) 32-bit - Acer D250 Netbook (Intel Atom N270, 2 GB RAM, 120 GB SSD)
Linux Mint 17.3 Rosa (Mate) 64-bit - MacBook Pro 15" (Intel Core2 Duo, 8 GB RAM, 240 GB SSD) - with some separation difficulties...

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Mon May 13, 2019 4:32 am

Thanks for the replies, I didn't specify the set up, I'm using headphones and listening to 4 kHz sound recording and then playing a 6 kHz sound at the same time on both sides. I did not know about this effect, but I was certain I could tell the 2 tones apart on another computer for some reason, I'll have to test it again later.

Noting the page linked: http://szhorvat.net/pelican/combination-tones.html, I will try to pay more attention to this.

Note: It does sound like the correct pitch for a difference between the 2 tones (2 kHz), I've only recently started getting obsessed with high quality sound, so I have a lot to learn in this field (clearly).

Just in case, I'll answer this:
jimallyn wrote:
Sun May 12, 2019 2:13 am
How loud are these other sounds you are hearing? Are they subtle, so you have to listen carefully to hear them? Or are they in-your-face obvious? How are the sounds generated, and what program is playing them? If you reduce the level of the two original tones, does the level of the phantom also drop? Does it drop at the same rate as the original tones, or does it drop faster?
The sound is about the same volume as the other tones, this happens when Google Chrome plays them on youtube, when I play them on Audacity and on standard media player (vlc and xplayer) (all on Linux Mint 19.1). When changing the volumes of the 2 tones, it seems as if the tone is the same as the lower of the 2 volumes (4 kHz and 6 kHz volumes changed independently). It drops with the drop in volume.
Last edited by Dampi05 on Mon May 13, 2019 6:09 am, edited 1 time in total.

User avatar
catweazel
Level 19
Level 19
Posts: 9587
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by catweazel » Mon May 13, 2019 4:51 am

Dampi05 wrote:
Mon May 13, 2019 4:32 am
I did not know about this effect
https://en.wikipedia.org/wiki/Beat_(aco ... ural_beats
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Mon May 13, 2019 6:31 am

catweazel wrote:
Mon May 13, 2019 4:51 am
Dampi05 wrote:
Mon May 13, 2019 4:32 am
I did not know about this effect
https://en.wikipedia.org/wiki/Beat_(aco ... ural_beats
This much I did know, I've looked at Psychoacoustics but I must have missed this specific effect (and most likely a few others).

Note:
This didn't fix the issue, it seems to be working correctly on Windows and Mac, but not on Linux

Side note:
Thanks for your posts Catweazel, they've helped me back when I moved over to Linux
Last edited by Dampi05 on Mon May 13, 2019 2:12 pm, edited 1 time in total.

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Mon May 13, 2019 2:11 pm

I'm writing another post reply since I've tested this on 2 other computers (Windows and Mac) and could distinguish the 2 tones fine, there seems to be some issue with how Linux handles sound.

Here is my setup:

[Hardware]: Realtek ALC892 (MSI's Nahimic 3) sound card
[Software]: ALSA with PulseAudio server on top (I have not tested if this happens on Jack, but I've been told Jack gives issues with some software that was not designed for it, I'm hoping someone here can tell me otherwise)

I have not tested this laptop under Windows, but I'm certain this issue would not happen under Windows since I'm sure more people would complain if it did (even though this was a pretty random test)

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Mon May 13, 2019 3:52 pm

Only other thing I can think of that could be potentially helpful is inquiring after the sample rate of the played files. Maybe the difference with other systems that you are experiencing is due to resampling. I would still, that is, like you to provide something so that someone can try to reproduce.

Jack is more or less intended for a musician or other production audience. I've never experienced a need for it.

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Mon May 13, 2019 6:36 pm

rene wrote:
Mon May 13, 2019 3:52 pm
Only other thing I can think of that could be potentially helpful is inquiring after the sample rate of the played files. Maybe the difference with other systems that you are experiencing is due to resampling. I would still, that is, like you to provide something so that someone can try to reproduce.

Jack is more or less intended for a musician or other production audience. I've never experienced a need for it.
I'm not too sure what I would need to give to reproduce this, other than the 2 youtube videos I used:
https://www.youtube.com/watch?v=lO9uRNrP8Mo
https://www.youtube.com/watch?v=nyZhQj0k7-s

I will also provide the sample rate of the 2 videos below (from xplayer - after downloading):
4000 Hz - Sample Rate: 44100 Hz, Bitrate: 125 kbps, Codec: MPEG-4 AAC (stereo)
6000 Hz - Sample Rate: 44100 Hz, Bitrate: 125 kbps, Codec: MPEG-4 AAC (stereo)

The expected behaviour (what happens on Windows for example):
When playing them separately, I note what each one sounds like, then when playing together, I can hear them and distinguish between them.

What happens (on my system):
When playing the tones together, a tone that is equal to the difference between them (in Hz) overpowers the sound so that the lower one is noticeable, but the higher tone is hard to detect.

Further note:
When listening to tones such as 250 Hz and 300 Hz, where the difference between them is small, the resultant tone sounds like it starts and stops really quickly (almost like the start of a dial-up telephone / fax tone but lower and consistent in tone, as in, not going higher or lower)

User avatar
catweazel
Level 19
Level 19
Posts: 9587
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by catweazel » Tue May 14, 2019 1:25 am

Dampi05 wrote:
Mon May 13, 2019 2:11 pm
I'm writing another post reply since I've tested this on 2 other computers (Windows and Mac) and could distinguish the 2 tones fine, there seems to be some issue with how Linux handles sound.
Based on the fact that the auditory illusion is expected, I would venture to say Linux is doing the better job of correctly reproducing the sounds :)
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Tue May 14, 2019 3:50 am

catweazel wrote:
Tue May 14, 2019 1:25 am
Dampi05 wrote:
Mon May 13, 2019 2:11 pm
I'm writing another post reply since I've tested this on 2 other computers (Windows and Mac) and could distinguish the 2 tones fine, there seems to be some issue with how Linux handles sound.
Based on the fact that the auditory illusion is expected, I would venture to say Linux is doing the better job of correctly reproducing the sounds :)
But surely if my ear is able to hear both at the same time, it should leave the illusion to my ear rather than trying to emulate it, unless you're saying that Windows and Mac try to go around the issue and therefore the sounds are not really being played at the same time, but rather alternating quickly enough that I don't hear the illusion and don't hear the alternation (instead of pre-mixing into the same sine wave).

Either way, is it possible to switch between these or do I just have to live with it?

Just noticed another thing:
3 kHz sine wave tone and 5 kHz sine wave tone at the same audio encoding settings doesn't give this problem (same with 5 kHz and 7 kHz)
It seems that the 5 kHz sound has a lower bitrate than the 3 kHz sound, when playing ones of equal bitrate, the sound appears again, not sure if this is the cause, just stating (same thing with the 5 and 7 kHz tones) (96 kbps on 5 kHz vs 125 kbps on 7 and 3 kHz tones)

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Tue May 14, 2019 4:53 pm

Dampi05 wrote:
Mon May 13, 2019 6:36 pm
I'm not too sure what I would need to give to reproduce this [ ... ]
That works nicely. I needed a bit of time to experiment but I agree with your description: on Linux mixing them introduces an overpowering lower tone which does not happen on Windows 7 here.

Unsure of what I was listening to with those sources being compressed artefacted audio, I experimented with a local PCM pure sine-generator, but the same thing happens when playing a 4000 Hz and 6000 Hz sine at the same time. Next going straight to ALSA rather than through Pulseaudio -- still same, and including without any resampling taking place.

So I thought I'd simply mix the sines myself. Would you agree that the effect is gone if you save the below as sines.c, do

Code: Select all

sudo apt-get install libpulse-dev
and compile it with the command as given at the top of the file, and run it as ./sines? Note this isn't a fully rhetorical question; by now my ears are quite beepy enough that I could swear hearing sines long after they in fact have stopped...

But, yes, while I wouldn't be sure I could distinguish the 4000 and 6000 tone in this, certainly that lower tone is missing (here). The program mixes in the naivest possible way. This would then seem to say that this is an artefact introduced by the standard mixing.... although it in that case seems at least of note that the effect's the same between ALSA's dmix and Pulseaudio. Also, the below generates a mono stream, but I also tried with stereo; did not change anything of note.

Code: Select all

/* gcc -W -Wall -O2 $(pkg-config --cflags libpulse-simple) -o sines sines.c -lm $(pkg-config --libs libpulse-simple) */

#include <stdlib.h>
#include <stdint.h>
#include <math.h>

#include <pulse/simple.h>

#define FREQ1 4000
#define FREQ2 6000

#define RATE 44100
#define SECS 10

int16_t samples[RATE];

static const pa_sample_spec spec = {
	.format		= PA_SAMPLE_S16NE,
	.rate		= RATE,
	.channels	= 1,
};

int main(void)
{
	int i;
	double x, y;

	for (i = 0, x = 0, y = 0; i < RATE; i++, x += (2 * M_PI * FREQ1) / RATE, y += (2 * M_PI * FREQ2) / RATE)
		samples[i] = (INT16_MAX * (sin(x) + sin(y))) / 2;

	pa_simple *s = pa_simple_new(NULL, "sines", PA_STREAM_PLAYBACK, NULL, "sines", &spec, NULL, NULL, NULL);
	if (!s) 
		return EXIT_FAILURE;

	for (i = 0; i < SECS; i++)
		pa_simple_write(s, samples, sizeof(samples), NULL);

	pa_simple_drain(s, NULL);
	pa_simple_free(s);

	return EXIT_SUCCESS;
}

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Tue May 14, 2019 5:10 pm

Yes, this seems like the phantom note (difference note) is weaker here, it's still noticeable, but way less than what I was experiencing, I also changed the frequencies to 250 Hz and 300 Hz to test that one too since it's easier to notice the mixing issue in those tones (yes, the tone is still there, but not anywhere near as bad)
Last edited by Dampi05 on Tue May 14, 2019 5:27 pm, edited 1 time in total.

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Tue May 14, 2019 5:24 pm

Note, when replying to the immediately above there's usually no need to quote, and certainly not all of it. As a forum reader that sometimes annoys me. I'd edit that above post and remove the entire quote; it's already there right above it anyway after all ;)

Here's by the way the single sine generator I used to test what happens with them mixed by Pulseaudio itself. You'd compile and run this once as is, once with FREQ 6000, and then launch the 4000 one and 6000 one from two terminals --- although I have to say I seemed to at times to be experiencing quite a few more mixing artefacts that way. It's still useful enough to hear the lower tone very present though, again, here.

The INT16_MAX * sin(x) means it's a louder tone then the previous, mixed one. That's in fact probably best, since that is also the difference when using "regular mixing" but if you want to experiment, just make it (INT16_MAX * sin(x)) / 2 same as the other.

I'll try and see if Pulseaudio does anything explicitly interesting when mixing...

Code: Select all

/* gcc -W -Wall -O2 $(pkg-config --cflags libpulse-simple) -o sine sine.c -lm $(pkg-config --libs libpulse-simple) */

#include <stdlib.h>
#include <stdint.h>
#include <math.h>

#include <pulse/simple.h>

#define FREQ 4000
#define RATE 44100
#define SECS 10

static int16_t samples[RATE / FREQ];

static const pa_sample_spec spec = {
        .format         = PA_SAMPLE_S16NE,
        .rate           = RATE,
        .channels       = 1,
};

int main(void)
{
        double x = 0;

        for (int i = 0; i < RATE / FREQ; i++, x += (2 * M_PI * FREQ) / RATE)
                samples[i] = INT16_MAX * sin(x);

        pa_simple *s = pa_simple_new(NULL, "sine", PA_STREAM_PLAYBACK, NULL, "sine", &spec, NULL, NULL, NULL);
        if (!s)
                return EXIT_FAILURE;

        for (int i = 0; i < SECS * FREQ; i++)
                pa_simple_write(s, samples, sizeof(samples), NULL);

        pa_simple_drain(s, NULL);
        pa_simple_free(s);

        return EXIT_SUCCESS;
}
Last edited by rene on Tue May 14, 2019 6:33 pm, edited 1 time in total.

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Tue May 14, 2019 5:41 pm

When testing this with "samples = (INT16_MAX * sin(x)) / 2;" it seems to sound like Windows plays it (in terms of the difference tone) since that tone seems to be almost gone (at least on the 4000 Hz to 6000 Hz one), on the 250 Hz to 300 Hz, the tone just sounds slightly like a phone ring (with a lower and consistent tone).

The / 2 makes all the difference in this case.

rene
Level 12
Level 12
Posts: 4172
Joined: Sun Mar 27, 2016 6:58 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by rene » Tue May 14, 2019 5:52 pm

Well, this seems to be explained at least. As far as I could see Pulseaudio simply adds-and-clamps the samples. As per the below that is, which does indeed here reintroduce the lower tone. I don't believe it's configurable on the Pulseaudio side either. clamps.c:

Code: Select all

/* gcc -W -Wall -O2 $(pkg-config --cflags libpulse-simple) -o clamps clamps.c -lm $(pkg-config --libs libpulse-simple) */

#include <stdlib.h>
#include <stdint.h>
#include <math.h>

#include <pulse/simple.h>

#define FREQ1 4000
#define FREQ2 6000

#define RATE 44100
#define SECS 10

int16_t samples[RATE];

static const pa_sample_spec spec = {
	.format		= PA_SAMPLE_S16NE,
	.rate		= RATE,
	.channels	= 1,
};

int main(void)
{
	int i;
	double x, y;

	for (i = 0, x = 0, y = 0; i < RATE; i++, x += (2 * M_PI * FREQ1) / RATE, y += (2 * M_PI * FREQ2) / RATE) {
		int32_t sample = INT16_MAX * (sin(x) + sin(y));
		samples[i] = sample < INT16_MIN ? INT16_MIN : sample;
		if (sample > INT16_MAX)
			samples[i] = INT16_MAX;
	}

	pa_simple *s = pa_simple_new(NULL, "sines", PA_STREAM_PLAYBACK, NULL, "sines", &spec, NULL, NULL, NULL);
	if (!s) 
		return EXIT_FAILURE;

	for (i = 0; i < SECS; i++)
		pa_simple_write(s, samples, sizeof(samples), NULL);

	pa_simple_drain(s, NULL);
	pa_simple_free(s);

	return EXIT_SUCCESS;
}

Dampi05
Level 1
Level 1
Posts: 14
Joined: Thu May 09, 2019 3:22 pm

Re: Audio Phantom Sound - 4 kHz + 6 kHz

Post by Dampi05 » Tue May 14, 2019 5:59 pm

I wonder if this could be considered a bug or if it's intended behaviour

Post Reply

Return to “Sound, Multimedia, & Codecs”