Difference between revisions of "GAUDIO"

From uGFX Wiki
Jump to: navigation, search
(Play back)
Line 7: Line 7:
 
Before any audio can be played, the audio device has to be initialized using <code>gaudioPlayInit()</code>. Both, the sample format and the sample frequency are set by this function call.
 
Before any audio can be played, the audio device has to be initialized using <code>gaudioPlayInit()</code>. Both, the sample format and the sample frequency are set by this function call.
  
After initialization, <code>gaudioPlay()</code> can be used to output audio data. The function takes a pointer to a GDataBuffer that holds the audio data to play in the format that has been set by the initialization call.
+
After initialization, <code>gaudioPlay()</code> can be used to output audio data. The function takes a pointer to a <code>GDataBuffer</code> that holds the audio data to play in the format that has been set by the initialization call.
  
 
<code>gaudioPause()</code> can be used to pause any current audio output. Resuming after a pause is done calling <code>gaudioPlay()</code> without any sample buffer reference.
 
<code>gaudioPause()</code> can be used to pause any current audio output. Resuming after a pause is done calling <code>gaudioPlay()</code> without any sample buffer reference.
  
 
Calling <code>gaudioStop()</code> will completely stop a current audio playback.
 
Calling <code>gaudioStop()</code> will completely stop a current audio playback.
 +
 +
== Volume ==
 +
The playback volume can be adjusted using <code>gaudioSetVolume()</code>. However, not every driver might implement this feature. The function will return <code>FALSE</code> in that case.
 +
 +
For stereo devices, both channels are set to the same volume.
  
 
=== External decoder ===
 
=== External decoder ===

Revision as of 00:31, 4 July 2014

The GAUDIO module provides high level API for handling audio in- and output. The module provides built-in decoders but does also allow to use external codecs. See #External decoder.

API reference

The API reference of the GAUDIO module can be found here.

Play back

Before any audio can be played, the audio device has to be initialized using gaudioPlayInit(). Both, the sample format and the sample frequency are set by this function call.

After initialization, gaudioPlay() can be used to output audio data. The function takes a pointer to a GDataBuffer that holds the audio data to play in the format that has been set by the initialization call.

gaudioPause() can be used to pause any current audio output. Resuming after a pause is done calling gaudioPlay() without any sample buffer reference.

Calling gaudioStop() will completely stop a current audio playback.

Volume

The playback volume can be adjusted using gaudioSetVolume(). However, not every driver might implement this feature. The function will return FALSE in that case.

For stereo devices, both channels are set to the same volume.

External decoder

If your audio output devices does have an internal processor to decode audio formats, use GAUDIO_PLAY_FORMAT_FILE as the third parameter for gaudioPlayInit(). The GAUDIO module will simply pass the audio data unmodified to the audio device.

Example

ToDo

Record

ToDo