ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Miscellaneous WINDEV functions
  • Stopping a non-locking sound
  • Size of sound files
  • Locking sound
  • Sound and component
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Sound (Function)
In french: Son
Plays a sound in WAV format. This sound can be:
  • stored on the disk.
  • included in the library (.WDL).
  • in an HFSQL memo.
This function can also be used to:
  • WINDEVReports and QueriesWindowsUser code (UMC) play a system sound.
  • WINDEVWindows play a sound of a given frequency for the desired time.
Remark: A sound card must be installed on the workstation.. The sound will be played according to the Windows settings (volume, balance, quality, etc.).
Example
WINDEVReports and QueriesUser code (UMC)
// Plays the sound found in the "TADA.WAV" file
Sound("Tada.wav")
// Plays while locking on sound card
Sound("tada.wav", soundWait)
// Plays while looping on sound card
Sound("C:\MSOFFICE\Sounds\Car.wav", soundLoop)
AndroidAndroid Widget
// Play the music.mp3 file included in the application
Sound("music.mp3")
WINDEVWindows
// Plays a sound of a given frequency
LOOP (10)
FOR nIndex = 1 TO 5536 STEP 100
Sound(nIndex, 1)
END
FOR nIndex = 5536 TO 1 STEP -100
Sound(nIndex, 1)
END
END
Syntax

Playing a .WAV file Hide the details

Sound(<Name of WAV file> [, <Option>])
<Name of WAV file>: Character string
Full or relative name of file to play. This file can be:
  • WINDEV a WAV file.
  • Android an audio file corresponding to all the formats supported by the OS (wav, mp3, 3gp, ogg, etc.). A summary of the supported audio files is available from the following address: http://developer.android.com/guide/appendix/media-formats.html.
    Remarks:
    • Android does not support 32-bit wav files.
    • This parameter can correspond to a URL. In this case, it is necessary to add the INTERNET permission when generating the application.
  • iPhone/iPad a file in wav format.
Remarks:
  • AndroidAndroid Widget The audio file to play can also be included in the application via the generation wizard. To play it, simply specify the file name (name + extension).
  • AndroidAndroid Widget iPhone/iPad WAV files in HFSQL memo items cannot be played.
<Option>: Optional integer constant
Sound execution mode:
soundDefault
(Default value)
The code continues to run as soon as the sound is started.
soundLoopThe sound is played in a loop.
Note: The file to be played must be on disk, not in the library (WDL file)..
soundWaitThe code is locked as long as the sound is not entirely played.
WINDEVReports and QueriesUser code (UMC)

Playing a system sound Hide the details

Sound(<System sound>)
<System sound>: Constant
Preset system sound to play:
soundSystemAsteriskAsterisk system sound.
soundSystemClosingSystem sound for closing Windows.
soundSystemCriticalStopSystem sound corresponding to the critical shutdown of the system.
soundSystemDefaultDefault system sound (beep in most cases).
soundSystemExclamationExclamation system sound.
soundSystemQuestionQuestion system sound.
WINDEVReports and QueriesUser code (UMC)

Playing a sound of a given frequency during the requested time Hide the details

<Result> = Sound(<Frequency> , <Duration>)
<Result>: Boolean
  • True if the sound was played,
  • False otherwise.
Note: Up to Windows 7, sound is played through the PC's internal speaker.. From Windows 7, the sound is played on the sound card.
<Frequency>: Unsigned integer
Frequency of the sound in Hertz.
Note: For versions below Windows 7, only audible frequencies can be used (between 37 and 32767).
<Duration>: Unsigned integer
Duration (in milliseconds) during which the sound is played. Warning: the sound is blocking. This parameter can correspond to:
  • an integer representing the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
Remarks

Stopping a non-locking sound

A sound played in non-locking mode can be stopped by the following code, called on a user action for example (click, control modification, etc.):
Sound("")

Size of sound files

Using large WAV files may trigger several problems (not enough RAM to load the sound, system stopped depending on the Windows version, etc.). For large ".WAV" files (several dozen megabytes), we recommend that you use the MCI functions.

Locking sound

A sound is necessarily locking:
  • If the sound is stored in a WINDEV library (.WDL file).
  • If the sound comes from a binary memo.

Sound and component

Sound is a non-blocking function by default. To use Sound in a component without locking the application, you must comply with the following constraints:
  • The file corresponding to the sound must not be found in the WDL or in the component.
  • The file corresponding to the sound must be found in the EXE directory of the application.
Business / UI classification: UI Code
Component: wd300obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/30/2024

Send a report | Local help