The Audio API handles audio interfaces including play and record supported formats.
A Legato device can use several audio interfaces. You choose the input and output interfaces to tie together. The Audio stream related to a particular interface is represented with an 'Audio Stream Reference'.
You can create your own audio path by connecting several audio streams together using audio connectors.
An audio path can support more than two audio interfaces. You can have a basic output audio path of a voice call to connect the Modem Voice Received interface with the Speaker interface, and at the same time, the Modem Voice Received interface can be also connected to a Recorder Device interface.
All the functions of this API are provided by the audioService.
Here's a code sample binding to audio services:
bindings: { clientExe.clientComponent.le_audio -> audioService.le_audio }
The audio profile can be set with the le_audio_SetProfile() function. The pre-configured profiles are defined with le_audio_Profile_t
enumeration type.
An audio profile can be retrieved with le_audio_GetProfile() and set with le_audio_SetProfile().
Then, the following functions let you enable or disable the audio settings on the selected audio interface:
To configure the encoding format, use le_audio_GetEncodingFormat() and le_audio_SetEncodingFormat().
To configure gain settings, use le_audio_GetGain() and le_audio_SetGain().
PCM has the following configuration get/set functions:
To Mute/Unmute the Call Waiting Tone to alert for an incoming voice call when a voice call is already in progress, use le_audio_MuteCallWaitingTone() and le_audio_UnmuteCallWaitingTone().
The following functions let you select the desired interface attributes:
Multiple users can own the same stream at the same time.
le_audio_GetDefaultPcmTimeSlot() can be called to get the default PCM time slot used on the current platform.
le_audio_GetDefaultI2sMode() can be called to get the default I2s channel mode slot used on the current platform.
Call le_audio_Close() to release it. If several users own the same, corresponding stream reference, the interface will close only after the last user releases the audio stream.
You can configure the PCM interface with the le_audio_SetPcmSamplingRate(), le_audio_SetPcmSamplingResolution() and le_audio_SetPcmCompanding() functions. This function must be called before activating an audio path with the PCM interface, in other words you must call this function before connecting the PCM Stream to a connector.
In addition, the le_audio_GetPcmSamplingRate(), le_audio_GetPcmSamplingResolution() and le_audio_GetPcmCompanding() functions allows you to retrieve the PCM interface configuration.
Once the users get an Audio Stream reference, they can control it with the following functions:
In the case your platform can support other gains in your audio subsystem, you can set or get the value of them with the following functions:
You can create your own audio path by connecting several audio streams together.
le_audio_CreateConnector() function creates a reference to an audio connector.
You can tie an audio stream to a connector by calling the le_audio_Connect() function.
You can remove an audio stream from a connector by calling the le_audio_Disconnect() function.
When finished with it, delete it using the le_audio_DeleteConnector() function.
A sample code that implements audio connectors and audio streams during voice call can be found in audioMccTest.c file (please refer to Sample code of audio settings for a dialing call page).
An audio file can be played to any active output interfaces.
Open a player interface by calling:
Audio file recording can be done from any active input interface.
Open a "File Recording" interface by calling:
A PCM configuration must be set with:
The PCM samples configuration can be retrieved with:
An AMR configuration must be set with:
To stop a play/record call le_audio_Stop():
You can also register a handler function for media-related notifications like errors or audio events.
le_audio_AddMediaHandler() function installs a handler for player/recorder stream notifications.
le_audio_RemoveMediaHandler() function removes the player/recorder handler function.
LE_AUDIO_MEDIA_NO_MORE_SAMPLES
event indicates when all samples put into the pipe by the user's app have been sent to the audio driver (see le_audio_PlaySamples()).A sample code that implements audio playback and capture can be found in audioPlaybackRec.c file (please refer to Sample code of audio playback and capture page).
The le_audio_PlayDtmf() function allows the application to play one or several DTMF on a playback stream. The duration and the pause of the DTMFs must also be specified with the input parameters.
The le_audio_PlaySignallingDtmf() function allows the application to ask the Mobile Network to generate on the remote audio party the DTMFs. Compared with le_audio_PlayDtmf(), le_audio_PlaySignallingDtmf() function may offer a better signal quality, but the the duration and the pause timings may be less accurate.
The application must register a handler function to detect incoming DTMF characters on a specific input audio stream. The le_audio_AddDtmfDetectorHandler() function installs a handler for DTMF detection.
The le_audio_RemoveDtmfDetectorHandler() function uninstalls the handler function.
The DTMFs are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, A, B, C, D. Not case sensitive.
A sample code that implements DTMF playback and decoding can be found in audioDtmfTest.c file (please refer to Sample code of dtmf playback and decoding page).
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.