Jump to content


Photo

Buzzer


  • Please log in to reply
9 replies to this topic

#1 da gamer

da gamer

    GMC Member

  • GMC Member
  • 227 posts

Posted 03 May 2010 - 04:53 PM

Hello,

is there a simple dll that can use the computers internal buzzer to beep at a certain frequency. iv'e looked around but have not seen a dll that can do this

Thanks
  • 0

#2 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 03 May 2010 - 08:34 PM

To be assembled with Flat Assembler:
format PE GUI 4.0 DLL

include 'win32a.inc'
section 'exe' code data executable readable writeable
data import
library k,'KERNEL32.DLL'
import k,kbeep,'Beep'
end data

beep:
  fld qword[esp+04h]
  fld qword[esp+0Ch]
  sub esp,8
  fistp dword[esp+4]
  fistp dword[esp]
  call [kbeep]
  fldz
  retn 0x10
align 4
data export
export "BEEPDLL.DLL",beep,'beep'
end data
align 4
data fixups
end data
Exports one function, "beep", case sensitive, first argument is frequency and second is duration, stdcall, all ty_real.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#3 da gamer

da gamer

    GMC Member

  • GMC Member
  • 227 posts

Posted 04 May 2010 - 04:09 PM

Thanks mate. It has really helped me a lot. If you want I can host the DLL for other people and with a small example on how to use it. However I can only do this is this is your script or it is in the public domain.

Thanks again. Dave
  • 0

#4 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 04 May 2010 - 08:42 PM

It's fine, it's a tiny little thing so feel free to use it however you want.
Edit - Also, as this code may fail in some very exceptional cases, you might want to change this:
fistp dword[esp]
  call [kbeep]
To this:
fistp dword[esp]
  wait
  call [kbeep]
This will just make sure that the processor has passed the arguments on to the next function before it tries to call it.

Edited by score_under, 04 May 2010 - 08:45 PM.

  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#5 jobro

jobro

    GMC Member

  • GMC Member
  • 1300 posts
  • Version:GM:Studio

Posted 05 May 2010 - 08:24 PM

Please note that sites like stopbadware.org tend to crack down hard on tools that beeps a lot, and since the buzzer don't have a volume control there is a big chance that you will get comments from such sites, so please add an option to disable the buzzer in the game's options. Also note that the buzzer is disabled on most modern computers, some have access to it in the mixer, but not all.

With this said here is some fun stuff to do:

Short beeps at a frequency +/- 1/10 of the frequency gives you a noisy buzz.

Short beeps altering between two frequencies modulating the 2nd gives you a synced sound.

And btw thanks for the assembler.

So let me get this straight:

global.beep = external_define('Beep.dll','Beep',stdcall,ty_real,2,ty_real,ty_real)
is used at gamestart to load the DLL function if I've understood this right?

Edited by jobro, 05 May 2010 - 08:48 PM.

  • 0

Marketplace.png


#6 da gamer

da gamer

    GMC Member

  • GMC Member
  • 227 posts

Posted 06 May 2010 - 03:34 PM

This is a small example on how to use this DLL

Game Start Event:
handle=external_define("beep.dll","beep",dll_stdcall,ty_real,2,ty_real,ty_real)

Keyboard Event:
external_call(handle,1000,100)

Game End Event:
external_free("beep.dll")

  • 0

#7 jobro

jobro

    GMC Member

  • GMC Member
  • 1300 posts
  • Version:GM:Studio

Posted 11 May 2010 - 05:28 AM

Thanks. Still I'm not sure if this is exactly what I need, however with your approval I wish to create an extension of it to help others to use it.

Edited by jobro, 11 May 2010 - 05:36 AM.

  • 0

Marketplace.png


#8 IQbrew

IQbrew

    Pro-Grammar

  • Banned Users
  • 2607 posts
  • Version:Unknown

Posted 11 May 2010 - 05:34 AM

Error belayed

Edited by IQbrew, 11 May 2010 - 05:43 AM.

"Personally, I rather look forward to a computer program winning the world chess championship. Humanity needs a lesson in humility. "

#9 jobro

jobro

    GMC Member

  • GMC Member
  • 1300 posts
  • Version:GM:Studio

Posted 11 May 2010 - 05:38 AM

D'oh! I know what the problem was, I had some initializer code in a room trying to set things up, so please do belay the last error from me. I must be damn tired right now... ^_^
  • 0

Marketplace.png


#10 da gamer

da gamer

    GMC Member

  • GMC Member
  • 227 posts

Posted 11 May 2010 - 05:20 PM

hey jobro,

You may create an exension of this code (not up to me relly). however i have already created an extension in my DLL which i posted a while ago in the DLL section but noone has replied too so i dunno if anyone needs it
  • 0