Opus Example

Source code path: example/multimedia/audio/opus

Supported Platforms

  • eh-lb525

Overview

This example demonstrates how to use the Opus audio codec library for recording, encoding, decoding, and playback, including:

  • Record PCM audio data at a 16kHz sampling rate from the microphone via mic recording

  • Encoding: Compress PCM data using the Opus codec (10ms frame length, approximately 16kbps bitrate)

  • Decoding: Decompress audio data using the Opus decoder

  • Playback: Play the decoded audio data through the speakers

Example Usage

Hardware Requirements

Before running this example, prepare:

Routine Description

If the opus_test() function contains opus_encoder_ctl(encoder, OPUS_SET_FORCE_MODE(MODE_SILK_ONLY));then define OPUS_STACK_SIZE as 20k.

If the opus_test() function does not call opus_encoder_ctl(encoder, OPUS_SET_FORCE_MODE(MODE_SILK_ONLY));, then define `OPUS_STACK_SIZE` as 200k.

Compilation and Programming

Switch to the example project directory and run the scons command to execute compilation:

scons –board=eh-lb525 -j32

Switch to the example project/build_xx directory and run uart_download.bat, select the port as prompted for download:

./uart_download.bat

Uart Download

please input the serial port num:5

For detailed steps on compilation and download, please refer to Quick Start.

Expected Results of Example

After the example starts: Start recording for ten seconds, then automatically play back after recording is complete. Expected successful recording and automatic playback.

Exception Diagnosis

Reference Documents

Update History

Version

Date

Release Notes

0.0.1

10/2024

Initial version