Jump to content

DosBeep (OS/2 1.x): Difference between revisions

From EDM2
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[image:legacy.png]]
{{Legacy
This is the legacy function. It is recommended to use: [[OS2 API:CPI:DosBeep|DosBeep]]
|RepFunc=[[DosBeep]]
 
|Remarks=The function described here was part of the OS2 1.x API. It had been updated for modern OS/2 development, it is available at [[DosBeep]].
==Description==
}}
This call generates sound from the speaker.
This call generates sound from the speaker.


==Syntax==
==Syntax==
<PRE>
  DosBeep (Frequency, Duration)
  DosBeep


    (Frequency, Duration)
</PRE>
==Parameters==
==Parameters==
; Frequency (USHORT) - input : Tone in Hertz (cycles per second) in the range 37 through 32767.  
;Frequency ([[USHORT]]) - input: Tone in Hertz (cycles per second) in the range 37 through 32767.
;Duration (USHORT) - input: Length of the sound in milliseconds.


; Duration (USHORT) - input : Length of the sound in milliseconds.
==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
*0 NO_ERROR
Return code descriptions are:
*395 ERROR_INVALID_FREQUENCY
 
* 0         NO_ERROR  
* 395       ERROR_INVALID_FREQUENCY  


==Remarks==
==Remarks==
DosBeep executes synchronously. An application program that invokes DosBeep waits until the specified number of milliseconds expire before it resumes execution.  
DosBeep executes synchronously. An application program that invokes DosBeep waits until the specified number of milliseconds expire before it resumes execution.


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSPROCESS
#define INCL_DOSPROCESS
Line 33: Line 27:
USHORT  rc = DosBeep(Frequency, Duration);
USHORT  rc = DosBeep(Frequency, Duration);


USHORT           Frequency;     /* Hertz (Hz) */
USHORT Frequency;   /* Hertz (Hz) */
USHORT           Duration;     /* Length of sound */
USHORT Duration;   /* Length of sound */


USHORT           rc;           /* return code */
USHORT rc;         /* return code */
</PRE>
</PRE>


This example generates a beep for 1 second (1,000 milliseconds) at a frequency of 1,380.
===MASM===
<PRE>
#define INCL_DOSPROCESS
 
#define BEEP_FREQUENCY 1380
#define BEEP_DURATION 1000
 
USHORT  rc;
 
  rc = DosBeep(BEEP_FREQUENCY,
                BEEP_DURATION);
</PRE>
===MASM Binding===
<PRE>
<PRE>
EXTRN  DosBeep:FAR
EXTRN  DosBeep:FAR
INCL_DOSPROCESS    EQU 1
INCL_DOSPROCESS    EQU 1


PUSH  WORD    Frequency     ;Frequency (in Hertz)
PUSH  WORD    Frequency   ;Frequency (in Hertz)
PUSH  WORD    Duration     ;Length of sound (in milliseconds)
PUSH  WORD    Duration   ;Length of sound (in milliseconds)
CALL  DosBeep
CALL  DosBeep


Returns WORD
Returns WORD
</PRE>
</PRE>
==Related Functions==
*


==Example Code==
This example generates a beep for 1 second (1,000 milliseconds) at a frequency of 1,380.
<PRE>
#define INCL_DOSPROCESS
#define BEEP_FREQUENCY 1380
#define BEEP_DURATION 1000
USHORT  rc;
rc = DosBeep(BEEP_FREQUENCY,
              BEEP_DURATION);
</PRE>


[[Category:The OS/2 API Project]]
[[Category:Dos16]]

Latest revision as of 17:45, 1 May 2023

Legacy Function Warning
It is recommended to use a newer replacement for this function.
Replacement: DosBeep
Remarks: The function described here was part of the OS2 1.x API. It had been updated for modern OS/2 development, it is available at DosBeep.

This call generates sound from the speaker.

Syntax

DosBeep (Frequency, Duration)

Parameters

Frequency (USHORT) - input
Tone in Hertz (cycles per second) in the range 37 through 32767.
Duration (USHORT) - input
Length of the sound in milliseconds.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 395 ERROR_INVALID_FREQUENCY

Remarks

DosBeep executes synchronously. An application program that invokes DosBeep waits until the specified number of milliseconds expire before it resumes execution.

Bindings

C

#define INCL_DOSPROCESS

USHORT  rc = DosBeep(Frequency, Duration);

USHORT  Frequency;   /* Hertz (Hz) */
USHORT  Duration;    /* Length of sound */

USHORT  rc;          /* return code */

MASM

EXTRN  DosBeep:FAR
INCL_DOSPROCESS     EQU 1

PUSH   WORD    Frequency   ;Frequency (in Hertz)
PUSH   WORD    Duration    ;Length of sound (in milliseconds)
CALL   DosBeep

Returns WORD

Example Code

This example generates a beep for 1 second (1,000 milliseconds) at a frequency of 1,380.

#define INCL_DOSPROCESS
#define BEEP_FREQUENCY 1380
#define BEEP_DURATION 1000

 USHORT  rc;

 rc = DosBeep(BEEP_FREQUENCY,
              BEEP_DURATION);