Sign in to follow this  
Followers 0
Mast3rpyr0

hearing test

14 posts in this topic

Probably not accurate at all but this is supposed to tell you the highest and lowest frequencies you can hear. Press start, wait for the sound and then hit stop, then wait until you dont hear sound to press again.

#include <GUiconstants.au3>

$mainWindow = GUICreate("Sound Test", 225, 75)

GUICtrlCreateLabel("Highest:", 10, 13)
$top = GUICtrlCreateInput("", 55, 10, 50)
GUICtrlCreateLabel("Lowest:", 110, 13)
$bottem = GUICtrlCreateInput("", 155, 10, 50)
$actionBtn = GUICtrlCreateButton("Start", 75, 45, 75)

Guisetstate(@SW_SHOW, $mainWindow)

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
    case $GUI_EVENT_CLOSE
        Exit
    case $actionBtn
        _doSoundTest()
    EndSwitch
WEnd

Func _doSoundTest()
    GUICtrlSetData($actionBtn, "Stop")
    $i = 100000
    Do
        Beep($i, 10)
        $i -= 50
    Until GUIGetMsg() = $actionBtn
    GUICtrlSetData($top, $i)
    Do
        Beep($i, 10)
        $i -= 50
    Until GUIGetMsg() = $actionBtn
    GUICtrlSetData($bottem, $i)
    GUICtrlSetData($actionBtn, "Start")
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Probably not accurate at all but this is supposed to tell you the highest and lowest frequencies you can hear. Press start, wait for the sound and then hit stop, then wait until you dont hear sound to press again.

#include <GUiconstants.au3>

$mainWindow = GUICreate("Sound Test", 225, 75)

GUICtrlCreateLabel("Highest:", 10, 13)
$top = GUICtrlCreateInput("", 55, 10, 50)
GUICtrlCreateLabel("Lowest:", 110, 13)
$bottem = GUICtrlCreateInput("", 155, 10, 50)
$actionBtn = GUICtrlCreateButton("Start", 75, 45, 75)

Guisetstate(@SW_SHOW, $mainWindow)

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
    case $GUI_EVENT_CLOSE
        Exit
    case $actionBtn
        _doSoundTest()
    EndSwitch
WEnd

Func _doSoundTest()
    GUICtrlSetData($actionBtn, "Stop")
    $i = 100000
    Do
        Beep($i, 10)
        $i -= 50
    Until GUIGetMsg() = $actionBtn
    GUICtrlSetData($top, $i)
    Do
        Beep($i, 10)
        $i -= 50
    Until GUIGetMsg() = $actionBtn
    GUICtrlSetData($bottem, $i)
    GUICtrlSetData($actionBtn, "Start")
EndFunc
You're on the right track but you should change

Until GUIGetMsg() = $actionBtn

To

Until GUIGetMsg() = $actionBtn OR $i = 0

Otherwise it will just keep counting down into useless ranges

Edit: Also at the top of the _doSundTest() function

GUICtrlSetData($top, "")
    GUICtrlSetData($Bottem, "")
to clear the inputs when starting a second test Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hah, that sounded like a bomb :)

neeeeeeeeeeeeeeeeeeooooooooooooowwwwwwwwwwwwwwwwwwwwwwwwuuuuuuuuuuuuuuuuuuuuuuuuuggggggggggggggggggg

ggggg

Yeah. Like that.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i had that exact line but it didnt stop so i took it out

I probably should have used

Until GUIGetMsg() = $actionBtn OR $i <= 0

But a better method is probably to put the following as the first line in both Do/Until loops

If $i <= 0 Then ExitLoop

Edit:

Actually you can change that to If $i <= 37. That's the bottom end for Beep()

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hah, that sounded like a bomb :)

Yeah. Like that.

I had to change the beep duration to 30. That's because at my age the range is narrow and the reflex times are slow. I does slow it down a bit though.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

THIS IS SOOOO AWESOME!

Share this post


Link to post
Share on other sites

My Score:

Highest: 31950

Lowest: -1600

Cool!

Share this post


Link to post
Share on other sites

Hi there.

It's a nice idea, yes, but I think it's not the best way of testing hearing.

First of all, most sound devices don't produce sound above 22050Hz. When they do, most of them don't do it accurately.

And even if they can produce those high frequencies, most speakers can't handle them properly as well.

So, the general limits are around this:

minimum: 30 Hz (generated by a woofer)

maximum: 20000 Hz (generated by a tweeter)

Only good sound cards and GREAT speakers will generate true 20000 Hz.

Another thing: I don't know how much do you know about sound and frequencies, but requesting negative frequencies won't produce any sound at all. If they do, then that is normally caused by an out-of-boundary device error.

In conclusion, I could say "ok, it's not impossible for a human being to hear above 20000 Hz", but:

1) I'm just saying this because I believe that nothing is impossible (hearing hypersound is not a human characteristic);

2) your speakers/audio card don't generate those frequencies correctly.

So maybe it would be a better idea to generate random frequencies between 30 and 20000 Hz, asking the user to click the button whenever he/she hears any sound (sleep time also random, so the user will never know when the sound will be triggered).

But there's also a psychologial factor that is, most audio cards generate a short "pop" noise when starting/stopping sounds. For both very high and very low frequencies, this often leads the user to think he/she is hearing something, even when he/she isn't.

However, the suggestion above can also trap those "mistakes", and who knows calculate an error ratio (for instance, an user could detect 100% of frequencies between 150Hz and 14000 Hz, and have a 63% ratio of detection of 16000 Hz. And a 14% ratio of erractic detection - when you think you were hearing, but you were just imagining).

Sorry, was I being too haisty? :)


Share this post


Link to post
Share on other sites

Hi there.

It's a nice idea, yes, but I think it's not the best way of testing hearing.

First of all, most sound devices don't produce sound above 22050Hz. When they do, most of them don't do it accurately.

And even if they can produce those high frequencies, most speakers can't handle them properly as well.

So, the general limits are around this:

minimum: 30 Hz (generated by a woofer)

maximum: 20000 Hz (generated by a tweeter)

Only good sound cards and GREAT speakers will generate true 20000 Hz.

Another thing: I don't know how much do you know about sound and frequencies, but requesting negative frequencies won't produce any sound at all. If they do, then that is normally caused by an out-of-boundary device error.

In conclusion, I could say "ok, it's not impossible for a human being to hear above 20000 Hz", but:

1) I'm just saying this because I believe that nothing is impossible (hearing hypersound is not a human characteristic);

2) your speakers/audio card don't generate those frequencies correctly.

So maybe it would be a better idea to generate random frequencies between 30 and 20000 Hz, asking the user to click the button whenever he/she hears any sound (sleep time also random, so the user will never know when the sound will be triggered).

But there's also a psychologial factor that is, most audio cards generate a short "pop" noise when starting/stopping sounds. For both very high and very low frequencies, this often leads the user to think he/she is hearing something, even when he/she isn't.

However, the suggestion above can also trap those "mistakes", and who knows calculate an error ratio (for instance, an user could detect 100% of frequencies between 150Hz and 14000 Hz, and have a 63% ratio of detection of 16000 Hz. And a 14% ratio of erractic detection - when you think you were hearing, but you were just imagining).

Sorry, was I being too haisty? :)

The author did not claim that it was a bio-medical instrument.

Although you're correct that there are equipment factors which come into play, the prime human hearing range is considered to be 20 - 20000 hz. That is prime. By the time you hit middle age good hearing is 20 - 15000 hz. You could never market this as a hearing test for several reasons (including the accuracy of to computer clock frequency) but it does give a rough indication.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hi there.

It's a nice idea, yes, but I think it's not the best way of testing hearing.

First of all, most sound devices don't produce sound above 22050Hz. When they do, most of them don't do it accurately.

And even if they can produce those high frequencies, most speakers can't handle them properly as well.

So, the general limits are around this:

minimum: 30 Hz (generated by a woofer)

maximum: 20000 Hz (generated by a tweeter)

Only good sound cards and GREAT speakers will generate true 20000 Hz.

Another thing: I don't know how much do you know about sound and frequencies, but requesting negative frequencies won't produce any sound at all. If they do, then that is normally caused by an out-of-boundary device error.

In conclusion, I could say "ok, it's not impossible for a human being to hear above 20000 Hz", but:

1) I'm just saying this because I believe that nothing is impossible (hearing hypersound is not a human characteristic);

2) your speakers/audio card don't generate those frequencies correctly.

So maybe it would be a better idea to generate random frequencies between 30 and 20000 Hz, asking the user to click the button whenever he/she hears any sound (sleep time also random, so the user will never know when the sound will be triggered).

But there's also a psychologial factor that is, most audio cards generate a short "pop" noise when starting/stopping sounds. For both very high and very low frequencies, this often leads the user to think he/she is hearing something, even when he/she isn't.

However, the suggestion above can also trap those "mistakes", and who knows calculate an error ratio (for instance, an user could detect 100% of frequencies between 150Hz and 14000 Hz, and have a 63% ratio of detection of 16000 Hz. And a 14% ratio of erractic detection - when you think you were hearing, but you were just imagining).

Sorry, was I being too haisty? :)

Yes, way too hasty! My first question was also: Is the computer able to produce these sounds? The answer is yes.

The script uses the internal speaker of the computer which van generate tones from 18.5 Hz to 1.1 x 10 ^ 6 Hz. Far beyond the human hearing. (1). The internal speaker is also able to accurately produce these tones.

The human hearing is between 20 Hz to 20,000 Hz (some state the lowest to be 15 Hz) (2).

So in fact, this script should be quite good at testing ones hearing with quite accurate results. (Except for the part where it goes below 0, but that problem is easily overcome).

Share this post


Link to post
Share on other sites

The author did not claim that it was a bio-medical instrument.

Although you're correct that there are equipment factors which come into play, the prime human hearing range is considered to be 20 - 20000 hz. That is prime. By the time you hit middle age good hearing is 20 - 15000 hz. You could never market this as a hearing test for several reasons (including the accuracy of to computer clock frequency) but it does give a rough indication.

The processor's clock frequency has absolutely nothing to do with the internal speaker.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

@GEOSoft

Well i didn't say the contrary ;)

@Manadar

"from 18.5 Hz to 1.1 x 10 ^ 6 Hz"

Are you sure about that? Because I haven't had any PC that would do that. Maybe not from the speaker itself, but from the sound device or its controller or whatever.

I mean, I really had the opportunity to test it with sound measuring devices. Above 20000Hz it was near this:

- half the PCs don't produce the sound correctly (often generating something similar to pink noise);

- the other half wouldn't even generate any sound.

I know my post was pretty haisty; that's why I said it so you guys wouldn't take it as an offense :P

But if you want I can resume it pretty well with these suggestions:

- Don't test over 22 kHz (for most PCs not over 20 kHz);

- Let each frequency play more time, at least near the boundaries of the test (this would prevent "wrong testing" due to the lag in user response);

- Don't let the frequency drop below 18 (it would make no sense).

Peace :)

EDIT: Ah ok, Manadar, your link explains it. In theory :P

Details added.

Edited by footswitch

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0