View previous topic :: View next topic |
Author |
Message |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Sat Nov 22, 2008 1:27 am Post subject: How do I make the computer beep? |
|
|
I'm sending ASCII characters to a text window. I call a subroutine with the integer value of the ASCII character (0-127), and the subroutine uses CHAR to convert to a character, then appends the character to the end of a buffer that's being displayed in the text window, and update. All is well and good, it works. Printable ones appear as though the window were a console of some kind, no problem. Even the CR/LF combo performs as expected - very cool.
When I send it a 7, which is the ASCII "BEL" character, I'd like the computer to go "beep". It doesn't - I just get a small black block for that character in the text window. I can suppress the black block easily enough. But how do I make the computer go "beep"? The HELP file describes some kind of BEEP function, and uses it in a line where a button is pressed to go "beep". But I'm not using a button-press to do this. How to simply produce a "beep" sound?
Thanks all!
-----------------------------------
ON EDIT:
I'm using FTN95, of course.
After fiddling with it for a while, I found that including <windows.ins> in the subroutine, and using the statement LB=BEEP("EXCLAMATION",J) where J is an integer and LB is a logical variable, it compiles without error and runs just fine... except I still don't hear any beeps when that statement is executed. (I put a PRINT statement right before it, and I can see the printed stuff just fine, so it's definitely executing this statement too).
Is there some place in the HELP files that explains how to use this function? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sat Nov 22, 2008 9:28 am Post subject: |
|
|
There is a "standard" callback with the name BEEP that is described in the help file but you cannot call it in the way that you mention.
It turns out that the documentation in this context is incorrect because MBOK should be OK instead.
There is a Windows API function in windows.ins in the form
LOGICAL L = MessageBeep(integer)
where "integer" is one of the constants MB_OK etc.
At the moment I cannot get either of the above to work on my machine so I will have to check further. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sat Nov 22, 2008 11:48 am Post subject: |
|
|
I still cannot get either of the above methods to work (both use MessageBeep) even though I have reset the sounds to the Windows default via the "Sounds and Audio Devices Properties" in the "Control Panel" (click on Start and the Control Panel).
However, the following function call works OK...
Code: | include <windows.ins>
logical L
L = Beep( 250, 175 )
|
The first argument is the sound frequency and the second is the duration in milliseconds. |
|
Back to top |
|
 |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Sat Nov 22, 2008 4:50 pm Post subject: |
|
|
Paul, BINGO!!! The simple version (freq and duration) worked perfectly. That's what I was looking for.
Thank you! |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Nov 24, 2008 2:00 pm Post subject: |
|
|
Here is another simple way to provide a sound...
Code: | include <windows.ins>
iret=play_sound_resource@("mysound")
end
RESOURCES
mysound SOUND "C:\\windows\\media\\Windows XP Logon Sound.wav"
|
There are a large number of standard sounds in the media folder. |
|
Back to top |
|
 |
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Mon Nov 24, 2008 2:14 pm Post subject: |
|
|
I simply use this:-
which I have used in my code since the days of DOS with FTN77 and is still part of FTN95. It does not require any include files or resources. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Nov 24, 2008 4:38 pm Post subject: |
|
|
Thanks for this.
BEEP@ is equivalent to Beep(frequency, duration) but with a fixed frequency and duration. The alternative gives you fancy wav sounds. |
|
Back to top |
|
 |
|