> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_15b7eb99384c20f55db7776b7b1ecdad/dir_7d99a5752ef00d9a9478541a793df8d8/dir_b95d7ee73b2963b5e37f0a7269e7a4c6/sound_8h.md).

# sound.h

[Macros](#define-members) | [Typedefs](#typedef-members) | [Enumerations](#enum-members) | [Functions](#func-members)

`#include <stdio.h>`

Include dependency graph for sound.h:

![](/files/mNsXvzsZJQQuNc4RVuBz)

[Go to the source code of this file.](/adk-5.0-programmers-guide/sound_8h_source.md)

|         |                                               |
| ------- | --------------------------------------------- |
| Macros  |                                               |
| #define | [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) |

|                                                          |                                                                                                                                                                                         |
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Typedefs                                                 |                                                                                                                                                                                         |
| typedef struct [SND](#a520814ffd85c7975c652a3bb5500430b) | [SND](#a520814ffd85c7975c652a3bb5500430b)                                                                                                                                               |
| typedef void(\*                                          | [SNDCallback](#aca23cc022f7f576ca8a03fe66a6817bb)) (void \*data, struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle, enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) reason) |

|              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enumerations |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| enum         | <p><a href="#a2a29b5498b5650f52341ae534f4c7df6">SNDError</a> {<br>  <a href="#a2a29b5498b5650f52341ae534f4c7df6a390962805c51d9a4e0352bf1c8d132ca">SND\_OK</a> =0, <a href="#a2a29b5498b5650f52341ae534f4c7df6afbe239ff476359fdeb61cce0c1e338e9">SND\_ERR\_FAIL</a> =-1, <a href="#a2a29b5498b5650f52341ae534f4c7df6aa8e16de8f1eac179601f71c84fc7ba9d">SND\_ERR\_PARAMETER</a> =-2, <a href="#a2a29b5498b5650f52341ae534f4c7df6a25fdd8fb3ab4cb8b5568fd704ea555fb">SND\_ERR\_NOT\_FOUND</a> =-3,<br>  <a href="#a2a29b5498b5650f52341ae534f4c7df6a7dc852e6bc7d60988b4b3739a0b7fb9a">SND\_ERR\_MEMORY</a> =-4, <a href="#a2a29b5498b5650f52341ae534f4c7df6ad8373eee4fdfa8468b287934fdc27fa7">SND\_ERR\_UNSUPPORTED</a> =-5, <a href="#a2a29b5498b5650f52341ae534f4c7df6ae5da46480ef8e3e394ff06564a205e6e">SND\_ERR\_READ</a> =-6<br>}</p> |

|                                                                                                   |                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions                                                                                         |                                                                                                                                                                                     |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) struct [SND](#a520814ffd85c7975c652a3bb5500430b) \* | [sndOpenFile](#a2e0076124852060867cc4039c1719646) (const char \*filename)                                                                                                           |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) void                                                | [sndClose](#aac877336c270fa31b7396dd9e01a0ee5) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle)                                                                          |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) | [sndStart](#a6074c9bf1534c6e8e10ed0e3c72897cf) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle)                                                                          |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) | [sndStop](#a3fbd83f5f49d41b445b1e9dd8bc82c0f) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle)                                                                           |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) | [sndSeek](#a8f0945ea304cff2a5b223186b73087f7) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle, double pos, int whence)                                                   |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) double                                              | [sndTell](#a701ee6a24c4fcffacf3ec555c92caf97) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle)                                                                           |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) double                                              | [sndLength](#ae7e8fbfe734a79cf6648515fb7758f12) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle)                                                                         |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) void                                                | [sndSetCallback](#a7964d1213f6f330b9cf1a16dd4973826) (struct [SND](#a520814ffd85c7975c652a3bb5500430b) \*handle, [SNDCallback](#aca23cc022f7f576ca8a03fe66a6817bb) cb, void \*data) |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) int                                                 | [sndSoundSupport](#ae626fac0d0b7af4ce5a11d5d8103046f) ()                                                                                                                            |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) | [sndSetMasterVolume](#ab1ab90d8fa2ebcdbb451c03514e0a62d) (int volume\_percent)                                                                                                      |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) int                                                 | [sndGetMasterVolume](#ae5bb68c7fe1cb7040fe62b859485a9a8) (void)                                                                                                                     |
| [DllSpec](#ad7c2e1cb200073ed64c64285a5f37231) enum [SNDError](#a2a29b5498b5650f52341ae534f4c7df6) | [sndBeep](#a86a10d01a3b4ab379531f0a029455ade) (int frequency, int duration\_ms, int volume)                                                                                         |

### MacroDefinition Documentation <a href="#macro-definition-documentation" id="macro-definition-documentation"></a>

### DllSpec <a href="#ad7c2e1cb200073ed64c64285a5f37231" id="ad7c2e1cb200073ed64c64285a5f37231"></a>

\#define DllSpec

### TypedefDocumentation <a href="#typedef-documentation" id="typedef-documentation"></a>

### SND <a href="#a520814ffd85c7975c652a3bb5500430b" id="a520814ffd85c7975c652a3bb5500430b"></a>

typedef struct \[SND]\(#a520814ffd85c7975c652a3bb5500430b) \[SND]\(#a520814ffd85c7975c652a3bb5500430b)

SND handle identifying a sound file

### SNDCallback <a href="#aca23cc022f7f576ca8a03fe66a6817bb" id="aca23cc022f7f576ca8a03fe66a6817bb"></a>

typedef void(\\\* SNDCallback) (void \\\*data, struct \[SND]\(#a520814ffd85c7975c652a3bb5500430b) \\\*handle, enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) reason)

sound callback function

**Parameters**

\[in] **data** data pointer \[in] **handle** handle obtained by sndOpenFile() \[in] **reason** reason why the callback was invoked: At end of file, this is SND\_OK, in case of error it is the error code

### EnumerationType Documentation <a href="#enumeration-type-documentation" id="enumeration-type-documentation"></a>

### SNDError <a href="#a2a29b5498b5650f52341ae534f4c7df6" id="a2a29b5498b5650f52341ae534f4c7df6"></a>

enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6)

error codes

|                       |                                      |
| --------------------- | ------------------------------------ |
| Enumerator            |                                      |
| SND\_OK               | no error                             |
| SND\_ERR\_FAIL        | generic error                        |
| SND\_ERR\_PARAMETER   | invalid parameters                   |
| SND\_ERR\_NOT\_FOUND  | file not found or cannot be accessed |
| SND\_ERR\_MEMORY      | out of memory                        |
| SND\_ERR\_UNSUPPORTED | unsupported format                   |
| SND\_ERR\_READ        | read error                           |

### FunctionDocumentation <a href="#function-documentation" id="function-documentation"></a>

### sndBeep() <a href="#a86a10d01a3b4ab379531f0a029455ade" id="a86a10d01a3b4ab379531f0a029455ade"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) sndBeep

play a beep tone

**Parameters**

\[in] **frequency** frequency in Hz \[in] **duration\_ms** duration in milliseconds \[in] **volume** volume in % (0..100)

#### Returns

error code

{% hint style="info" %}
The beep is played synchronously.
{% endhint %}

### sndClose() <a href="#aac877336c270fa31b7396dd9e01a0ee5" id="aac877336c270fa31b7396dd9e01a0ee5"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) void sndClose

close the file opened using [sndOpenFile](#a2e0076124852060867cc4039c1719646)

**Parameters**

\[in] **handle** handle obtained by sndOpenFile()

### sndGetMasterVolume() <a href="#ae5bb68c7fe1cb7040fe62b859485a9a8" id="ae5bb68c7fe1cb7040fe62b859485a9a8"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) int sndGetMasterVolume

read master volume

#### Returns

volume in percent (range \[0..100]) or error code if less than 0.

### sndLength() <a href="#ae7e8fbfe734a79cf6648515fb7758f12" id="ae7e8fbfe734a79cf6648515fb7758f12"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) double sndLength

read the estimated length of the file

**Parameters**

\[in] **handle** handle obtained by sndOpenFile()

#### Returns

estimated length in seconds or error code if less than 0.

{% hint style="info" %}
The returned length is an estimate only, that can be obtained by reading the header of the file and may not represent the exact length. Obtaining the exact length may not be possible without scanning the whole file (e.g. for MP3).
{% endhint %}

### sndOpenFile() <a href="#a2e0076124852060867cc4039c1719646" id="a2e0076124852060867cc4039c1719646"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) struct \[SND]\(#a520814ffd85c7975c652a3bb5500430b)\\\* sndOpenFile

open file and return handle. Playback does not start automatically, use [sndStart()](#a6074c9bf1534c6e8e10ed0e3c72897cf) to start playing the file.

**Parameters**

\[in] **filename** file name of a sound file.

#### Returns

handle or NULL if the file cannot be found or the file format is not supported or if the sound device cannot be accessed.

### sndSeek() <a href="#a8f0945ea304cff2a5b223186b73087f7" id="a8f0945ea304cff2a5b223186b73087f7"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) sndSeek

change the current position

**Parameters**

\[in] **handle** handle obtained by sndOpenFile() \[in] **pos** position in seconds \[in] **whence** one of SEEK\_SET, SEEK\_CUR, SEEK\_END to specify whether the position pos is with respect to the file start, the current position or file end.

#### Returns

error code

### sndSetCallback() <a href="#a7964d1213f6f330b9cf1a16dd4973826" id="a7964d1213f6f330b9cf1a16dd4973826"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) void sndSetCallback

set callback that gets invoked when playback stops due to end of file or due to error.

**Parameters**

\[in] **handle** handle obtained by sndOpenFile() \[in] **cb** function pointer, use NULL to delete callback \[in] **data** data pointer that gets passed on to the callback

### sndSetMasterVolume() <a href="#ab1ab90d8fa2ebcdbb451c03514e0a62d" id="ab1ab90d8fa2ebcdbb451c03514e0a62d"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) sndSetMasterVolume

set master volume in percent

**Parameters**

\[in] **volume\_percent** volume in the range \[0..100] return error code

### sndSoundSupport() <a href="#ae626fac0d0b7af4ce5a11d5d8103046f" id="ae626fac0d0b7af4ce5a11d5d8103046f"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) int sndSoundSupport

check whether the device has sound support for playback of MP3 or WAV files

#### Returns

1 if sound support is present, else 0

### sndStart() <a href="#a6074c9bf1534c6e8e10ed0e3c72897cf" id="a6074c9bf1534c6e8e10ed0e3c72897cf"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) sndStart

start playback. Playback starts at the current position.

**Parameters**

\[in] **handle** handle obtained by sndOpenFile()

#### Returns

error code

### sndStop() <a href="#a3fbd83f5f49d41b445b1e9dd8bc82c0f" id="a3fbd83f5f49d41b445b1e9dd8bc82c0f"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) enum \[SNDError]\(#a2a29b5498b5650f52341ae534f4c7df6) sndStop

stop playback. Stopping does not reset the current position, i.e. invoking [sndStart()](#a6074c9bf1534c6e8e10ed0e3c72897cf) after [sndStop()](#a3fbd83f5f49d41b445b1e9dd8bc82c0f) resumes playback at the position when [sndStop()](#a3fbd83f5f49d41b445b1e9dd8bc82c0f) was invoked.

**Parameters**

\[in] **handle** handle obtained by sndOpenFile()

#### Returns

error code

### sndTell() <a href="#a701ee6a24c4fcffacf3ec555c92caf97" id="a701ee6a24c4fcffacf3ec555c92caf97"></a>

\[DllSpec]\(#ad7c2e1cb200073ed64c64285a5f37231) double sndTell

read the current position

**Parameters**

\[in] **handle** handle obtained by sndOpenFile()

#### Returns

position in seconds from the file start or error code if less than 0.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_15b7eb99384c20f55db7776b7b1ecdad/dir_7d99a5752ef00d9a9478541a793df8d8/dir_b95d7ee73b2963b5e37f0a7269e7a4c6/sound_8h.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
