Jump to content

Beep function


Recommended Posts

CyberSlugs Beep Dll

Again same question:

Is it possible to play a sound as long as you press a button? (How?) Because it seems, as if you have to put duration to play a sound, when you start playing it.

Edited by Markus

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

No its not exactly what i wanted. The sound in this script is only played very often. For example if you press a button very long, you hear clearly that the sound is played and replayed and replayed, i would prefer to have one clear sound, but for that i have to start playing the sound, when i press a button and have to stop the sound when i stop pressing the button. So it's impossible to do that with the beep function(?), since i have to put the duration at the start, where i can't know how long the button will be pressed.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Okay, so it seems as if its impossible to play a sound as long as you press a button with that dll?

So are there other beep dlls which make that possible?

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Okay, so it seems as if its impossible to play a sound as long as you press a button with that dll?

So are there other beep dlls which make that possible?

Have a look at the Demo Beep script here http://www.autoitscript.com/forum/index.ph...amp;hl=Beep+Dll

just make your Beep duration really long, start it with _Ispressed and Stop it with Exit.

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

A beep sound can't be interrupted, that demo helps only, to stop the script in the loop.

If you press the exithotkey it will stop after the tone is played.

Sure it's possible to do sth like this:

While _isPressed(..)
     Beep(...,10)
Wend

But it doesnt listen nice.

After testing that demo script, i think even more, that it is impossible to play a tone with the "Beep" function, as long as you press a button, without that replay and replay trick in my code above.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Personally, beep is one of my favorite functions, but unles you made it so you'd push the button, hold it for a time then when you let it go it would beep for the same time thats possible

but other than that, the computer cant beep for an unknown duration

Link to comment
Share on other sites

KB-Piano

I wonder if sth like that would be possible with autoit.... it's rly great......

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Personally, beep is one of my favorite functions, but unles you made it so you'd push the button, hold it for a time then when you let it go it would beep for the same time thats possible

but other than that, the computer cant beep for an unknown duration

Okay, ty

Next sound question:

How to play sounds through real speakers? Without playing special files (Soundplay() ), just as the beep function, but for real speakers.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Okay, ty

Next sound question:

How to play sounds through real speakers? Without playing special files (Soundplay() ), just as the beep function, but for real speakers.

SoundPlay will only play a wav or Mp3 file that is on your HD.

I would have thought you could control the Beep function with two scripts, one to scan the keyboard and when a key is pressed it runs the second script for the Beep function, when the key is released, the second Beep script is terminated.

There are various ways to have the second script terminate, first way I can think of is to have the Keyboard write a Flag value to the Registry, then have the second beep script read the registry value.

There are also scripts that can terminate a process, so you could use that method as well.

Edited by Lakes

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

I would have thought you could control the Beep function with two scripts, one to scan the keyboard and when a key is pressed it runs the second script for the Beep function, when the key is released, the second Beep script is terminated.

There are various ways to have the second script terminate, first way I can think of is to have the Keyboard write a Flag value to the Registry, then have the second beep script read the registry value.

Ahh ok well, i'll try that, ty.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Ok it works:

Main.au3:

CODE
#include <misc.au3>

HotKeySet("^q","_exit")

Global $pid[11]

Global $exe=1

For $exe=1 To 10

IniWrite(@ScriptDir & "\uerbertrag.ini","Beep","Playsound" & $exe,0)

Next

For $exe=1 To 10

$pid[$exe]=Run ('"' & @ScriptDir & '\Beep.exe"' & '"' & $exe & '"')

Next

$exe=1

While 1

Sleep(10)

If _IsPressed(51) Then

IniWrite(@ScriptDir & "\uerbertrag.ini","Beep","Playsound" & $exe,1)

;Run (@ScriptDir & "\Beep.exe")

While _IsPressed(51)

WEnd

ProcessClose($pid[$exe])

IniWrite(@ScriptDir & "\uerbertrag.ini","Beep","Playsound" & $exe,0)

$pid[$exe]=Run ('"' & @ScriptDir & '\Beep.exe"' & '"' & $exe & '"')

If $exe=10 Then

$exe=1

Else

$exe=$exe+1

EndIf

EndIf

WEnd

Func _exit()

Exit

EndFunc ;==>_exit

Func OnAutoItExit()

For $exe=1 To 10

ProcessClose($pid[$exe])

IniWrite(@ScriptDir & "\uerbertrag.ini","Beep","Playsound" & $exe,0)

Next

EndFunc ;==>OnAutoItExit

Beep.au3:

#NoTrayIcon
$reader=$CmdLine[1]

While 1
    Sleep(10)
    If IniRead(@ScriptDir & "\uerbertrag.ini","Beep","Playsound" & $reader,0)=1 Then Beep(1000,6000)
WEnd

Compile Beep.au3 to Beep.exe, put both files in the same folder and start the main:

Wait some secs, then you may play sounds as long as you press a button. As it was only short work, you may only play with "q" and only one freq. But freq shouldn't be a problem. One problem that remains, is that you can't play many notes very fast after eachother.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...