Click here to Skip to main content
15,444,353 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
I just wonder ... I can hear a created sound with this code :
C#
Console.Beep(32767, 5000);


So , How can I hear it ?! I know the human can't hear sound more than 20 kilohertz and I am not a child too (I mean my hears is not young enough to hear 20 kilohertz) !!! but it seems that I hear more than 32 kilohertz !!!

So , Is this code different ?! What is wrong ?!

Maybe I am an endangered species :D !
Posted
Comments
Zoltán Zörgő 21-Jan-15 13:56pm    
Most likely, it is emitting lower frequency (too).
CPallini 21-Jan-15 15:53pm    
I can't hear half of such frequency :-(
Sergey Alexandrovich Kryukov 21-Jan-15 20:16pm     CRLF
My 5 for your curiosity and critical thinking. —SA
TheRealSteveJudge 22-Jan-15 2:37am    
My 5 for the sense of humour!

Could be anything: harmonics, faulty hardware, you being very, very young (the range you can hear changes as you age).

Or it could be that the frequency generator that produces the beep in your PC is just not very good at high frequencies.
So try an experiment.
Do that, and reduce the frequency by a thousand Hz each time. Do you hear it continuously? Does the tone get "deeper" continuously?
If it does do, all the way down, then yes you're a freak!:laugh:
If it doesn't, then it's probably hardware.

If it helps, I hear it as well, but it "fades" as the frequency drops until I can;t hear it, then it gets louder again as it drops through the "normal human range" - so it's almost certainly a frequency generation problem.
 
Share this answer
 
Comments
ZurdoDev 21-Jan-15 15:22pm    
It does seem a valid question yet makes me think something obvious is being missed. Humans typically only hear to a max of 20k and this function supports up to 32k? That's quite a bit higher with no real value. Me thinks the frequency value you pass in is not the same as the frequency of the actual sound.
CPallini 21-Jan-15 15:45pm    
Are you discriminating against dogs?
ZurdoDev 21-Jan-15 15:46pm    
Yes.
OriginalGriff 21-Jan-15 15:48pm     CRLF
It may be reasonably accurate within the range of hearing for a "normal human" - IIRC in the early days BS (Before Sound blaster) there were quite a lot of real tunes played on it. But if I was designing the hardware, I wouldn't care too much about the range outside human hearing, especially if it cost extra money to make it work.
ZurdoDev 21-Jan-15 15:54pm    
Actually, limiting filters are easily built, but now where getting way off topic.
I can hear it, too, subjectively, painfully high pitch. (Hurray! I'm young again!) But I also can here low-frequency clicks. Nothing wrong is perceived for audible frequencies; and the musical tones sound realistic (if they are not too low, where discretization errors are considerable). But the tone is pretty dirty.

This does not yet proof anything. But then I lowered your tone by some hundreds of hertz, and… subjective tone of high pitch did not change. It's already wrong. Moreover, when I lowed the tone by 2/3, 3/4 and 1/2 (perfect fifth, perfect fourth and octave, the intervals most distinctly perceived and detected by human year as most harmonic, due to obvious physical characteristics of human hearing), the audible tone… completely disappeared despite the fact that it should become closer to the normal human-audible domain.

Probably, you should not take this generation too seriously.

But the question is very good, I appreciate it.

—SA
 
Share this answer
 
v2
Comments
TheRealSteveJudge 22-Jan-15 2:38am    
5*
Sergey Alexandrovich Kryukov 22-Jan-15 2:46am     CRLF
Thank you, Steve. —SA
MohammadSina Karvandi 22-Jan-15 6:06am    
thank you for your time and read ! :)
Sergey Alexandrovich Kryukov 22-Jan-15 11:17am     CRLF
My pleasure. —SA
There are 2 propositions one can consider:

a) You CAN hear way above 20kHz
b) The speaker is NOT vibrating at 32kHz

To test proposition a your equipment is totally inadequate. Why do auditory labs have the equipment and facilities they have? So lets rule that out for the moment.

Proposition b seems most likely. The audio amplifier may supply a 32kHz voltage but even in the world of esoteric hifi a tweeter capable of vibrating at 32kHz is very rare. The speaker is vibrating at some other frequency in response to the input and my guess would be it's resonant frequency - probably a few kHz.

This test is illuminating:

C#
for (int freq = 100; freq < 32767; freq += 300)
{
    Console.WriteLine(freq);
    Console.Beep(freq, 200);
}


The perceived increase in frequency stops long before the upper limit. This is where the audio system stops being capable of following the input.

If we consider this example:
https://msdn.microsoft.com/en-us/library/4fe3hdb1(v=vs.110).aspx[^]

and add:

C#
// Define the octave multiplier.
protected enum Octave
{
    same = 1,
    one = 2,
    two = 4,
    three = 8,
    four = 16,
    five = 32,
    six = 64,
}

and:

C#
// Play the notes in a song.
protected static void Play(Note[] tune, Octave octave = Octave.same)
{
    foreach (Note n in tune)
    {
        if (n.NoteTone == Tone.REST)
            Thread.Sleep((int)n.NoteDuration);
        else
            Console.Beep((int)n.NoteTone * (int)octave, (int)n.NoteDuration);
    }
}

then we can do:

C#
// Play the song
Play(Mary, Octave.two);

By octave 5 the notes are starting to sound the same which means we are reaching the limit of the system to faithfully reproduce the input.
 
Share this answer
 
v5
Comments
Sergey Alexandrovich Kryukov 21-Jan-15 21:06pm     CRLF
Agree, a 5. See also my my updated answers; I made some extra experiments, out of curiosity. —SA
[no name] 21-Jan-15 21:45pm    
Yes so did I.
TheRealSteveJudge 22-Jan-15 2:38am    
5*
MohammadSina Karvandi 22-Jan-15 6:05am     CRLF
Yeah , thank u for read and I think you're right ... According your answer : I use your first code and I realize that I can't hear a frequency between 19.5 kilohertz to 26 kilohertz but I can hear the above frequency. So as I understand from your answer my Device (The Speaker of My Lap top ) don't work normally for the frequencies above the 26 kilo hertz . So , Am I right ?!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900