Results 1 to 9 of 9

Thread: Beep Plugin

  1. #1
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Beep Plugin

    I made this for my amusement to use while playing semi-afk or to alert me when encountering a random.

    Here's the API:

    Code:
    function Beep(freq, duration: ShortInt): Boolean;
    function MessageBeep(id: Word): Boolean;
    
    function BEEP_SIMPLE(): Word;
    function BEEP_ERROR(): Word;
    function BEEP_WARNING(): Word;
    function BEEP_QUESTION(): Word;
    function BEEP_INFORMATION(): Word;
    function BEEP_OK(): Word;
    The first two are the beeping functions you should use.

    Beep is a hardware beep requiring an 8254 sound chip which may not work on newer computers which don't have the chip. If there is hardware support, it will beep even if software sound is disabled (unless hardware sound is also disabled). Beep will not work in Vista or XP 64-bit machines.

    The frequency is in Hertz and ranges between 37 through 32,767. The duration is in milliseconds.

    MessageBeep is a software beep that uses the standard Windows sounds you have set up in your control panel. To get there, go to Control Panel -> Sounds -> Sounds tab. The argument is the return value of one of the six BEEP_NAME functions listed above [I have them as functions rather than constants because Simba can only import DLL functions, not data, but if you leave off the parentheses it's just the same for scripting.].

    Control Panel sound correspondence (to change the sounds):

    • BEEP_SIMPLE: May not be changed. You can use this if you want to make sure that the sound is heard regardless of Control Panel configuration.
    • BEEP_ERROR: Windows Critical Stop.
    • BEEP_WARNING: Windows Exclamation.
    • BEEP_QUESTION: Windows Question.
    • BEEP_INFORMATION: Windows Asterisk.
    • BEEP_OK: Windows Default Beep.

    BEEP_SIMPLE may not be changed. You can use this if you want to make sure that the sound is heard regardless of Control Panel configuration.

    Both beep functions return false if they fail, or true if they succeed. If you call MessageBeep with an argument other than those provided in the six BEEP_NAME functions, it will return false, though it may play a sound nonetheless.

    Here is a testing script to try out the plugin:

    Code:
    {Aftermath 11/22/11}
    program BeepDemo;
      var success: Boolean;
      var freq, duration: ShortInt;
    {$Loadlib SimbaBeep}
    begin
      freq := 750;
      duration := 300;
    
      WriteLn('Beep Test');
      success := Beep(freq, duration);
      WriteLn('Hardware beep: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_SIMPLE);
      WriteLn('Software beep SIMPLE: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_ERROR);
      WriteLn('Software beep ERROR: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_WARNING);
      WriteLn('Software beep WARNING: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_QUESTION);
      WriteLn('Software beep QUESTION: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_INFORMATION);
      WriteLn('Software beep INFORMATION: ' + BoolToStr(success));
    
      Wait(1000);
      success := MessageBeep(BEEP_OK);
      WriteLn('Software beep OK: ' + BoolToStr(success));
    end.
    To install, place the attached DLL in your Plugins directory. The DLL is for use with 32-bit Simba only. This shouldn't matter much since 64-bit Simba is a buggy piece of trash anyway

    I've attached the source. You'll need to make a Win32 DLL project in Visual Studio, and use the .def file for the module definition.
    Last edited by Aftermath; 11-23-2011 at 01:26 AM.

  2. #2
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Please post source code of the DLL.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  3. #3
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    FYI: http://docs.villavu.com/simba/script...ight=playsound

    Looking over the API, it looks good. Didn't actually test it due to lack of source code.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  4. #4
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have attached the source and the module definitions file.

  5. #5
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Cool
    Simple, yet effective.
    Hup Holland Hup!

  6. #6
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I use this to AFK train to tell me when my prayers ran out.

    Simba Code:
    program Timer;
    {$Loadlib SimbaBeep}
    const ToWait = 142000;
    begin
      Wait(ToWait);
      MessageBeep(BEEP_OK);
    end.

  7. #7
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    Cool
    Simple, yet effective.
    It reminds me of my Runite miner which would play the ``Halleluja'' sound (Holy hand grenade in World World Party) every time it mined a Runite ore...

    Source looks good.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  8. #8
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,880
    Mentioned
    7 Post(s)
    Quoted
    152 Post(s)

    Default

    Anyway to make this send the user a text-message or an email?
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  9. #9
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Of course, though if I were to make routines to send an SMS, I wouldn't put it in a plugin called 'SimbaBeep'. That's an interesting idea though, I might make that sometime.

    Edit: Did some experiments with sending SMS programmatic - the current method I'm using seems to require knowing the recipient's carrier, which would be a stumbling block to a clean API. I may look for another way later

    Edit 2: In the United States, text messages most often charge the receiver only, meaning that I can send to U.S. numbers for free by knowing their carriers. To send internationally, or without bothering to look up the carriers, I would need to use a pay service, which I'm not willing to pay for. So that about wraps up the discussion of my writing anything of the sort.

    Edit 3: Of course, I might use this to SMS myself Though I doubt there'd be any reason to since I would never use bots while not keeping track of them.
    Last edited by Aftermath; 11-25-2011 at 02:09 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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