10.7. Sample Code and Board-side Component Preliminary Testing

10.7.1. Description of the Sample Code

User-Get Mode :

Advantage: SDK users can obtain and record the status of each audio frame, and users can perform operations such as drop / delay / copy at the application layer.

Disadvantages: SDK users need to open threads to do get/send actions at the application layer.

Bind Mode :

Advantages: SDK users only need to be responsible for fetching or broadcasting data after creating channel parameters.

Disadvantage: The application layer cannot deploy and observe the current state.

Uplink Audio (from microphone to encoding)

Reference source: cvi_sample_audio.c : SAMPLE_AUDIO_AiAenc

../_images/Sample002.png

The diagram above illustrates the User-Get Mode.

../_images/Sample003.png

The diagram above illustrates the Bind Mode.

Downlink Audio (from decoding to playback):

Reference source: cvi_sample_audio.c : SAMPLE_AUDIO_AdecAo

../_images/Sample004.png

The diagram above illustrates the User-Get Mode.

../_images/Sample005.png

The diagram above illustrates the Bind Mode.

10.7.2. Preliminary Testing of the Board-side Component

For different versions released with the project, it is important to provide audio version information to synchronize with application engineers.

After receiving the SDK software, users can use audio-related software to obtain version and board audio status information.

The implementation of the sample_audio executable program corresponds to the code in cvi_sample_audio.c.

During the initial customization of the board, users can perform dual-channel recording using the following method to confirm the audio waveform of the stored file, verify the correct input, and confirm that the speakers are functioning properly by directly playing back the dual-channel recording after recording.


[Checking Your Audio SDK Version]:

When running

sample_audio 7,

the console will display the following:

version [cviaudio_2021_tinyalsa0407A]

The information inside the square brackets [] indicates the audio version.


[Example Code for Recording]:

When running

sample_audio 19,

it corresponds to the code flow in case 19 of cvi_sample_audio.c.

The program prompts the user to enter recording parameters, and the user can simply press Enter to use the default values (as shown in the figure below).

When the console displays: ———————————>start recording…

Recording will begin for the specified number of seconds according to the user’s settings, and the audio will be saved as “sample_record.raw” on disk.

../_images/Sample007.png

[Example Code for Playback]:

When running

sample_audio 20 檔名.raw,

it corresponds to the code flow in case 20 of cvi_sample_audio.c.

The program prompts the user to enter playback parameters, and the user can simply press Enter to use the default values (as shown in the figure below).

When the console displays: ———————————>start playing… Playback will begin based on the user’s configuration and file name.

../_images/Sample006.png

The Audio Release SO file is a dynamic link library that contains the necessary libraries to ensure the completeness of the Audio SDK API.

Please ensure that the SDK released with your project includes the following libraries:

Name

unctionality

libcvi_audio.so

Audio API integration layer

libcvi_RES1.so

Audio resampling module

libcvi_VoiceEngine.so

Audio encoding/decoding module

libcvi_vqe.so

Audio algorithm integration layer

libssp.so

Audio SSP (including AEC) algorithm

libaec.so

Audio AEC algorithm

libtinyalsa.so

Audio recording and playback ALSA layer

libaacenc2.so

AAC encoding related - please contact FAE personnel for official documentation

libaacdec2.so

AAC decoding related - please contact FAE personnel for official documentation