Playing Sounds on the internal speaker-VBForums
Results 1 to 6 of 6

Thread: Playing Sounds on the internal speaker

  1. #1

    Thread Starter
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Playing Sounds on the internal speaker

    Using the following code even if your speakers are switched off you can still make a beep sound.

    Code:
     Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As _
               Integer, ByVal dwDuration As Integer) As Integer
    'event
    Beep(500, 500)'plays a beep at 500 frequency and 500milliseconds
    Computer's internal speaker volume and frequency threshold varies from computer to computer so you will not be able to play all freuqencies.
    Setting the frequency between 13000 and 16500 will make the hight pitched "mosquito" noise which most adults can't hear and will hurt your ears if you have good hearing.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  2. #2
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    Re: Playing Sounds on the internal speaker

    Seems like this belongs here ...

    http://www.phy.mtu.edu/~suits/notefreqs.html

  3. #3
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    Re: Playing Sounds on the internal speaker

    Sothing I realized over the holidays, win7 is rumored to eventually drop any support for kern32, the alternative to this in dotnet is:

    code Code:
    1. System.Console.Beep(Integer, Integer)
    Last edited by spyk3; Dec 29th, 2009 at 05:30 PM.

  4. #4
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    Re: Playing Sounds on the internal speaker

    Just a quick dll add (seems like it belongs here too)
    this contains a variable list for every note (frequency already given for each variable)
    for any other music nuts like me that might want to play around with not just console beep but really any embeded audio device will play the majority of these notes
    keep in mind notes c1Sharp and below are less than 37 which is the minimum for most machine speakers, and anything over 12,000 is pretty much in audible unless you're a dog
    Attached Files Attached Files

  5. #5
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,529

    Re: Playing Sounds on the internal speaker

    Quote Originally Posted by spyk3 View Post
    Just a quick dll add (seems like it belongs here too)
    this contains a variable list for every note (frequency already given for each variable)
    for any other music nuts like me that might want to play around with not just console beep but really any embeded audio device will play the majority of these notes
    keep in mind notes c1Sharp and below are less than 37 which is the minimum for most machine speakers, and anything over 12,000 is pretty much in audible unless you're a dog
    I ran indirectly into this thread. How do you use the dll, what are the embedded functions?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  6. #6
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,529

    Re: Playing Sounds on the internal speaker

    Quote Originally Posted by cameron2 View Post
    Using the following code even if your speakers are switched off you can still make a beep sound.

    Code:
     Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As _
               Integer, ByVal dwDuration As Integer) As Integer
    'event
    Beep(500, 500)'plays a beep at 500 frequency and 500milliseconds
    Computer's internal speaker volume and frequency threshold varies from computer to computer so you will not be able to play all freuqencies.
    Setting the frequency between 13000 and 16500 will make the hight pitched "mosquito" noise which most adults can't hear and will hurt your ears if you have good hearing.
    Is this supposed to apply to .Net only? I've tried it under VB6 and it works if frequency and duration are stated as constants, but not if they are variables.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.