├── .clang-ignore ├── .github └── workflows │ ├── RunBuildTest.yml │ ├── RunBuildTestBoard.yml │ ├── RunBuildTestNXP.yml │ └── UpdateDockerImage.yml ├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── COPYING-BSD-3 ├── ChangeLogKSDK.txt ├── Kconfig ├── LICENSE.txt ├── README.md ├── SW-Content-Register.txt ├── audio_examples.cmake ├── components.cmake ├── components ├── decoders │ ├── aac │ │ ├── aac_extractmetadata.c │ │ ├── aac_metadata.h │ │ └── aac_utility.c │ ├── flac │ │ └── flac_extractmetadata.c │ ├── mp3 │ │ ├── mp3_extractmetadata.c │ │ ├── mp3_id3v2.c │ │ ├── mp3_id3v2.h │ │ ├── mp3_id3v2_internal.h │ │ ├── mp3_metadata.h │ │ └── mp3_vbr.c │ ├── opus │ │ └── opus_extractmetadata.c │ └── wav │ │ ├── adpcm_extractmetadata.c │ │ ├── wav_common.c │ │ ├── wav_metadata.h │ │ ├── wavedata.h │ │ └── wavedefs.h └── encoders │ └── opus │ ├── opusenc_cei.c │ └── opusenc_cei.h ├── dockerfiles └── Dockerfile ├── doxygen ├── .gitignore ├── CeiEncoder.md ├── Doxyfile_RM ├── Makefile ├── ProgrammersGuide.md ├── common │ ├── arm_logo.png │ ├── codec_flow.png │ ├── communication.svg │ ├── customdoxygen.css │ ├── elements.svg │ ├── fs_logo.gif │ ├── fs_logo.svg │ ├── maestro.svg │ ├── maestroApp.svg │ ├── nxp_logo_small.png │ ├── pads.svg │ ├── processtime │ │ ├── mic_speaker.svg │ │ ├── mic_speaker_1ch_elements_without_fileread.svg │ │ ├── mic_speaker_2ch_elements_without_fileread.svg │ │ ├── mic_vit.svg │ │ ├── mic_vit_elements.svg │ │ ├── mic_vs_vit.svg │ │ ├── mic_vs_vit_elements.svg │ │ ├── mp3_44kHz_with_fileread.svg │ │ ├── mp3_44kHz_without_fileread.svg │ │ ├── mp3_48kHz_with_fileread.svg │ │ ├── mp3_48kHz_without_fileread.svg │ │ ├── playback.svg │ │ ├── playback_streamer2.svg │ │ ├── record.svg │ │ ├── record_streamer2.svg │ │ ├── wav_44kHz.svg │ │ └── wav_48kHz.svg │ ├── template │ │ ├── contact.tex │ │ ├── copyright_attribution.tex │ │ ├── doxygen_def.sty │ │ ├── footer_def.tex │ │ └── header_def.tex │ └── trademarks │ │ ├── new_footer-2.html │ │ ├── new_header.html │ │ └── new_stylesheet.css ├── maestro_playback.md ├── maestro_record.md ├── maestro_sync.md ├── maestro_usb_mic.md ├── maestro_usb_speaker.md ├── processing_time.md ├── supported_features.md └── test_48khz_16bit_2ch.wav ├── elements.cmake ├── src ├── cci │ ├── inc │ │ ├── cci_metadata.h │ │ ├── ccidec.h │ │ ├── codec_interface.h │ │ ├── codec_interface_public_api.h │ │ └── errordefs.h │ └── src │ │ ├── ccidec.c │ │ ├── codec_interface.c │ │ └── codecextractmetadata.c ├── cei │ └── inc │ │ ├── cei.h │ │ ├── cei_enctypes.h │ │ └── cei_table.h ├── core │ ├── inc │ │ ├── pad.h │ │ ├── pipeline.h │ │ ├── streamer.h │ │ └── streamer_element.h │ └── src │ │ ├── pad.c │ │ ├── pipeline.c │ │ ├── streamer.c │ │ ├── streamer_element.c │ │ └── streamer_msg.c ├── devices │ ├── audio_sink_default.c │ ├── audio_sink_default.h │ ├── audio_src_default.c │ └── audio_src_default.h ├── elements │ ├── audio_proc.c │ ├── audio_proc.h │ ├── audio_sink.c │ ├── audio_sink.h │ ├── audio_src.c │ ├── audio_src.h │ ├── decoder.c │ ├── decoder.h │ ├── decoder_pads.c │ ├── decoder_pads.h │ ├── encoder.c │ ├── encoder.h │ ├── file_sink.c │ ├── file_sink.h │ ├── file_src.c │ ├── file_src.h │ ├── mem_sink.c │ ├── mem_sink.h │ ├── mem_src.c │ ├── mem_src.h │ ├── netbuf_src.c │ ├── netbuf_src.h │ ├── process_sink.c │ └── process_sink.h ├── inc │ ├── audio_cfg.h │ ├── error.h │ ├── streamer_api.h │ ├── streamer_element_properties.h │ ├── streamer_message.h │ └── types.h ├── parsers │ └── cci │ │ └── cci_codec_type_conversion.c └── utils │ ├── inc │ ├── file_utils.h │ ├── general_utils.h │ ├── maestro_logging.h │ └── ringbuffer.h │ └── src │ ├── file_utils.c │ ├── general_utils.c │ ├── maestro_logging.c │ └── ringbuffer.c ├── west-freestanding.yml ├── west.yml └── zephyr ├── CMakeLists.txt ├── Kconfig ├── README.rst ├── audioTracks ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.flac.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.m4a.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.mp3.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.opus_ogg.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.opus_ogg_raw.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.raw ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.raw.h ├── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.wav └── Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.wav.h ├── doc ├── Makefile ├── conf.py ├── doc │ ├── .buildinfo │ ├── .doctrees │ │ ├── README.doctree │ │ ├── environment.pickle │ │ ├── samples │ │ │ ├── record_ram │ │ │ │ └── README.doctree │ │ │ └── record_vit │ │ │ │ └── README.doctree │ │ └── tests │ │ │ ├── decoder │ │ │ └── README.doctree │ │ │ ├── encoder │ │ │ └── README.doctree │ │ │ └── memToMem │ │ │ └── README.doctree │ ├── README.html │ ├── _sources │ │ ├── README.rst.txt │ │ ├── samples │ │ │ ├── record_ram │ │ │ │ └── README.rst.txt │ │ │ └── record_vit │ │ │ │ └── README.rst.txt │ │ └── tests │ │ │ ├── decoder │ │ │ └── README.rst.txt │ │ │ ├── encoder │ │ │ └── README.rst.txt │ │ │ └── memToMem │ │ │ └── README.rst.txt │ ├── _static │ │ ├── alabaster.css │ │ ├── basic.css │ │ ├── custom.css │ │ ├── doctools.js │ │ ├── documentation_options.js │ │ ├── file.png │ │ ├── github-banner.svg │ │ ├── language_data.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ └── sphinx_highlight.js │ ├── genindex.html │ ├── objects.inv │ ├── samples │ │ ├── record_ram │ │ │ └── README.html │ │ └── record_vit │ │ │ └── README.html │ ├── search.html │ ├── searchindex.js │ └── tests │ │ ├── decoder │ │ └── README.html │ │ ├── encoder │ │ └── README.html │ │ └── memToMem │ │ └── README.html └── make.bat ├── module.yml ├── samples ├── record_ram │ ├── CMakeLists.txt │ ├── Kconfig │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ │ ├── app_streamer_element_pcm.c │ │ ├── app_streamer_element_pcm.h │ │ └── main.c └── record_vit │ ├── CMakeLists.txt │ ├── Kconfig │ ├── README.rst │ ├── prj.conf │ ├── sample.yaml │ └── src │ ├── app_streamer_element_pcm.c │ ├── app_streamer_element_pcm.h │ ├── app_streamer_element_vit.c │ ├── app_streamer_element_vit.h │ └── main.c ├── tests ├── decoder │ ├── CMakeLists.txt │ ├── Kconfig │ ├── README.rst │ ├── prj.conf │ ├── src │ │ ├── decoder.code-workspace │ │ └── main.c │ └── testcase.yaml ├── encoder │ ├── CMakeLists.txt │ ├── Kconfig │ ├── README.rst │ ├── prj.conf │ ├── src │ │ └── main.c │ └── testcase.yaml └── memToMem │ ├── CMakeLists.txt │ ├── Kconfig │ ├── README.rst │ ├── prj.conf │ ├── src │ └── main.c │ └── testcase.yaml └── wrappers └── fsl_debug_console.h /.clang-ignore: -------------------------------------------------------------------------------- 1 | config/.* 2 | coverity/.* 3 | docs/.* 4 | doxygen/.* 5 | libs/.* 6 | mcu-audio/.* 7 | mk/.* 8 | 9 | FreeRTOSConfig.h 10 | FreeRTOSConfigBoard.h 11 | ffconf.h 12 | pin_mux.c 13 | pin_mux.h 14 | -------------------------------------------------------------------------------- /.github/workflows/RunBuildTest.yml: -------------------------------------------------------------------------------- 1 | # Simple build test in docker environment 2 | name: Build test 3 | run-name: Build test run by @${{ github.actor }} 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | workflow_run: 13 | workflows: ["Docker image update"] 14 | branches: 15 | - 'main' 16 | 17 | workflow_dispatch: 18 | inputs: 19 | platform: 20 | description: 'Platform to run tests for' 21 | required: false 22 | default: 'rd_rw612_bga' 23 | type: string 24 | logLevel: 25 | description: 'Log level' 26 | required: true 27 | default: 'warning' 28 | type: choice 29 | options: 30 | - info 31 | - warning 32 | - debug 33 | 34 | jobs: 35 | build: 36 | runs-on: ubuntu-latest 37 | container: 38 | image: ghcr.io/radimli/maestro_test:main 39 | volumes: 40 | # TODO: Copy into the container instead? 41 | - ${{ github.workspace }}:/app/maestro 42 | #username: ${{ github.actor }} 43 | #password: ${{ secrets.PRIVATE_ACCESS_TOKEN }} 44 | 45 | steps: 46 | - name: Checkout 47 | uses: actions/checkout@v4 48 | 49 | - name: Initialize west 50 | run: | 51 | cd /app/maestro 52 | west init -l . --mf west-freestanding.yml 53 | west update 54 | 55 | - name: Execute build tests 56 | run: | 57 | cd /app/maestro/zephyr 58 | west twister --verbose --verbose --verbose --platform rd_rw612_bga --integration --build-only --testsuite-root . | tee /app/buildLog.txt 59 | 60 | - name: Upload artefacts 61 | uses: actions/upload-artifact@v4.4.3 62 | with: 63 | path: | 64 | /app/maestro/zephyr/twister-out/*.json 65 | /app/maestro/zephyr/twister-out/*.xml 66 | /app/buildLog.txt 67 | -------------------------------------------------------------------------------- /.github/workflows/RunBuildTestBoard.yml: -------------------------------------------------------------------------------- 1 | # Simple build test in docker environment 2 | name: Build test for specific board 3 | run-name: Build test for a board run by @${{ github.actor }} 4 | 5 | on: 6 | workflow_dispatch: 7 | inputs: 8 | platform: 9 | description: 'Platform to run tests for' 10 | required: true 11 | default: 'rd_rw612_bga' 12 | type: string 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | container: 18 | image: ghcr.io/radimli/maestro_test:main 19 | volumes: 20 | # TODO: Copy into the container instead? 21 | - ${{ github.workspace }}:/app/maestro 22 | #username: ${{ github.actor }} 23 | #password: ${{ secrets.PRIVATE_ACCESS_TOKEN }} 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v4 28 | 29 | - name: Initialize west 30 | run: | 31 | cd /app/maestro 32 | west init -l . --mf west-freestanding.yml 33 | west update 34 | 35 | - name: Execute build tests 36 | run: | 37 | cd /app/maestro/zephyr 38 | west twister --verbose --verbose --verbose --platform ${{ inputs.platform }} --build-only --testsuite-root ../ | tee /app/buildLog.txt 39 | 40 | - name: Upload artefacts 41 | uses: actions/upload-artifact@v4.4.3 42 | with: 43 | path: | 44 | /app/maestro/zephyr/twister-out/*.json 45 | /app/maestro/zephyr/twister-out/*.xml 46 | /app/buildLog.txt 47 | -------------------------------------------------------------------------------- /.github/workflows/RunBuildTestNXP.yml: -------------------------------------------------------------------------------- 1 | # Simple build test in docker environment 2 | name: Build test for NXP 3 | run-name: Build test for NXP run by @${{ github.actor }} 4 | 5 | on: workflow_dispatch 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | container: 11 | image: ghcr.io/radimli/maestro_test:main 12 | volumes: 13 | # TODO: Copy into the container instead? 14 | - ${{ github.workspace }}:/app/maestro 15 | #username: ${{ github.actor }} 16 | #password: ${{ secrets.PRIVATE_ACCESS_TOKEN }} 17 | 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v4 21 | 22 | - name: Initialize west 23 | run: | 24 | cd /app/maestro 25 | west init -l . --mf west-freestanding.yml 26 | west update 27 | 28 | - name: Execute build tests 29 | run: | 30 | cd /app/maestro/zephyr 31 | west twister --verbose --verbose --verbose --vendor=nxp --build-only --testsuite-root ./ | tee /app/buildLog.txt 32 | 33 | - name: Upload artefacts 34 | uses: actions/upload-artifact@v4.4.3 35 | with: 36 | path: | 37 | /app/maestro/zephyr/twister-out/*.json 38 | /app/maestro/zephyr/twister-out/*.xml 39 | /app/buildLog.txt 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/UpdateDockerImage.yml: -------------------------------------------------------------------------------- 1 | # Based on: https://github.com/Delgan/qml-format/blob/a57ccf9991ca3e210d2ec3c97156c5fb4bb66227/LICENSE 2 | name: Docker image update 3 | run-name: Docker image update run by @${{ github.actor }} 4 | 5 | on: 6 | push: 7 | paths: 8 | - '.github/workflows/BuildDockerImage.yml' 9 | 10 | schedule: 11 | - cron: '0 6 * * 0' 12 | 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | env: 26 | REGISTRY: ghcr.io 27 | IMAGE_NAME: ${{ github.repository }} 28 | 29 | jobs: 30 | build_and_push_docker_image: 31 | runs-on: ubuntu-latest 32 | permissions: 33 | contents: read 34 | packages: write 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v3 39 | 40 | - name: Log in to the Container registry 41 | uses: docker/login-action@v3.3.0 42 | with: 43 | registry: ${{ env.REGISTRY }} 44 | username: ${{ github.actor }} 45 | password: ${{ secrets.GH_REGISTRY_WRITE }} 46 | 47 | - name: Extract metadata for Docker 48 | id: meta 49 | uses: docker/metadata-action@v5.6.1 50 | with: 51 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 52 | 53 | - name: Build and push Docker image 54 | uses: docker/build-push-action@v6.10.0 55 | with: 56 | context: . 57 | file: dockerfiles/Dockerfile 58 | push: true 59 | tags: ${{ steps.meta.outputs.tags }} 60 | labels: ${{ steps.meta.outputs.labels }} 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.d 3 | *.o 4 | *.swp 5 | .DS_Store 6 | *.xml 7 | *.json 8 | 9 | twister-out*/ 10 | components/ 11 | armgcc 12 | iar 13 | 14 | __repo__ 15 | .vscode 16 | build 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Maestro Audio Framework changelog 2 | ## 2.0.0 (newest) 3 | - Added Zephyr port, see [Zephyr README](zephyr/README.rst). 4 | - Possible to use standalone version, pulling its own Zephyr and dependencies 5 | - Possible to import it as a module in your Zephyr project 6 | - Changed build system - newly uses Kconfig and Cmake 7 | - Supports NXP MCUXSDK (previously 2.x) 8 | - Changed folder structure and names to improve readability (description may be found in [README](README.md)) 9 | - Removed audio libraries and placed into audio-voice-components repository 10 | - Added libraries are pulled into the build via Kconfig and Cmake 11 | - Changed Maestro library core - minor changes 12 | 13 | ## 1.8.0 14 | - New platforms support: MCX-N5XX-EVK, FRDMMCXN236 and RD-RW612-BGA 15 | - Fixed compilation warnings 16 | - Documentation improvements and updates 17 | - Added section with processing time information 18 | - Added application state diagrams 19 | - Various updates and fixes 20 | ## 1.7.0 21 | - Removed EAP support for future SDK releases 22 | - Created new API for audio_sink and audio_src to support USB source, sink 23 | - ASRC library integrated 24 | - License changed to BSD 3-Clause 25 | - Improved pipeline creation API 26 | - Fixed compilation warnings in Opus 27 | - Various other improvements and bug fixes 28 | ## 1.6.0 29 | - Up to 2 parallel pipelines supported 30 | - Synchronous Sample Rate Converter support Added 31 | - Various improvements and bug fixes 32 | ## 1.5.0 33 | - Enabled switching from 2 to 4 channel output during processing 34 | - PadReturn type has been replaced by FlowReturn 35 | - Support of AAC, WAV, FLAC decoders 36 | - Renamed eap element to audio_proc element 37 | - Added audio_proc to VIT pipeline to support VoiceSeeker 38 | - Minor bug fixes 39 | ## 1.4.0 40 | - Use Opusfile lib for Ogg Opus decoder 41 | - Refactor code, fix issues found in unit tests 42 | - Various bug fixes 43 | ## 1.3.0 44 | - Make Maestro framework open source (except mp3 and wav decoder) 45 | - Refactor code, remove unused parts, add comments 46 | ## 1.2.0 47 | - Unified buffering in audio source, audio sink 48 | - Various improvements and bug fixes 49 | ## 1.0_rev0 50 | - Initial version of framework with support for Cortex-M7 platforms 51 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro) 5 | mcux_add_include( 6 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/src 7 | INCLUDES inc 8 | core/inc 9 | utils/inc 10 | elements 11 | devices 12 | ) 13 | 14 | mcux_add_source( 15 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/src 16 | SOURCES inc/*.h 17 | core/inc/*.h 18 | core/src/*.c 19 | utils/inc/general_utils.h 20 | utils/inc/maestro_logging.h 21 | utils/src/general_utils.c 22 | utils/src/maestro_logging.c 23 | ) 24 | endif() 25 | 26 | include(${SdkRootDirPath}/middleware/audio_voice/maestro/components.cmake OPTIONAL) 27 | include(${SdkRootDirPath}/middleware/audio_voice/maestro/configs.cmake OPTIONAL) 28 | include(${SdkRootDirPath}/middleware/audio_voice/maestro/elements.cmake OPTIONAL) 29 | include(${SdkRootDirPath}/middleware/audio_voice/maestro/audio_examples.cmake OPTIONAL) 30 | -------------------------------------------------------------------------------- /COPYING-BSD-3: -------------------------------------------------------------------------------- 1 | The BSD 3 Clause License 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 | SOFTWARE. 34 | -------------------------------------------------------------------------------- /ChangeLogKSDK.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | @page middleware_log Middleware Change Log 3 | 4 | @section maestro Maestro Audio Framework for MCUXpresso SDK 5 | The currently supported version is 1.8.0 6 | - 1.8.0 7 | - New platforms support: MCX-N5XX-EVK, FRDMMCXN236 and RD-RW612-BGA 8 | - Fixed compilation warnings 9 | - Documentation improvements and updates 10 | - Added section with processing time information 11 | - Added application state diagrams 12 | - Various updates and fixes 13 | - 1.7.0 14 | - Removed EAP support for future SDK releases 15 | - Created new API for audio_sink and audio_src to support USB source, sink 16 | - ASRC library integrated 17 | - License changed to BSD 3-Clause 18 | - Improved pipeline creation API 19 | - Fixed compilation warnings in Opus 20 | - Various other improvements and bug fixes 21 | - 1.6.0 22 | - Up to 2 parallel pipelines supported 23 | - Synchronous Sample Rate Converter support Added 24 | - Various improvements and bug fixes 25 | - 1.5.0 26 | - Enabled switching from 2 to 4 channel output during processing 27 | - PadReturn type has been replaced by FlowReturn 28 | - Support of AAC, WAV, FLAC decoders 29 | - Renamed eap element to audio_proc element 30 | - Added audio_proc to VIT pipeline to support VoiceSeeker 31 | - Minor bug fixes 32 | - 1.4.0 33 | - Use Opusfile lib for Ogg Opus decoder 34 | - Refactor code, fix issues found in unit tests 35 | - Various bug fixes 36 | - 1.3.0 37 | - Make Maestro framework open source (except mp3 and wav decoder) 38 | - Refactor code, remove unused parts, add comments 39 | - 1.2.0 40 | - Unified buffering in audio source, audio sink 41 | - Various improvements and bug fixes 42 | - 1.0_rev0 43 | - Initial version of framework with support for Cortex-M7 platforms 44 | 45 | */ 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Maestro audio framework 2 | 3 | ## Introduction 4 | 5 | Maestro audio framework intends to enable chaining of basic audio processing blocks, called *elements*. These blocks then form stream processing objects, called *pipeline*. 6 | This pipeline can be used for multiple audio processing use cases. 7 | 8 | The processing blocks can include (but are not limited to) different audio sources (for example file or microphone), decoders or encoders, filters or effects, and audio sinks. Framework overview is depicted in the following picture: 9 | 10 | ![maestro overview](doxygen/common/maestroApp.svg) 11 | 12 | \*not all elements and libraries are supported in Zephyr port. For more information, see [Maestro on Zephyr](zephyr/README.rst) 13 | 14 | The Maestro audio framework is an open-source component developed by NXP Semiconductors and released under the BSD-compatible license. It is running on RTOS (Zephyr or FreeRTOS), abstracted by OSA layer. 15 | 16 | For detailed description of the audio Maestro framework, please refer to the [programmer's guide](doxygen/ProgrammersGuide.md). 17 | 18 | To see what is new, see [changelog](CHANGELOG.md). 19 | 20 | ## Maestro on Zephyr 21 | 22 | Getting started guide and further information for Maestro on Zephyr may be found [here](zephyr/README.rst). 23 | 24 | ## Maestro on FreeRTOS 25 | 26 | Maestro on FreeRTOS is supported in NXP's SDK. To get started, see [mcuxsdk doc](https://mcuxpresso.nxp.com/mcuxsdk/latest/html/index.html). 27 | 28 | ### Supported examples 29 | 30 | The current version of the Maestro audio framework supports several optional [features](doxygen/supported_features.md), some of which are used in these examples: 31 | 32 | - [maestro_playback](doxygen/maestro_playback.md) 33 | - [maestro_record](doxygen/maestro_record.md) 34 | - [maestro_usb_mic](doxygen/maestro_usb_mic.md) 35 | - [maestro_usb_speaker](doxygen/maestro_usb_speaker.md) 36 | - [maestro_sync](doxygen/maestro_sync.md) 37 | 38 | The examples can be found in the **audio_examples** folder of the desired board. The demo applications are based on FreeRTOS and use multiple tasks to form the application functionality. 39 | 40 | ### Example applications overview 41 | 42 | To set up the audio framework properly, it is necessary to create a streamer with `streamer_create` API. It is also essential to set up the desired hardware peripherals using the functions described in `streamer_pcm.h`. 43 | The Maestro example projects consist of several files regarding the audio framework. The initial file is `main.c` with code to create multiple tasks. 44 | For features including SD card (in the maestro_playback examples, reading a file from SD card is supported and in maestro_record writing to SD card is currently supported) the `APP_SDCARD_Task` is created. 45 | The command prompt and connected functionalities are handled by `APP_Shell_Task`. 46 | 47 | One of the most important parts of the configuration is the `streamer_pcm.c` where the initialization of the hardware peripherals, input and output buffer management can be found. For further information please see also `streamer_pcm.h` 48 | 49 | In the Maestro USB examples (maestro_usb_mic and maestro_usb_speaker), the USB configuration is located in the `usb_device_descriptor.c`, `audio_microphone.c` and `audio_speaker.c` files. For further information please see also `usb_device_descriptor.h`, `audio_microphone.h` and `audio_speaker.h`. 50 | 51 | In order to be able to get the messages from the audio framework, it is necessary to create a thread for receiving the messages from the streamer, which is usually called a `Message Task`. 52 | The message thread is placed in the `app_streamer.c` file, reads the streamer message queue, and reacts to the following messages: 53 | 54 | - STREAM_MSG_ERROR - stops the streamer and exits the message thread 55 | - STREAM_MSG_EOS - stops the streamer and exits the message thread 56 | - STREAM_MSG_UPDATE_DURATION - prints info about the stream duration 57 | - STREAM_MSG_UPDATE_POSITION - prints info about current stream position 58 | - STREAM_MSG_CLOSE_TASK - exits the message thread 59 | 60 | ## File structure 61 | 62 | | Folder | Description | 63 | |:---|:---| 64 | | src | Maestro audio framework sources | 65 | | src/inc | Maestro include files | 66 | | src/core | Maestro core sources | 67 | | src/cci | Common decoder interface sources | 68 | | src/cei | Common encoder interface sources | 69 | | src/elements | Maestro elements sources | 70 | | src/devices | External audio devices implementation (audio source & audio sink elements) | 71 | | src/utils | Helper utilities utilized by Maestro | 72 | | docs | Generated documentation | 73 | | doxygen | Documentation sources | 74 | | components | Glue for audio libraries, so they can be used in elements | 75 | | tests | Maestro tests | 76 | | zephyr/ | Zephyr related files | 77 | | zephyr/samples/ | Zephyr samples | 78 | | zephyr/tests/ | Zephyr tests | 79 | | zephyr/audioTracks/ | Audio tracks for testing | 80 | | zephyr/wrappers/ | Zephyr NXP SDK Wrappers | 81 | | zephyr/doc/ | Zephyr documentation configuration for Sphinx | 82 | | zephyr/scripts/ | Zephyr helper scripts, mostly for testing | 83 | 84 | ## Contribution to the Maestro project 85 | 86 | We welcome and encourage the community to submit patches directly to the Maestro project placed on github. 87 | Contributing can be managed via pull-requests. 88 | -------------------------------------------------------------------------------- /SW-Content-Register.txt: -------------------------------------------------------------------------------- 1 | maestro Name: Maestro Audio Framework 2 | Version: 1.7.0 3 | Outgoing License: LA_OPT_NXP_Software_License.txt September 2023 - Additional distribution license - License in Section 2.3 applies 4 | License File: LICENSE.txt 5 | Format: Maestro package 6 | Description: Maestro MCU Audio Framework 7 | Location: https://github.com/nxp-mcuxpresso/maestro 8 | 9 | Package content: 10 | Precompiled libraries 11 | Outgoing License: LA_OPT_NXP_Software_License.txt September 2023 - Additional distribution license - License in Section 2.3 applies 12 | License File: LICENSE.txt 13 | Release location: ./libs/* 14 | Format: Binary 15 | Origin: NXP (Proprietary) 16 | Flac (BSD 3-clause) 17 | Url: https://github.com/xiph/flac 18 | 19 | Redistributable source files 20 | Outgoing License: BSD 3-clause 21 | License File: COPYING-BSD-3 22 | Release location: ./config/*, .inc/*, .mcu-audio/*, .streamer/*, .template/* 23 | Format: Source and header files 24 | Origin: NXP (BSD 3-clause) 25 | Ogg (BSD 3-clause) 26 | Opus (BSD 3-clause) 27 | Opusfile (BSD 3-clause) 28 | Url: https://github.com/xiph/ogg 29 | https://github.com/xiph/opus 30 | https://github.com/xiph/opusfile 31 | -------------------------------------------------------------------------------- /audio_examples.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if (CONFIG_MCUX_PRJSEG_module.audio_voice.default_config) 5 | mcux_add_configuration( 6 | CC "-DSAI_XFER_QUEUE_SIZE=2" 7 | ) 8 | 9 | mcux_add_iar_configuration( 10 | LD "--config_def=__stack_size__=0x1000 --config_def=__heap_size__=0x3000 --semihosting" 11 | ) 12 | 13 | mcux_add_armgcc_configuration( 14 | LD "-Xlinker --defsym=__stack_size__=0x1000 -Xlinker --defsym=__heap_size__=0x1000" 15 | ) 16 | endif() 17 | 18 | if (CONFIG_MCUX_PRJSEG_module.audio_voice.lpc_config) 19 | mcux_add_configuration( 20 | CC "-DPRINTF_ADVANCED_ENABLE=1 -DPRINTF_FLOAT_ENABLE=1" 21 | ) 22 | 23 | mcux_add_iar_configuration( 24 | LD "--config_def=__stack_size__=0x1000 --config_def=__heap_size__=0x2500 --semihosting" 25 | ) 26 | 27 | mcux_add_armgcc_configuration( 28 | LD "-Xlinker --defsym=__stack_size__=0x1000 -Xlinker --defsym=__heap_size__=0x2000" 29 | ) 30 | endif() 31 | 32 | 33 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_EN_ENABLE) 34 | mcux_add_macro( 35 | CC "-DVIT_MODEL_EN" 36 | TOOLCHAINS armgcc mcux 37 | ) 38 | endif() 39 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_CN_ENABLE) 40 | mcux_add_macro( 41 | CC "-DVIT_MODEL_CN" 42 | TOOLCHAINS armgcc mcux 43 | ) 44 | endif() 45 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_DE_ENABLE) 46 | mcux_add_macro( 47 | CC "-DVIT_MODEL_DE" 48 | TOOLCHAINS armgcc mcux 49 | ) 50 | endif() 51 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_ES_ENABLE) 52 | mcux_add_macro( 53 | CC "-DVIT_MODEL_ES" 54 | TOOLCHAINS armgcc mcux 55 | ) 56 | endif() 57 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_FR_ENABLE) 58 | mcux_add_macro( 59 | CC "-DVIT_MODEL_FR" 60 | TOOLCHAINS armgcc mcux 61 | ) 62 | endif() 63 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_IT_ENABLE) 64 | mcux_add_macro( 65 | CC "-DVIT_MODEL_IT" 66 | TOOLCHAINS armgcc mcux 67 | ) 68 | endif() 69 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_JA_ENABLE) 70 | mcux_add_macro( 71 | CC "-DVIT_MODEL_JA" 72 | TOOLCHAINS armgcc mcux 73 | ) 74 | endif() 75 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_KO_ENABLE) 76 | mcux_add_macro( 77 | CC "-DVIT_MODEL_KO" 78 | TOOLCHAINS armgcc mcux 79 | ) 80 | endif() 81 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_PT_ENABLE) 82 | mcux_add_macro( 83 | CC "-DVIT_MODEL_PT" 84 | TOOLCHAINS armgcc mcux 85 | ) 86 | endif() 87 | if (CONFIG_MCUX_PRJSEG_MAESTRO_EXAMPLE_VIT_MODEL_TR_ENABLE) 88 | mcux_add_macro( 89 | CC "-DVIT_MODEL_TR" 90 | TOOLCHAINS armgcc mcux 91 | ) 92 | endif() -------------------------------------------------------------------------------- /components.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.decoder.aac.enable) 5 | mcux_add_source( 6 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders/aac 7 | SOURCES *.c 8 | *.h 9 | TOOLCHAINS armgcc mcux 10 | ) 11 | 12 | mcux_add_include( 13 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 14 | INCLUDES aac 15 | ) 16 | 17 | mcux_add_macro( 18 | CC "-DAAC_DEC=1" 19 | TOOLCHAINS armgcc mcux 20 | ) 21 | endif() 22 | 23 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.decoder.flac.enable) 24 | mcux_add_source( 25 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders/flac 26 | SOURCES flac_extractmetadata.c 27 | TOOLCHAINS armgcc iar mcux 28 | ) 29 | 30 | mcux_add_macro( 31 | CC "-DFLAC_DEC=1" 32 | TOOLCHAINS armgcc iar mcux 33 | ) 34 | endif() 35 | 36 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.decoder.mp3.enable) 37 | mcux_add_include( 38 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 39 | INCLUDES mp3 40 | TOOLCHAINS armgcc iar mcux 41 | ) 42 | 43 | mcux_add_source( 44 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 45 | SOURCES mp3/*.h 46 | mp3/*.c 47 | TOOLCHAINS armgcc iar mcux 48 | ) 49 | 50 | mcux_add_macro( 51 | CC "-DMP3_DEC=1" 52 | TOOLCHAINS armgcc iar mcux 53 | ) 54 | endif() 55 | 56 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.decoder.wav.enable) 57 | mcux_add_include( 58 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 59 | INCLUDES wav 60 | TOOLCHAINS armgcc iar mcux 61 | ) 62 | 63 | mcux_add_source( 64 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 65 | SOURCES wav/*.h 66 | wav/*.c 67 | TOOLCHAINS armgcc iar mcux 68 | ) 69 | 70 | mcux_add_macro( 71 | CC "-DWAV_DEC=1" 72 | TOOLCHAINS armgcc iar mcux 73 | ) 74 | endif() 75 | 76 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.decoder.opus_ogg.enable) 77 | mcux_add_source( 78 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/decoders 79 | SOURCES opus/opus_extractmetadata.c 80 | ) 81 | mcux_add_macro( 82 | CC "-DOGG_OPUS_DEC=1" 83 | ) 84 | endif() 85 | 86 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.encoder.opus.enable) 87 | mcux_add_include( 88 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/encoders 89 | INCLUDES opus 90 | ) 91 | 92 | mcux_add_source( 93 | BASE_PATH ${SdkRootDirPath}/middleware/audio_voice/maestro/components/encoders 94 | SOURCES opus/opusenc_cei.c 95 | opus/opusenc_cei.h 96 | ) 97 | 98 | mcux_add_macro( 99 | CC "-DOPUS_ENCODE=1\ 100 | -DSTREAMER_ENABLE_CEI_OPUS=1" 101 | ) 102 | endif() 103 | 104 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.audio_proc.asrc.enable) 105 | mcux_add_macro( 106 | CC "-DASRC_PROC=1" 107 | TOOLCHAINS armgcc mcux 108 | ) 109 | endif() 110 | 111 | if (CONFIG_MCUX_COMPONENT_middleware.audio_voice.maestro.element.audio_proc.ssrc.enable) 112 | mcux_add_macro( 113 | CC "-DSSRC_PROC=1" 114 | TOOLCHAINS armgcc iar mcux 115 | ) 116 | endif() 117 | 118 | if (CONFIG_MCUX_PRJSEG_middleware.audio_voice.components.voice_seeker) 119 | mcux_add_macro( 120 | CC "-DVOICE_SEEKER_PROC=1" 121 | TOOLCHAINS armgcc mcux 122 | ) 123 | endif() 124 | 125 | if (CONFIG_MCUX_PRJSEG_middleware.audio_voice.components.vit) 126 | mcux_add_macro( 127 | CC "-DVIT_PROC=1" 128 | TOOLCHAINS armgcc mcux 129 | ) 130 | endif() -------------------------------------------------------------------------------- /components/decoders/aac/aac_metadata.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | //! \addtogroup asi_dffi 3 | //! @{ 4 | // 5 | // Copyright 2004-2005 SigmaTel, Inc. 6 | // Copyright 2024 NXP 7 | // 8 | // SPDX-License-Identifier: BSD-3-Clause 9 | // 10 | //! \file asi_dffi_aac_metadata.h 11 | //! \brief Contains defines for MP3 metadata functions. 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | // Definitions 16 | //////////////////////////////////////////////////////////////////////////////// 17 | #define MOOV_CKID 0 //!< \brief main metadata atom 18 | #define STSZ_CKID 1 //!< \brief to gather the metadata information 19 | #define MDAT_CKID 2 //!< \brief to indicate that metadata portion is over 20 | #define MDIA_CKID 3 //!< \brief to break to go to sub-atom 21 | #define MINF_CKID 4 //!< \brief to break to go to sub-atom 22 | #define TRAK_CKID 5 //!< \brief to break to go to sub-atom 23 | #define STBL_CKID 6 //!< \brief to break to go to sub-atom 24 | #define FTYP_CKID 7 //!< \brief to check whether mp4 file 25 | #define UDTA_CKID 8 //!< \brief to break 26 | #define ALB_CKID 9 //!< \brief to get album name 27 | #define ART_CKID 10 //!< \brief to get artists name 28 | #define STSD_CKID 11 29 | #define MP4A_CKID 12 30 | #define LIST_CKID 13 31 | #define TTL_CKID 14 //!< \brief to get title name 32 | #define DRMS_CKID 15 33 | 34 | #define ESDS_CKID 16 //!< \brief APPLE: add ESDS atom index 35 | #define SINF_CKID 17 //!< \brief APPLE: add SINF atom index 36 | // Add more Ckids here 37 | #define META_CKID 18 38 | #define MDHD_CKID 19 39 | #define DAY_CKID 20 //!< \brief Year metadata here 40 | #define TRKN_CKID 21 //!< \brief Track Number Metadata 41 | #define MP4V_CKID 22 //!< \brief video chunk 42 | #define AVC1_CKID 23 //!< \brief video chunk 43 | #define HDLR_CKID 24 //!< \brief Handler Chunk to identify Video/Audio handler 44 | #define STCO_CKID 25 45 | #define ALAC_CKID 26 46 | #define GEN_CKID 27 47 | #define GNRE_CKID 28 48 | 49 | #define UNKNOWN_CKID 29 50 | #define TOTAL_CKID 29 51 | 52 | #define BUFFERFILL 96 * 3 53 | 54 | #define ATOM_NAME_LENGTH 4 55 | #define ATOM_SIZE_LENGTH 4 56 | #define ATOM_HEADER_LENGTH (ATOM_NAME_LENGTH + ATOM_SIZE_LENGTH) 57 | #define MAX_MDAT_ATOM 4 58 | 59 | uint32_t ADTS_GetBytes(CCI_Ctx *Ctx, int32_t); 60 | void ADTS_SkipBytes(CCI_Ctx *Ctx, int32_t); 61 | uint32_t ADTS_IndexToSampleRate(int); 62 | uint32_t ADTS_Bitrate(CCI_Ctx *Ctx, uint32_t, uint32_t); 63 | int32_t ADTS_GetCurrentOffset(CCI_Ctx *Ctx); 64 | 65 | typedef struct AAC_DFFI 66 | { 67 | int32_t Aac_NumSamples; 68 | int32_t Aac_TimeScale; 69 | int32_t Aac_SamplingRate; 70 | int32_t Aac_BitRate; 71 | int32_t aac_file_flag; 72 | int32_t overwrite; // overwrite 73 | int32_t tracktype; // tracktype = UNKNOWN 74 | int32_t AACMetaDataFlag; // if it is 1 it indiacates that title name/album name/artist's name is available 75 | int32_t AacCkSize; // this variable is global 76 | int32_t AacDataBegin[MAX_MDAT_ATOM]; 77 | // to get the multiplication right!!! 78 | int32_t AacMDATCount; 79 | int64_t AacMDATSize[MAX_MDAT_ATOM]; 80 | int32_t chunkcount; 81 | int32_t MandatoryAtoms; 82 | int32_t AllAtoms; 83 | int32_t SamplingRate; 84 | int32_t AacFlag; 85 | int32_t aac_file_offset; 86 | int32_t AacCkVal; 87 | int32_t Aac_Duration; 88 | } AAC_DFFI_t; 89 | 90 | #ifndef min 91 | #define min(a, b) (((a) < (b)) ? (a) : (b)) 92 | #endif 93 | 94 | /////////////////////////////////////////////////////////////////////////////// 95 | // End of file 96 | /////////////////////////////////////////////////////////////////////////////// 97 | //! @} 98 | -------------------------------------------------------------------------------- /components/decoders/mp3/mp3_id3v2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | //! \addtogroup asi_dffi 8 | //! @{ 9 | // 10 | // Copyright (c) 2004-2005 SigmaTel, Inc. 11 | // 12 | //! \file mp3_id3v2.h 13 | //! \brief Contains functionality to read MP3 metadata. 14 | 15 | #ifndef __ID3V2_H 16 | #define __ID3V2_H 17 | 18 | //////////////////////////////////////////////////////////////////////////////// 19 | // Macros 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | // Includes 24 | //////////////////////////////////////////////////////////////////////////////// 25 | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | // Prototypes 28 | //////////////////////////////////////////////////////////////////////////////// 29 | int32_t Mp3MetaDataReadID3V2(CCI_Ctx *Ctx, int32_t iIgnored, file_meta_data_t *pMetaData); 30 | 31 | #endif 32 | /////////////////////////////////////////////////////////////////////////////// 33 | // End of file 34 | //////////////////////////////////////////////////////////////////////////////// 35 | //! @} 36 | -------------------------------------------------------------------------------- /components/decoders/mp3/mp3_id3v2_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | //! \addtogroup asi_dffi 8 | //! @{ 9 | // 10 | // Copyright (c) 2004-2005 SigmaTel, Inc. 11 | // 12 | //! \file mp3_id3v2_internal.h 13 | //! \brief Contains functionality to read MP3 metadata. 14 | 15 | #ifndef __ID3V2_INTERNAL_H 16 | #define __ID3V2_INTERNAL_H 17 | 18 | #include 19 | 20 | #ifndef MAX_STRING 21 | #define MAX_STRING 100 22 | #endif 23 | 24 | #define ID3V2_HEADER_FLAG_FOOTER 0x10 25 | #define ID3V2_HEADER_EXPERIMENTAL 0x20 26 | #define ID3V2_HEADER_EXTENDED_HEADER 0x40 27 | #define ID3V2_HEADER_UNSYNCRONIZATION 0x80 28 | 29 | // We don't support these 30 | #define ID3V2_FRAME_HEADER_TAG_ALTER_PREVERVE 0x0040 31 | #define ID3V2_FRAME_HEADER_FILE_ALTER_PRESERVE 0x0020 32 | #define ID3V2_FRAME_HEADER_FRAME_READ_ONLY 0x0010 33 | 34 | // We don't support these 35 | #define ID3V2_FRAME_HEADER_GROUPING_IDENTITY 0x4000 36 | #define ID3V2_FRAME_HEADER_DATA_LENGTH_INDICATOR 0x0100 37 | 38 | // We only use these to determine that we cannot read a frame with these bits present. 39 | #define ID3V2_FRAME_HEADER_UNSYNCRONIZATION 0x0200 40 | #define ID3V2_FRAME_HEADER_COMPRESSION 0x0800 41 | #define ID3V2_FRAME_HEADER_ENCRYPTION 0x0400 42 | 43 | // These represent the last 3 letters of the frame identifier. 44 | // The function Id3V2ReadFrame() will read the first byte (the T, for example) in one word, 45 | // and then the last 3 letters as another word. This helps to easily determine what the identifier for 46 | // the tag is easier. Remember, these 3 bytes are read from the file in reversed order. (So TALB is actually 47 | // read into 2 words: 'T' and 'BLA') 48 | #define TALB 0x424c41 49 | #define TIT1 0x315449 50 | #define TIT2 0x325449 51 | #define TPE1 0x314550 52 | #define TRCK 0x4b4352 53 | #define TCON 0x4e4f43 54 | #define TYER 0x524559 55 | #define TDRC 0x435244 56 | 57 | // These represent the last 3 letters of the frame identifier. 58 | // The function Id3V2ReadFramev2() will read the first byte (the T, for example) in one word, 59 | // and then the last 2 letters as another word. This helps to easily determine what the identifier for 60 | // the tag is easier. Remember, these 2 bytes are read from the file in reversed order. (So TAL is actually 61 | // read into 2 words: 'T' and 'LA') 62 | #define TAL 0x4c41 63 | #define TT1 0x3154 64 | #define TT2 0x3254 65 | #define TP1 0x3150 66 | #define TRK 0x4b52 67 | #define TCO 0x4f43 68 | #define TYE 0x4559 69 | 70 | #define ENCODING_ISO_8559 0 71 | #define ENCODING_UTF_16 1 72 | #define ENCODING_UTF_16_NOBOM 2 73 | #define ENCODING_UTF_8 3 74 | 75 | #define BOM_BIG_ENDIAN 0xFFFE 76 | #define BOM_LITTLE_ENDIAN 0xFEFF 77 | 78 | //////////////////////////////////////////////////////////////////////////////// 79 | // Prototypes 80 | //////////////////////////////////////////////////////////////////////////////// 81 | bool Id3V2ReadFrame(CCI_Ctx *Ctx, file_meta_data_t *pMetaData, bool bSyncSafe); 82 | bool Id3V2ReadFramev2(CCI_Ctx *Ctx, file_meta_data_t *pMetaData, bool bSyncSafe); 83 | int Id3V2ReadVariedStringToUnicodeBuffer( 84 | CCI_Ctx *Ctx, uint32_t uFlags, uint32_t uFrameSize, uint16_t *pString, int32_t iBufferLength); 85 | int Id3V2ReadUTF16String( 86 | CCI_Ctx *Ctx, uint32_t uEndianNess, uint32_t uFlags, uint32_t uFrameSize, uint16_t *pString, int32_t iBufferLength); 87 | int Id3V2ReadUTF8String(CCI_Ctx *Ctx, uint32_t uFrameSize, uint16_t *pString, int32_t iBufferLength); 88 | 89 | uint32_t Id3V2ReadInt(CCI_Ctx *Ctx, bool bSyncSafe); 90 | uint32_t Id3V2ReadIntv2(CCI_Ctx *Ctx, bool bSyncSafe); 91 | 92 | #endif 93 | /////////////////////////////////////////////////////////////////////////////// 94 | // End of file 95 | //////////////////////////////////////////////////////////////////////////////// 96 | //! @} 97 | -------------------------------------------------------------------------------- /components/decoders/opus/opus_extractmetadata.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | //////////////////////////////////////////////////////////////////////////////// 8 | // Includes 9 | //////////////////////////////////////////////////////////////////////////////// 10 | #include 11 | #include "cci_metadata.h" 12 | #include "codec_interface.h" 13 | #ifdef OGG_OPUS_DEC 14 | #include 15 | #endif 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | //! \brief Extract the meta data from raw opus file. 19 | //! 20 | //! 21 | //! Extract the meta data from the file. 22 | //! 23 | //! \param[in] *MetaData this structure will be filled in by the function 24 | //! \param[in] *ctx CCI Context Structure 25 | //! \retval SUCCESS 26 | //! \retval CODEC_METADATA_NOT_FOUND -- metadata failed 27 | //! \retval ERROR_ASI_DFFI_METADATA_NOT_FOUND - metadata was not found 28 | //! \retval ERROR_OS_FILESYSTEM_FILE_OPEN -- the file failed to open 29 | //! \retval CODEC_FSEEK_FAILED - fseek call failed 30 | //! 31 | //////////////////////////////////////////////////////////////////////////////// 32 | int32_t codec_extract_metadata_opus(file_meta_data_t *MetaData, CCI_Ctx *ctx) 33 | { 34 | /* Hard-code the audio format details for streaming use case. */ 35 | MetaData->sample_rate = 48000; 36 | MetaData->num_channels = 1; 37 | MetaData->bits_per_sample = 16; 38 | MetaData->stream_type = STREAM_TYPE_OPUS; 39 | 40 | MetaData->valid_vbr_header = 0; 41 | MetaData->start_pos = 0; 42 | /* Cannot calculate with audio stream. Set to non-zero to avoid 43 | * streamer pipeline error about invalid duration. */ 44 | MetaData->total_time = 1; 45 | 46 | return CODEC_SUCCESS; 47 | } 48 | 49 | #ifdef OGG_OPUS_DEC 50 | 51 | //////////////////////////////////////////////////////////////////////////////// 52 | //! \brief Extract the meta data from the ogg opus file. 53 | //! 54 | //! 55 | //! Extract the meta data from the file. 56 | //! 57 | //! \param[in] *MetaData this structure will be filled in by the function 58 | //! \param[in] *ctx CCI Context Structure 59 | //! \retval SUCCESS 60 | //! \retval CODEC_METADATA_NOT_FOUND -- metadata failed 61 | //! \retval ERROR_ASI_DFFI_METADATA_NOT_FOUND - metadata was not found 62 | //! \retval ERROR_OS_FILESYSTEM_FILE_OPEN -- the file failed to open 63 | //! \retval CODEC_FSEEK_FAILED - fseek call failed 64 | //! 65 | //////////////////////////////////////////////////////////////////////////////// 66 | int32_t codec_extract_metadata_ogg_opus(file_meta_data_t *MetaData, CCI_Ctx *ctx) 67 | { 68 | int ret = 0; 69 | uint8_t opus_buf[60]; 70 | OpusHead head = {0}; 71 | 72 | ctx->cci_dec_read(0, opus_buf, sizeof(opus_buf), 0, ctx->user_data); 73 | 74 | ret = op_test(&head, opus_buf, sizeof(opus_buf)); 75 | if (ret < 0) 76 | { 77 | /* Cannot parse header */ 78 | return CODEC_METADATA_NOT_FOUND; 79 | } 80 | 81 | /* Set the sample rate to 48kHz because the output data from the op_read() function is always at 48kHz. */ 82 | MetaData->sample_rate = 48000U; 83 | 84 | MetaData->num_channels = head.channel_count; 85 | MetaData->stream_type = STREAM_TYPE_OGG_OPUS; 86 | 87 | /* Hard-code the audio format details for streaming use case. */ 88 | MetaData->bits_per_sample = 16; 89 | MetaData->valid_vbr_header = 0; 90 | MetaData->start_pos = 0; 91 | /* Cannot calculate with audio stream. Set to non-zero to avoid 92 | * streamer pipeline error about invalid duration. */ 93 | MetaData->total_time = 1; 94 | 95 | return CODEC_SUCCESS; 96 | } 97 | 98 | /////////////////////////////////////////////////////////////////////////////// 99 | // End of file 100 | //////////////////////////////////////////////////////////////////////////////// 101 | //! @} 102 | 103 | #endif /* OGG_OPUS */ 104 | -------------------------------------------------------------------------------- /components/decoders/wav/adpcm_extractmetadata.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | //! \addtogroup asi_dffi 9 | //! @{ 10 | // 11 | // Copyright (c) 2004-2005 SigmaTel, Inc. 12 | // 13 | //! \file adpcm_extractmetadata.c 14 | //! \brief Contains functionality that extracts the meta data from the file 15 | //! and stores it in the file_meta_data_t structure. 16 | /////////////////////////////////////////////////////////////////////////////// 17 | 18 | //////////////////////////////////////////////////////////////////////////////// 19 | // Includes 20 | //////////////////////////////////////////////////////////////////////////////// 21 | #include "codec_interface.h" 22 | #include "cci_metadata.h" 23 | 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // Macros 26 | //////////////////////////////////////////////////////////////////////////////// 27 | 28 | //////////////////////////////////////////////////////////////////////////////// 29 | // External Definitions 30 | //////////////////////////////////////////////////////////////////////////////// 31 | 32 | //////////////////////////////////////////////////////////////////////////////// 33 | // External References 34 | //////////////////////////////////////////////////////////////////////////////// 35 | 36 | //////////////////////////////////////////////////////////////////////////////// 37 | // Equates 38 | //////////////////////////////////////////////////////////////////////////////// 39 | 40 | //////////////////////////////////////////////////////////////////////////////// 41 | // Prototypes 42 | //////////////////////////////////////////////////////////////////////////////// 43 | extern RtStatus_t CodecExtractMetaDataAdpcm(file_meta_data_t *meta_data, CCI_Ctx *Ctx); 44 | 45 | //////////////////////////////////////////////////////////////////////////////// 46 | // Variables 47 | //////////////////////////////////////////////////////////////////////////////// 48 | 49 | ///////////////////////////////////////////////////////////////////////////////// 50 | //! \brief Extract the meta data. 51 | //! 52 | //! \param[in] int64_t file_handle this key allows the file to be quickly found and opened 53 | //! \param[in] file_meta_data_t *MetaData this structure will be filled in by the function 54 | //! 55 | //! \retval SUCCESS 56 | //! \retval ERROR -- various errors can be returned from this function 57 | //! 58 | //! \note This should be accessed via the generic function DffiExtractMetaData. 59 | //! This function parses file up to Data chunk and gives start position. 60 | //! 61 | //! 62 | ///////////////////////////////////////////////////////////////////////////////// 63 | int32_t codec_extract_metadata_wave(file_meta_data_t *meta_data, CCI_Ctx *Ctx) 64 | { 65 | return ((RtStatus_t)(CodecExtractMetaDataAdpcm(meta_data, Ctx))); 66 | } 67 | /////////////////////////////////////////////////////////////////////////////// 68 | // End of file 69 | /////////////////////////////////////////////////////////////////////////////// 70 | //! @} 71 | -------------------------------------------------------------------------------- /components/decoders/wav/wav_metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | //! \addtogroup asi_dffi 9 | //! @{ 10 | // 11 | // Copyright (c) 2004-2005 SigmaTel, Inc. 12 | // 13 | //! \file asi_dffi_wav_metadata.h 14 | //! \brief Includes header data for wav meta-data functions. 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #define ADPCM_READ_BUFFER_SIZE 156 18 | 19 | /* WAVE form wFormatTag IDs */ 20 | #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */ 21 | #define WAVE_FORMAT_PCM 0x0001 /* Microsoft PCM */ 22 | #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */ 23 | #define WAVE_FORMAT_IBM_CVSD 0x0005 /* IBM Corporation */ 24 | #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */ 25 | #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */ 26 | #define WAVE_FORMAT_OKI_ADPCM 0x0010 /* OKI */ 27 | #define WAVE_FORMAT_DVI_ADPCM 0x0011 /* Intel Corporation */ 28 | #define WAVE_FORMAT_IMA_ADPCM (WAVE_FORMAT_DVI_ADPCM) /* Intel Corporation */ 29 | #define WAVE_FORMAT_MEDIASPACE_ADPCM 0x0012 /* Videologic */ 30 | #define WAVE_FORMAT_SIERRA_ADPCM 0x0013 /* Sierra Semiconductor Corp */ 31 | #define WAVE_FORMAT_G723_ADPCM 0x0014 /* Antex Electronics Corporation */ 32 | #define WAVE_FORMAT_DIGISTD 0x0015 /* DSP Solutions, Inc. */ 33 | #define WAVE_FORMAT_DIGIFIX 0x0016 /* DSP Solutions, Inc. */ 34 | #define WAVE_FORMAT_DIALOGIC_OKI_ADPCM 0x0017 /* Dialogic Corporation */ 35 | #define WAVE_FORMAT_YAMAHA_ADPCM 0x0020 /* Yamaha Corporation of America */ 36 | #define WAVE_FORMAT_SONARC 0x0021 /* Speech Compression */ 37 | #define WAVE_FORMAT_DSPGROUP_TRUESPEECH 0x0022 /* DSP Group, Inc */ 38 | #define WAVE_FORMAT_ECHOSC1 0x0023 /* Echo Speech Corporation */ 39 | #define WAVE_FORMAT_AUDIOFILE_AF36 0x0024 /* */ 40 | #define WAVE_FORMAT_APTX 0x0025 /* Audio Processing Technology */ 41 | #define WAVE_FORMAT_AUDIOFILE_AF10 0x0026 /* */ 42 | #define WAVE_FORMAT_DOLBY_AC2 0x0030 /* Dolby Laboratories */ 43 | #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */ 44 | #define WAVE_FORMAT_ANTEX_ADPCME 0x0033 /* Antex Electronics Corporation */ 45 | #define WAVE_FORMAT_CONTROL_RES_VQLPC 0x0034 /* Control Resources Limited */ 46 | #define WAVE_FORMAT_DIGIREAL 0x0035 /* DSP Solutions, Inc. */ 47 | #define WAVE_FORMAT_DIGIADPCM 0x0036 /* DSP Solutions, Inc. */ 48 | #define WAVE_FORMAT_CONTROL_RES_CR10 0x0037 /* Control Resources Limited */ 49 | #define WAVE_FORMAT_NMS_VBXADPCM 0x0038 /* Natural MicroSystems */ 50 | #define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */ 51 | #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */ 52 | #define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative Labs, Inc */ 53 | #define WAVE_FORMAT_CREATIVE_FASTSPEECH8 0x0202 /* Creative Labs, Inc */ 54 | #define WAVE_FORMAT_CREATIVE_FASTSPEECH10 0x0203 /* Creative Labs, Inc */ 55 | #define WAVE_FORMAT_FM_TOWNS_SND 0x0300 /* Fujitsu Corp. */ 56 | #define WAVE_FORMAT_OLIGSM 0x1000 /* Ing C. Olivetti & C., S.p.A. */ 57 | #define WAVE_FORMAT_OLIADPCM 0x1001 /* Ing C. Olivetti & C., S.p.A. */ 58 | #define WAVE_FORMAT_OLICELP 0x1002 /* Ing C. Olivetti & C., S.p.A. */ 59 | #define WAVE_FORMAT_OLISBC 0x1003 /* Ing C. Olivetti & C., S.p.A. */ 60 | #define WAVE_FORMAT_OLIOPR 0x1004 /* Ing C. Olivetti & C., S.p.A. */ 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | // End of file 64 | /////////////////////////////////////////////////////////////////////////////// 65 | //! @} 66 | -------------------------------------------------------------------------------- /components/decoders/wav/wavedata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Extern references 8 | #define MAX_CHANNEL 2 9 | 10 | extern short *InputBuf; 11 | extern short *OutputBuf; 12 | 13 | typedef struct IOStream__ 14 | { 15 | uint8_t *pu8ReadBaseAddr; 16 | uint8_t *pu8ReadPtr; 17 | uint8_t *pu8ReadEndAddr; 18 | uint8_t *pu8WriteBaseAddr; 19 | uint8_t *pu8WritePtr; 20 | uint8_t *pu8WriteEndAddr; 21 | } IOStream_t; 22 | 23 | // Function Declarations 24 | typedef struct 25 | { 26 | int pred; 27 | int step; 28 | int index; 29 | } tADPCM; 30 | 31 | typedef struct _ms_adpcm_memory 32 | { 33 | int iPredSample[2]; 34 | short iSamp1[2]; 35 | short iSamp2[2]; 36 | short iCoef1[2]; 37 | short iCoef2[2]; 38 | short iDelta[2]; 39 | short wCoef1[10]; // Provision for 10 coefficient sets. Signed data. 40 | short wCoef2[10]; 41 | unsigned char bPredictor[2]; 42 | int first_block; 43 | } ms_adpcm_memory_t; 44 | 45 | typedef struct _ima_adpcm_memory 46 | { 47 | tADPCM sIma[MAX_CHANNEL]; 48 | } ima_adpcm_memory_t; 49 | 50 | typedef struct 51 | { 52 | union 53 | { 54 | ms_adpcm_memory_t ms; 55 | ima_adpcm_memory_t ima; 56 | } u; 57 | // Frequently used variables 58 | short wnSamplesPerBlock; 59 | short gwBlockAlign; 60 | short gwChannels; 61 | 62 | int gwWavDuration; 63 | int gwSamplesPerSec; 64 | int gwAvgBytesPerSec; 65 | unsigned short gwFormatTag; 66 | short wBitsPerSample; 67 | short wcbSize; 68 | short wnNumCoef; 69 | int datachunksize; // Used in AIFF 70 | int dataOffset; 71 | short wValidBitsPerSample; 72 | int dwChannelMask; 73 | // int nReadBytes; 74 | // int nWriteBytes; 75 | int OutputBinaryDataWritten; 76 | int InputDataPtr; 77 | int gnInputBufModulo; 78 | int gnOutputBufModulo; 79 | uint8_t *OutputBinaryData; 80 | uint8_t *InputBinaryData; 81 | } WAVDEC; 82 | 83 | extern int waveparser(); 84 | extern int Initialize_Wave_Header(int formattag, int num_channels, int SamplingRate); 85 | void Write_Wave_Header(); 86 | 87 | void InitIMAStates(void); 88 | extern void Encode_PCM(int); 89 | /* Decoder prototypes */ 90 | extern void Decode_PCM_Block(WAVDEC *ptrThis, int SamplestoDecode, int *pi32BytesRead, int *pi32BytesWrite); 91 | extern void Decode_MS_ADPCM_Block( 92 | WAVDEC *ptrThis, int SamplestoDecode, int channels, int ContinuationFlag, int *pi32BytesRead, int *pi32BytesWrite); 93 | extern void Decode_IMA_ADPCM_Block( 94 | WAVDEC *ptrThis, int SamplestoDecode, int ContinuationFlag, int *pi32BytesRead, int *pi32BytesWrite); 95 | extern int setupWaveDecoderStream(IOStream_t *IOStream, 96 | WAVDEC *wav, 97 | int *fileOffset, 98 | unsigned char i32eof, 99 | int i32InitialBufferSize, 100 | int decType, 101 | int i32DataOffset); 102 | extern void Decode_AIFF(WAVDEC *ptrThis, int SamplestoDecode, int *pi32BytesRead, int *pi32BytesWrite); 103 | -------------------------------------------------------------------------------- /components/decoders/wav/wavedefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | // Copyright(C) SigmaTel, Inc. 2004 9 | // 10 | // Filename: wavedefs.h 11 | // Description: Includes header data for wav meta-data functions. 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #define ADPCM_READ_BUFFER_SIZE 156 15 | 16 | /* WAVE form wFormatTag IDs */ 17 | #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */ 18 | #define WAVE_FORMAT_PCM 0x0001 /* Microsoft PCM */ 19 | #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */ 20 | #define WAVE_FORMAT_IBM_CVSD 0x0005 /* IBM Corporation */ 21 | #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */ 22 | #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */ 23 | #define WAVE_FORMAT_OKI_ADPCM 0x0010 /* OKI */ 24 | #define WAVE_FORMAT_DVI_ADPCM 0x0011 /* Intel Corporation */ 25 | #define WAVE_FORMAT_IMA_ADPCM (WAVE_FORMAT_DVI_ADPCM) /* Intel Corporation */ 26 | #define WAVE_FORMAT_MEDIASPACE_ADPCM 0x0012 /* Videologic */ 27 | #define WAVE_FORMAT_SIERRA_ADPCM 0x0013 /* Sierra Semiconductor Corp */ 28 | #define WAVE_FORMAT_G723_ADPCM 0x0014 /* Antex Electronics Corporation */ 29 | #define WAVE_FORMAT_DIGISTD 0x0015 /* DSP Solutions, Inc. */ 30 | #define WAVE_FORMAT_DIGIFIX 0x0016 /* DSP Solutions, Inc. */ 31 | #define WAVE_FORMAT_DIALOGIC_OKI_ADPCM 0x0017 /* Dialogic Corporation */ 32 | #define WAVE_FORMAT_YAMAHA_ADPCM 0x0020 /* Yamaha Corporation of America */ 33 | #define WAVE_FORMAT_SONARC 0x0021 /* Speech Compression */ 34 | #define WAVE_FORMAT_DSPGROUP_trueSPEECH 0x0022 /* DSP Group, Inc */ 35 | #define WAVE_FORMAT_ECHOSC1 0x0023 /* Echo Speech Corporation */ 36 | #define WAVE_FORMAT_AUDIOFILE_AF36 0x0024 /* */ 37 | #define WAVE_FORMAT_APTX 0x0025 /* Audio Processing Technology */ 38 | #define WAVE_FORMAT_AUDIOFILE_AF10 0x0026 /* */ 39 | #define WAVE_FORMAT_DOLBY_AC2 0x0030 /* Dolby Laboratories */ 40 | #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */ 41 | #define WAVE_FORMAT_ANTEX_ADPCME 0x0033 /* Antex Electronics Corporation */ 42 | #define WAVE_FORMAT_CONTROL_RES_VQLPC 0x0034 /* Control Resources Limited */ 43 | #define WAVE_FORMAT_DIGIREAL 0x0035 /* DSP Solutions, Inc. */ 44 | #define WAVE_FORMAT_DIGIADPCM 0x0036 /* DSP Solutions, Inc. */ 45 | #define WAVE_FORMAT_CONTROL_RES_CR10 0x0037 /* Control Resources Limited */ 46 | #define WAVE_FORMAT_NMS_VBXADPCM 0x0038 /* Natural MicroSystems */ 47 | #define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */ 48 | #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */ 49 | #define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative Labs, Inc */ 50 | #define WAVE_FORMAT_CREATIVE_FASTSPEECH8 0x0202 /* Creative Labs, Inc */ 51 | #define WAVE_FORMAT_CREATIVE_FASTSPEECH10 0x0203 /* Creative Labs, Inc */ 52 | #define WAVE_FORMAT_FM_TOWNS_SND 0x0300 /* Fujitsu Corp. */ 53 | #define WAVE_FORMAT_OLIGSM 0x1000 /* Ing C. Olivetti & C., S.p.A. */ 54 | #define WAVE_FORMAT_OLIADPCM 0x1001 /* Ing C. Olivetti & C., S.p.A. */ 55 | #define WAVE_FORMAT_OLICELP 0x1002 /* Ing C. Olivetti & C., S.p.A. */ 56 | #define WAVE_FORMAT_OLISBC 0x1003 /* Ing C. Olivetti & C., S.p.A. */ 57 | #define WAVE_FORMAT_OLIOPR 0x1004 /* Ing C. Olivetti & C., S.p.A. */ 58 | #define WAVE_FORMAT_EXTENSIBLE 0xfffe /* wave format extensible */ 59 | 60 | // Supported chunk types 61 | #define RIFF_CKID 0 62 | #define WAVE_CKID 1 63 | #define FMT_CKID 2 64 | #define FACT_CKID 3 65 | #define DATA_CKID 4 66 | #define LIST_CKID 5 67 | #define INFO_CKID 6 68 | #define ISFT_CKID 7 69 | #define IART_CKID 8 70 | #define DISP_CKID 9 71 | #define IGNR_CKID 10 72 | #define ICRD_CKID 11 73 | // Add more Ckids here 74 | #define INAM_CKID 12 75 | #define IPRD_CKID 13 76 | 77 | #define UNKNOWN_CKID 14 78 | #define TOTAL_CKID 14 79 | 80 | #define FORM_CKID 0 81 | #define AIFF_CKID 1 82 | #define COMM_CKID 2 83 | #define SSND_CKID 3 84 | #define MARK_CKID 4 85 | 86 | #define ADPCM_SOURCE_BUF_SIZE 2048 87 | #define ADPCM_READ_BUFFER_SIZE 156 88 | -------------------------------------------------------------------------------- /components/encoders/opus/opusenc_cei.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __OPUSENC_CEI_H__ 8 | #define __OPUSENC_CEI_H__ 9 | 10 | #include 11 | #include "cei.h" 12 | 13 | int OPUSEncoderGetMemorySize(uint8_t channels); 14 | int OPUSEncoderInit(void *memory, uint32_t sampleRate, uint8_t channels); 15 | int OPUSEncoderGetConfig(void *memory, void *config); 16 | int OPUSEncoderSetConfig(void *memory, void *config); 17 | int OPUSEncoderEncode(void *memory, BufferInfo *source, BufferInfo *dest); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | ARG ZEPHYR_SDK_VERSION=0.16.4 4 | ARG ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION} 5 | ARG ZEPHYR_SDK_TOOLCHAINS="-t arm-zephyr-eabi" 6 | 7 | # OS dependencies and packages 8 | 9 | RUN \ 10 | apt-get -y update \ 11 | && apt-get -y install --no-install-recommends \ 12 | ca-certificates \ 13 | cmake \ 14 | device-tree-compiler \ 15 | git \ 16 | ninja-build \ 17 | && apt-get clean \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | # Zephyr SDK 21 | 22 | RUN \ 23 | export sdk_file_name="zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-$(uname -m)_minimal.tar.xz" \ 24 | && apt-get -y update \ 25 | && apt-get -y install --no-install-recommends \ 26 | wget \ 27 | xz-utils \ 28 | && wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${sdk_file_name}" \ 29 | && mkdir -p ${ZEPHYR_SDK_INSTALL_DIR} \ 30 | && tar -xvf ${sdk_file_name} -C ${ZEPHYR_SDK_INSTALL_DIR} --strip-components=1 \ 31 | && ${ZEPHYR_SDK_INSTALL_DIR}/setup.sh -c ${ZEPHYR_SDK_TOOLCHAINS} \ 32 | && rm ${sdk_file_name} \ 33 | && apt-get remove -y --purge \ 34 | wget \ 35 | xz-utils \ 36 | && apt-get clean \ 37 | && rm -rf /var/lib/apt/lists/* 38 | 39 | # Python 40 | 41 | ENV VIRTUAL_ENV=/opt/venv 42 | RUN \ 43 | apt-get -y update \ 44 | && apt-get -y install --no-install-recommends \ 45 | python3 \ 46 | python3-pip \ 47 | python3-venv \ 48 | && python3 -m venv $VIRTUAL_ENV 49 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 50 | 51 | # West 52 | 53 | RUN pip install --no-cache-dir wheel west pyelftools anytree psutil pyserial natsort pytest ply tabulate 54 | 55 | # Zephyr 56 | 57 | #RUN \ 58 | # west init \ 59 | # && cd zephyr \ 60 | # && west update hal_nxp \ 61 | # && west update cmsis 62 | 63 | -------------------------------------------------------------------------------- /doxygen/.gitignore: -------------------------------------------------------------------------------- 1 | generated/ -------------------------------------------------------------------------------- /doxygen/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: clean rf 3 | 4 | rf: clean 5 | if test -d "../docs/src"; then rm -rf ../docs/src; fi 6 | mkdir generated 7 | mkdir ../docs/src 8 | doxygen Doxyfile_RM 9 | cp -a generated/refMan/html/. ../docs/src/ 10 | 11 | pdf: clean 12 | make -C generated/refMan/latex pdf 13 | cp generated/refMan/latex/refman.pdf MaestroRM.pdf 14 | 15 | clean: 16 | rm -rf generated/ -------------------------------------------------------------------------------- /doxygen/common/arm_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/doxygen/common/arm_logo.png -------------------------------------------------------------------------------- /doxygen/common/codec_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/doxygen/common/codec_flow.png -------------------------------------------------------------------------------- /doxygen/common/customdoxygen.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | color: #51626f; 4 | } 5 | 6 | body, table, div, p, dl { 7 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 8 | } 9 | 10 | .title { 11 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 12 | } 13 | 14 | .textblock ul { 15 | list-style: none outside url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAF0lEQVQIHWP8uZXhPwMWwIRFDCxEDwkAjygCuZMRiw4AAAAASUVORK5CYII="); 16 | } 17 | 18 | h1, h2.groupheader { 19 | color: #51626f; 20 | font-size: 21px; 21 | } 22 | 23 | h1 { 24 | font-weight: 600; 25 | } 26 | 27 | h2 { 28 | font-size: 18px; 29 | } 30 | 31 | .tablist a, 32 | .tablist a:hover { 33 | text-shadow: none; 34 | background-image: none; 35 | } 36 | 37 | .tablist a { 38 | color: #ffffff; 39 | } 40 | 41 | .tablist a:hover { 42 | background-color: #f2f2f5; 43 | color: #007088; 44 | } 45 | 46 | .tablist li.current a { 47 | text-shadow: none; 48 | background-image: none; 49 | background-color: #ffffff; 50 | color: #777777; 51 | } 52 | 53 | .navpath ul { 54 | background-image: none; 55 | background-color: #e6e6e6; 56 | color: #646464; 57 | } 58 | 59 | .tabs, .tabs2, .tabs3, 60 | .tablist li { 61 | background: rgba(0, 0, 0, 0) linear-gradient(to bottom, #f1b635, #e4942a) repeat scroll 0 0; 62 | } 63 | 64 | a { 65 | color: #5e89c1; 66 | } 67 | 68 | #nav-tree .selected { 69 | text-shadow: none; 70 | background-image: none; 71 | background-color: #e6e6e6; 72 | color: #646464; 73 | } 74 | 75 | #nav-tree .selected a { 76 | color: #646464; 77 | } 78 | 79 | #titlearea { 80 | border-bottom: 1px solid #51626f; 81 | } 82 | 83 | #projectname { 84 | font: 32px "Helvetica Neue", Helvetica, Arial; 85 | } 86 | 87 | div.image img[src="Kinetis_SDK_Block_Diagram.png"]{ 88 | width:600px; 89 | } 90 | 91 | .image { 92 | text-align: center; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /doxygen/common/fs_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/doxygen/common/fs_logo.gif -------------------------------------------------------------------------------- /doxygen/common/nxp_logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/doxygen/common/nxp_logo_small.png -------------------------------------------------------------------------------- /doxygen/common/template/contact.tex: -------------------------------------------------------------------------------- 1 | \begin{flushleft}\textbf{\textsf{\slshape{How to Reach Us\-:}}}\\[6pt] 2 | \textbf{\textsf{Home Page\-:}}\\ 3 | \url{http://www.nxp.com} \\[6pt] 4 | \textbf{\textsf{Web Support\-:}}\\ 5 | \url{http://www.nxp.com/support} 6 | \end{flushleft} -------------------------------------------------------------------------------- /doxygen/common/template/copyright_attribution.tex: -------------------------------------------------------------------------------- 1 | \begin{flushleft} 2 | \textsf{Information in this document is provided solely to enable system and software implementers to use NXP products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits based on the information in this document.}\newline 3 | 4 | \textsf{NXP makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does NXP assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in NXP data sheets and/or specifications can and do vary in different applications, and actual performance may vary over time. All operating parameters, including “typicals,” must be validated for each customer application by customer's technical experts. NXP does not convey any license under its patent rights nor the rights of others. NXP sells products pursuant to standard terms and conditions of sale, which can be found at the following address: \url{http://www.nxp.com/SalesTermsandConditions}.} \newline 5 | 6 | \textsf{While NXP has implemented advanced security features, all products may be subject to unidentified vulnerabilities. Customers are responsible for the design and operation of their applications and products to reduce the effect of these vulnerabilities on customer's applications and products, and NXP accepts no liability for any vulnerability that is discovered. Customers should implement appropriate design and operating safeguards to minimize the risks associated with their applications and products.} \newline 7 | 8 | 9 | \textsf{NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD, Freescale, the Freescale logo, Kinetis, Processor Expert, and Tower are trademarks of NXP B.V. All other product or service names are the property of their respective owners. Arm, Cortex, Keil, Mbed, Mbed Enabled, and ~{\textmu}Vision are trademarks or registered trademarks of Arm Limited (or its subsidiaries) in the US and/or elsewhere. The related technology may be protected by any or all of patents, copyrights, designs and trade secrets. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. The Power Architecture and Power.org word marks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org.} \newline 10 | 11 | \textsf{ 12 | \copyright~2020-2023 NXP B.V.} 13 | \end{flushleft} 14 | 15 | 16 | -------------------------------------------------------------------------------- /doxygen/common/template/footer_def.tex: -------------------------------------------------------------------------------- 1 | % Latex footer for doxygen 1.8.20 2 | %--- End generated contents --- 3 | 4 | % Index 5 | \backmatter 6 | \newpage 7 | \phantomsection 8 | \clearemptydoublepage 9 | \addcontentsline{toc}{chapter}{\indexname} 10 | \printindex 11 | 12 | \newpage 13 | \input{copyright_attribution} 14 | \input{contact} 15 | 16 | \end{document} 17 | -------------------------------------------------------------------------------- /doxygen/common/template/header_def.tex: -------------------------------------------------------------------------------- 1 | % Latex header for doxygen 1.8.20 2 | \let\mypdfximage\pdfximage\def\pdfximage{\immediate\mypdfximage}\documentclass[twoside]{book} 3 | 4 | %% moved from doxygen.sty due to workaround for LaTex 2019 version and unmaintained tabu package 5 | \usepackage{ifthen} 6 | \ifx\requestedLaTeXdate\undefined 7 | \usepackage{array} 8 | \else 9 | \usepackage{array}[=2016-10-06] 10 | \fi 11 | %% 12 | % Packages required by doxygen 13 | \usepackage{fixltx2e} 14 | \usepackage{calc} 15 | \usepackage{doxygen} 16 | \usepackage{graphicx} 17 | \usepackage[utf8]{inputenc} 18 | \usepackage{makeidx} 19 | \usepackage{multicol} 20 | \usepackage{multirow} 21 | \PassOptionsToPackage{warn}{textcomp} 22 | \usepackage{textcomp} 23 | \usepackage[nointegrals]{wasysym} 24 | \usepackage[table]{xcolor} 25 | \usepackage{ifpdf,ifxetex} 26 | 27 | % Font selection 28 | \usepackage[T1]{fontenc} 29 | \usepackage[scaled=.90]{helvet} 30 | \usepackage{courier} 31 | \renewcommand{\familydefault}{\sfdefault} 32 | \usepackage{amssymb} 33 | \usepackage{sectsty} 34 | \allsectionsfont{% 35 | \fontseries{bc}\selectfont% 36 | \color{darkgray}% 37 | } 38 | \renewcommand{\DoxyLabelFont}{% 39 | \fontseries{bc}\selectfont% 40 | \color{darkgray}% 41 | } 42 | \newcommand{\+}{\discretionary{\mbox{\scriptsize$\hookleftarrow$}}{}{}} 43 | 44 | % Arguments of doxygenemoji: 45 | % 1) '::' form of the emoji, already "LaTeX"-escaped 46 | % 2) file with the name of the emoji without the .png extension 47 | % in case image exist use this otherwise use the '::' form 48 | \newcommand{\doxygenemoji}[2]{% 49 | \IfFileExists{./#2.png}{\raisebox{-0.1em}{\includegraphics[height=0.9em]{./#2.png}}}{#1}% 50 | } 51 | % Page & text layout 52 | \usepackage{geometry} 53 | \geometry{% 54 | a4paper,% 55 | top=2.5cm,% 56 | bottom=2.5cm,% 57 | left=2.5cm,% 58 | right=2.5cm% 59 | } 60 | \tolerance=750 61 | \hfuzz=15pt 62 | \hbadness=750 63 | \setlength{\emergencystretch}{15pt} 64 | \setlength{\parindent}{0cm} 65 | \newcommand{\doxynormalparskip}{\setlength{\parskip}{3ex plus 2ex minus 2ex}} 66 | \newcommand{\doxytocparskip}{\setlength{\parskip}{1ex plus 0ex minus 0ex}} 67 | \doxynormalparskip 68 | \makeatletter 69 | \renewcommand{\paragraph}{% 70 | \@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{% 71 | \normalfont\normalsize\bfseries\SS@parafont% 72 | }% 73 | } 74 | \renewcommand{\subparagraph}{% 75 | \@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{% 76 | \normalfont\normalsize\bfseries\SS@subparafont% 77 | }% 78 | } 79 | \makeatother 80 | 81 | \makeatletter 82 | \newcommand\hrulefilll{\leavevmode\leaders\hrule\hskip 0pt plus 1filll\kern\z@} 83 | \makeatother 84 | 85 | % Headers & footers 86 | \usepackage{fancyhdr} 87 | \pagestyle{fancyplain} 88 | \fancyhead[LE]{\fancyplain{}{\bfseries\thepage}} 89 | \fancyhead[CE]{\fancyplain{}{}} 90 | \fancyhead[RE]{\fancyplain{}{\bfseries\leftmark}} 91 | \fancyhead[LO]{\fancyplain{}{\bfseries\rightmark}} 92 | \fancyhead[CO]{\fancyplain{}{}} 93 | \fancyhead[RO]{\fancyplain{}{\bfseries\thepage}} 94 | \fancyfoot[LE]{\fancyplain{}{}} 95 | \fancyfoot[CE]{\fancyplain{}{}} 96 | \fancyfoot[RE]{\fancyplain{}{\bfseries\scriptsize NXP Semiconductors }} 97 | \fancyfoot[LO]{\fancyplain{}{\bfseries\scriptsize NXP Semiconductors }} 98 | \fancyfoot[CO]{\fancyplain{}{}} 99 | \fancyfoot[RO]{\fancyplain{}{}} 100 | \renewcommand{\footrulewidth}{0.4pt} 101 | \renewcommand{\chaptermark}[1]{% 102 | \markboth{#1}{}% 103 | } 104 | \renewcommand{\sectionmark}[1]{% 105 | \markright{\thesection\ #1}% 106 | } 107 | 108 | % Indices & bibliography 109 | \usepackage{natbib} 110 | \usepackage[titles]{tocloft} 111 | \setcounter{tocdepth}{3} 112 | \setcounter{secnumdepth}{5} 113 | \makeindex 114 | 115 | \usepackage{newunicodechar} 116 | \newunicodechar{⁻}{${}^{-}$}% Superscript minus 117 | \newunicodechar{²}{${}^{2}$}% Superscript two 118 | \newunicodechar{³}{${}^{3}$}% Superscript three 119 | 120 | % Hyperlinks (required, but should be loaded last) 121 | \ifpdf 122 | \usepackage[pdftex,pagebackref=true]{hyperref} 123 | \else 124 | \ifxetex 125 | \usepackage[pagebackref=true]{hyperref} 126 | \else 127 | \usepackage[ps2pdf,pagebackref=true]{hyperref} 128 | \fi 129 | \fi 130 | 131 | \hypersetup{% 132 | colorlinks=true,% 133 | linkcolor=blue,% 134 | citecolor=blue,% 135 | unicode% 136 | } 137 | 138 | % Custom commands 139 | \newcommand{\clearemptydoublepage}{% 140 | \newpage{\pagestyle{empty}\cleardoublepage}% 141 | } 142 | 143 | \usepackage{caption} 144 | \captionsetup{labelsep=space,justification=centering,font={bf},singlelinecheck=off,skip=4pt,position=top} 145 | 146 | \usepackage{etoc} 147 | \etocsettocstyle{\doxytocparskip}{\doxynormalparskip} 148 | \renewcommand{\numberline}[1]{#1~} 149 | %===== C O N T E N T S ===== 150 | 151 | \begin{document} 152 | 153 | % Titlepage & ToC 154 | \hypersetup{pageanchor=false, 155 | bookmarksnumbered=true, 156 | pdfencoding=unicode 157 | } 158 | \pagenumbering{alph} 159 | \begin{titlepage} 160 | \vspace*{7cm} 161 | \begin{center}% 162 | {\Large Maestro Audio Solutions Reference Manual}\\ 163 | \vspace*{1cm} 164 | {\large v 1.0}\\ 165 | \vspace*{1cm} 166 | {\large NXP Semiconductors}\\ 167 | \end{center} 168 | \end{titlepage} 169 | \clearemptydoublepage 170 | \pagenumbering{roman} 171 | \tableofcontents 172 | \clearemptydoublepage 173 | \pagenumbering{arabic} 174 | \hypersetup{pageanchor=true} 175 | 176 | %--- Begin generated contents --- 177 | -------------------------------------------------------------------------------- /doxygen/common/trademarks/new_footer-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 15 | 16 | 17 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /doxygen/common/trademarks/new_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $projectname: $title 10 | $title 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | $treeview 26 | $search 27 | $mathjax 28 | $darkmode 29 | 30 | $extrastylesheet 31 | 32 | 33 | 34 | 35 | 36 |
37 | 38 | 39 | 40 |
41 | 42 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
52 |
$projectname $projectnumber 53 |
54 |
$projectbrief
55 |
60 |
$projectbrief
61 |
$searchbox
$searchbox
79 |
80 | 81 | 82 | -------------------------------------------------------------------------------- /doxygen/supported_features.md: -------------------------------------------------------------------------------- 1 | # Supported features 2 | 3 | The current version of the audio framework supports several optional features. These can be limited to some MCU cores or development boards variants. More information about support can be found on the specific example page: 4 | - [maestro_playback](maestro_playback.md) 5 | - [maestro_record](maestro_record.md) 6 | - [maestro_usb_mic](maestro_usb_mic.md) 7 | - [maestro_usb_speaker](maestro_usb_speaker.md) 8 | - [maestro_sync](maestro_sync.md) 9 | 10 | Some features are delivered as prebuilt library and the binaries can be found in the `\middleware\audio_voice\components\*component*\libs` folder. The source code of some features can be found in the `\middleware\audio_voice\maestro\src` folder. 11 | 12 | ## Decoders 13 | 14 | Supported decoders and its options are: 15 | 16 | | Decoder | Sample rates [kHz] | Number of channels | Bit depth | 17 | |-----------------------|---------------------------------------------------------------|-----------------------------------|---------------------------| 18 | | AAC | 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48 | 1, 2 (mono/stereo) | 16 | 19 | | FLAC | 8, 11.025, 12, 16, 22.05, 32, 44.1, 48 | 1, 2 (mono/stereo) | 16 | 20 | | MP3 | 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48 | 1, 2 (mono/stereo) | 16 | 21 | | OPUS | 8, 16, 24, 48 | 1, 2 (mono/stereo) | 16 | 22 | | WAV | 8, 11.025, 16, 22.05, 32, 44.1, 48 | 1, 2 (mono/stereo) | 8, 16, 24 | 23 | 24 | For more details about the reference decoders please see audio-voice-components repository documentation `\middleware\audio_voice\components\`. 25 | 26 | ## Encoders 27 | 28 | - **OPUS encoder** - The current verion of the audio framework only supports a OPUS encoder. For more details about the encoder please see the following [link](https://opus-codec.org/docs/opus_api-1.3.1/). 29 | 30 | ## Sample rate converters 31 | 32 | - **SSRC** - Synchronous sample rate converter. More details about SSRC are available in the User Guide, which is located in `middleware\audio_voice\components\ssrc\doc\`. 33 | 34 | - **ASRC** - Asynchronous sample rate converter is not used in our examples, but it is part of the maestro middleware and can be enabled. To enable ASRC, the `maestro_framework_asrc` and `CMSIS_DSP_Library_Source` components must be added to the project. Furthermore, it is necessary to switch from Redlib to Newlib (semihost) library and add a platform definition to the project (e.g. for RT1170: `PLATFORM_RT1170_CORTEXM7`). Supported platforms can be found in the `PL_platformTypes.h` file. More details about ASRC are available in the User Guide, which is located in `middleware\audio_voice\components\asrc\doc\`. 35 | 36 | ## Additional libraries 37 | 38 | - **VIT** - Voice Intelligent Technology (VIT) Wake Word and Voice Command Engines provide free, ready to use voice UI enablement for developers. It enables customer-defined wake words and commands using free online tools. More details about VIT are available in the VIT package, which is located in `middleware\audio_voice\components\vit\{platform}\Doc\`(depending on the platform) or via following [link](https://nxp.com/vit). 39 | 40 | - **VoiceSeeker** - VoiceSeeker is a multi-microphone voice control audio front-end signal processing solution. More details about VoiceSeeker are available in the VoiceSeeker package, which is located in `middleware\audio_voice\components\voice_seeker\{platform}\Doc\`(depending on the platform) or via following [link](https://nxp.com/voiceseeker). 41 | -------------------------------------------------------------------------------- /doxygen/test_48khz_16bit_2ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/doxygen/test_48khz_16bit_2ch.wav -------------------------------------------------------------------------------- /src/cci/inc/codec_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /*! @file codec_interface.h 8 | * @brief Contains codec interface definitions. 9 | */ 10 | #ifndef __CODEC_INTERFACE_H__ 11 | #define __CODEC_INTERFACE_H__ 12 | 13 | /* 14 | * Includes 15 | */ 16 | #include "codec_interface_public_api.h" 17 | #if defined(__cplusplus) 18 | extern "C" { 19 | #endif 20 | /* 21 | * Structure 22 | */ 23 | 24 | /*! 25 | * @brief Declares codec_get_memory_sizes_function_t as a ptr to a function that 26 | * calls codec get memory size 27 | */ 28 | typedef int32_t (*codec_get_memory_sizes_function_t)(void); 29 | /*! 30 | * @brief Declares codec_init_function_t as a pointer to a function that calls 31 | * codec init 32 | */ 33 | typedef int32_t (*codec_init_function_t)(int32_t *memory[], int32_t *callback_fn[], int32_t *user_data); 34 | /*! 35 | * @brief Declares codec_decode_function_t as a pointer to a function that calls 36 | * codec decode 37 | */ 38 | typedef int32_t (*codec_decode_function_t)(int32_t *memory[], int32_t *sample_produced, int32_t *buf_out); 39 | /*! 40 | * @brief Declares codec_get_pcm_samples_function_t as a ptr to a function that 41 | * calls codec get pcm samples 42 | */ 43 | typedef int32_t (*codec_get_pcm_samples_function_t)(int32_t *memory[], 44 | int32_t *sample_produced, 45 | int32_t max_sample, 46 | int32_t *buf_out); 47 | /*! 48 | * @brief Declares codec_reset_function_t as a pointer to a function that calls 49 | * codec reset 50 | */ 51 | typedef int32_t (*codec_reset_function_t)(int32_t *memory[]); 52 | /*! 53 | * @brief Declares codec_file_seek_function_t as a pointer to a function that 54 | * calls codec seek 55 | */ 56 | typedef int32_t (*codec_file_seek_function_t)(int32_t *memory[], int32_t seek_offset); 57 | /*! 58 | * @brief Declares codec_get_input_frame_size_function_t as a ptr to a 59 | * function that calls codec get input frame size 60 | */ 61 | typedef int32_t (*codec_get_io_frame_size_function_t)(int32_t *in_size, int32_t *out_size); 62 | 63 | /*! 64 | * @brief Codec Interface Function Table 65 | */ 66 | typedef struct _codec_interface_function_table 67 | { 68 | codec_get_memory_sizes_function_t GetMemorySizes; /*!< @brief get size of 69 | required memory for codec*/ 70 | codec_init_function_t Init; /*!< @brief Initialization of Codec*/ 71 | codec_decode_function_t Decode; /*!< @brief Decoding of codec*/ 72 | codec_get_pcm_samples_function_t GetPcmSamples; /*!< @brief get pcm samples 73 | for codec*/ 74 | codec_reset_function_t Reset; /*!< @brief reset codec*/ 75 | codec_file_seek_function_t FileSeek; /*!< @brief seek at specific 76 | offset*/ 77 | codec_get_io_frame_size_function_t GetIOFrameSize; /*!< @brief Get io frame size*/ 78 | } codec_interface_function_table_t; 79 | 80 | /* 81 | * External Definitions 82 | */ 83 | extern const codec_interface_function_table_t g_codec_function_table[STREAM_TYPE_COUNT]; 84 | 85 | /* MP3 */ 86 | #ifdef MP3_DEC 87 | #include "mp3_cci.h" 88 | #endif 89 | 90 | /* WAV */ 91 | #ifdef WAV_DEC 92 | #include "wav_cci.h" 93 | #endif 94 | 95 | /* FLAC */ 96 | #ifdef FLAC_DEC 97 | #include "flac_cci.h" 98 | #endif 99 | 100 | /* AAC */ 101 | #if defined(AAC_DEC) && !defined(__ICCARM__) 102 | #include "aac_cci.h" 103 | #endif 104 | 105 | #ifdef OPUS_DEC 106 | #include "opus_cci_raw.h" 107 | #endif 108 | 109 | #ifdef OGG_OPUS_DEC 110 | #include "opus_cci.h" 111 | #endif 112 | 113 | #if defined(__cplusplus) 114 | } 115 | #endif 116 | 117 | #endif /* __CODEC_INTERFACE_H__ */ 118 | -------------------------------------------------------------------------------- /src/cci/inc/errordefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /*! @file errordefs.h 8 | * @brief Contains error codes. 9 | * 10 | */ 11 | 12 | #ifndef _ERRORDEFS_H 13 | #define _ERRORDEFS_H 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif 18 | 19 | #ifndef __LANGUAGE_ASM__ 20 | /** 21 | * @brief Return status 22 | * 23 | */ 24 | typedef int RtStatus_t; 25 | #endif 26 | /** 27 | * @brief Status success 28 | * 29 | */ 30 | #define SUCCESS (0) 31 | /** 32 | * @brief Generic error 33 | * 34 | */ 35 | #define ERROR_GENERIC (-1) 36 | 37 | #if defined(__cplusplus) 38 | } 39 | #endif 40 | 41 | #endif /* _ERRORDEFS_H */ 42 | -------------------------------------------------------------------------------- /src/cci/src/codecextractmetadata.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /*! 8 | * @file codecextractmetadata.c 9 | * @brief This file Contains functionality that determines the file type and 10 | * then calls the proper extract meta_data function 11 | * 12 | */ 13 | 14 | /* 15 | * Includes 16 | */ 17 | #include "codec_interface_public_api.h" 18 | #include "audio_cfg.h" 19 | #include "cci_metadata.h" 20 | 21 | /* 22 | * Functions 23 | */ 24 | 25 | int32_t ccidec_extract_meta_data(audio_stream_type_t stream_type, file_meta_data_t *meta_data, CCI_Ctx *ctx) 26 | { 27 | uint8_t ret = CODEC_METADATA_FILETYPE_FAILED; 28 | 29 | switch (stream_type) 30 | { 31 | #ifdef WAV_DEC 32 | case STREAM_TYPE_PCM: 33 | case STREAM_TYPE_MSADPCM: 34 | case STREAM_TYPE_IMAADPCM: 35 | ret = (uint8_t)codec_extract_metadata_wave(meta_data, ctx); 36 | break; 37 | #endif 38 | #ifdef MP3_DEC 39 | case STREAM_TYPE_MP3: 40 | ret = (uint8_t)codec_extract_metadata_mp3(meta_data, ctx); 41 | break; 42 | #endif 43 | #ifdef OPUS_DEC 44 | case STREAM_TYPE_OPUS: 45 | ret = codec_extract_metadata_opus(meta_data, ctx); 46 | break; 47 | #endif /* OPUS_DEC */ 48 | 49 | #ifdef OGG_OPUS_DEC 50 | case STREAM_TYPE_OGG_OPUS: 51 | ret = codec_extract_metadata_ogg_opus(meta_data, ctx); 52 | break; 53 | #endif /* OGG_OPUS_DEC */ 54 | #if defined(AAC_DEC) && !defined(__ICCARM__) 55 | case STREAM_TYPE_AAC: 56 | ret = (uint8_t)codec_extract_metadata_aac(meta_data, ctx); 57 | break; 58 | #endif 59 | #ifdef FLAC_DEC 60 | case STREAM_TYPE_FLAC: 61 | ret = (uint8_t)codec_extract_metadata_flac(meta_data, ctx); 62 | break; 63 | #endif 64 | default: 65 | /* Unknown Audio Stream Type (kCodecStreamTypeUnknown) */ 66 | break; 67 | } 68 | 69 | return (ret); 70 | } 71 | 72 | /* 73 | * End of file 74 | * @} 75 | */ 76 | -------------------------------------------------------------------------------- /src/cei/inc/cei.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __CEI_H__ 8 | #define __CEI_H__ 9 | 10 | #include 11 | #include 12 | 13 | /** 14 | * @file cei.h 15 | * @brief Common encoder interface API prototypes 16 | * 17 | */ 18 | 19 | /** 20 | * @brief Common encoder error 21 | * 22 | */ 23 | #define CEI_ENCODER_ENCODEERR -1 24 | 25 | /** 26 | * @brief Holds buffer information, 27 | */ 28 | typedef struct 29 | { 30 | void *ptr; /*!< @brief Buffer pointer */ 31 | uint32_t size; /*!< @brief Buffer length */ 32 | } BufferInfo; 33 | 34 | /** 35 | * @brief Defines a function returning a memory size to be allocated. 36 | * 37 | * @param channels Number of channels, which the encoder will encode. 38 | * @return The number of bytes to be allocated. 39 | */ 40 | typedef int (*CeiFnGetMemorySize)(uint8_t channels); 41 | 42 | /** 43 | * @brief Defines a function initializing an encoder. 44 | * 45 | * @param memory Pointer to memory previously allocated to hold encoder structures. 46 | * @param sampleRate The source sample rate. 47 | * @param channels Number of channels which the encoder will encode. 48 | * 49 | * @returns 0 if encoder was initialized successfully, anything other otherwise. 50 | */ 51 | typedef int (*CeiFnEncoderInit)(void *memory, uint32_t sampleRate, uint8_t channels); 52 | 53 | /** 54 | * @brief Defines a function retrieving encoder configuration. 55 | * 56 | * @param memory Pointer to previously allocated memory with encoder structures. Can be NULL if default configuration is 57 | * desired. 58 | * @param config Pointer to an encoder-specific configuration structure. 59 | * 60 | * @returns 0 if configuration gathered successfully, anything other otherwise. 61 | */ 62 | typedef int (*CeiFnEncoderGetConfig)(void *memory, void *config); 63 | 64 | /** 65 | * @brief Defines a function applying configuration to an encoder. 66 | * 67 | * @param memory Pointer to previously allocated memory with encoder structures. 68 | * @param config Pointer to an encoder-specific configuration structure. 69 | * 70 | * @returns 0 if configuration applied successfully, anything other otherwise. 71 | */ 72 | typedef int (*CeiFnEncoderSetConfig)(void *memory, void *config); 73 | 74 | /** 75 | * @brief Defines a function which encodes data in a given input buffer to a given output buffer. Input buffer will 76 | * contain 16-bit signed interleaved little-endian samples (s16le). 77 | * 78 | * @param memory Pointer to previously allocated memory with encoder structures. 79 | * @param source Contains information about the input buffer. 80 | * @param dest Contains information about the output buffer. 81 | * 82 | * @returns Number of produced bytes or CEI_ENCODER_ENCODEERR. 0 constitutes an EOS condition. 83 | */ 84 | typedef int (*CeiFnEncode)(void *memory, BufferInfo *source, BufferInfo *dest); 85 | 86 | /** 87 | * @brief Common encoder interface function pointers 88 | * 89 | */ 90 | typedef struct 91 | { 92 | CeiFnGetMemorySize fnGetMemorySize; /*!< @brief Get memory size function pointer */ 93 | CeiFnEncoderInit fnInit; /*!< @brief Init function pointer */ 94 | CeiFnEncoderGetConfig fnGetConfig; /*!< @brief Get config function pointer */ 95 | CeiFnEncoderSetConfig fnSetConfig; /*!< @brief Set config function pointer */ 96 | CeiFnEncode fnEncode; /*!< @brief Encode function pointer */ 97 | } CeiEncoderFunctions; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/cei/inc/cei_enctypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __CEI_ENCTYPES_H__ 8 | #define __CEI_ENCTYPES_H__ 9 | 10 | /** 11 | * @file cei_enctypes.h 12 | * @brief Basic common encoder interface types, information, configuration structures 13 | * 14 | */ 15 | 16 | /** 17 | * @brief Encoder types 18 | * 19 | */ 20 | typedef enum 21 | { 22 | CEIENC_OPUS, 23 | CEIENC_LAST 24 | } CeiEncoderType; 25 | 26 | /** 27 | * @brief Bitstream info 28 | * 29 | */ 30 | typedef struct 31 | { 32 | uint32_t sample_rate; /*!< @brief Bitstream sample rate */ 33 | uint8_t num_channels; /*!< @brief Bitstream number of channels */ 34 | uint8_t endian; /*!< @brief Bitstream endianness */ 35 | uint8_t sign; /*!< @brief Bitstream sign */ 36 | uint8_t sample_size; /*!< @brief Bitstream sample size */ 37 | uint8_t interleaved; /*!< @brief Bitstream interleaved */ 38 | } CeiBitstreamInfo; 39 | 40 | /** 41 | * @brief Opus configuration 42 | * 43 | */ 44 | typedef struct 45 | { 46 | int32_t complexity; /*!< @brief Opus complexity */ 47 | int32_t bitrate; /*!< @brief Opus bitrate */ 48 | int32_t vbr; /*!< @brief Opus variable bit rate */ 49 | int32_t vbrConstraint; /*!< @brief Opus VBR constraint */ 50 | int32_t forceChannels; /*!< @brief Opus force channels */ 51 | int32_t maxBandwidth; /*!< @brief Opus maximum bandwidth */ 52 | int32_t bandwidth; /*!< @brief Opus bandwidth */ 53 | int32_t application; /*!< @brief Opus application */ 54 | int32_t inbandFec; /*!< @brief Opus inband FEC */ 55 | int32_t packetLossPerc; /*!< @brief Opus packet loss percent for FEC */ 56 | int32_t dtx; /*!< @brief Opus discontinuous transmission */ 57 | int32_t lsbDepth; /*!< @brief Opus depth of signal being encoded */ 58 | int32_t expertFrameDuration; /*!< @brief Opus variable duration frames */ 59 | int32_t predictionDisabled; /*!< @brief Opus prediction disabled */ 60 | } CeiOpusConfig; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/cei/inc/cei_table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __CEI_TABLE_H__ 8 | #define __CEI_TABLE_H__ 9 | 10 | /** 11 | * @file cei_table.h 12 | * @brief Static tables for encoder functions, sizes 13 | */ 14 | 15 | #include 16 | #include "cei.h" 17 | #include "cei_enctypes.h" 18 | 19 | #ifdef STREAMER_ENABLE_CEI_OPUS 20 | #include "opusenc_cei.h" 21 | #endif 22 | 23 | /** 24 | * @brief Common encoder interface function pointer table 25 | * 26 | */ 27 | static const CeiEncoderFunctions ceiEncTable[CEIENC_LAST] = { 28 | #ifdef STREAMER_ENABLE_CEI_OPUS 29 | // CEIENC_OPUS 30 | {.fnGetMemorySize = &OPUSEncoderGetMemorySize, 31 | .fnInit = &OPUSEncoderInit, 32 | .fnGetConfig = &OPUSEncoderGetConfig, 33 | .fnSetConfig = &OPUSEncoderSetConfig, 34 | .fnEncode = &OPUSEncoderEncode} 35 | #else 36 | {0} 37 | #endif 38 | }; 39 | 40 | /** 41 | * @brief Common encoder interface config size table 42 | * 43 | */ 44 | static const size_t ceiEncConfigSizeTable[CEIENC_LAST] = { 45 | #ifdef STREAMER_ENABLE_CEI_OPUS 46 | sizeof(CeiOpusConfig) // CEIENC_OPUS 47 | #else 48 | 0 49 | #endif 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/devices/audio_sink_default.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef AUDIO_SINK_DEFAULT_H 8 | #define AUDIO_SINK_DEFAULT_H 9 | 10 | /*! 11 | * @file audio_sink_default.h 12 | * @brief This file contains the definitions for the 13 | * PCM manager Audio Sink Interface 14 | */ 15 | 16 | #include "audio_sink.h" 17 | 18 | #include "streamer_pcm.h" 19 | 20 | /** 21 | * @brief Audio sink buffer number 22 | * 23 | */ 24 | #if !defined(AUDIO_SINK_BUFFER_NUM) 25 | #if defined(SAI_XFER_QUEUE_SIZE) 26 | #define AUDIO_SINK_BUFFER_NUM (SAI_XFER_QUEUE_SIZE + 1) 27 | #elif defined(I2S_NUM_BUFFERS) 28 | #define AUDIO_SINK_BUFFER_NUM (I2S_NUM_BUFFERS + 1) 29 | #else 30 | #define AUDIO_SINK_BUFFER_NUM (3) 31 | #endif 32 | #endif 33 | 34 | /** 35 | * @brief Minimum audio buffer size 36 | * 37 | */ 38 | #define MIN_AUDIO_BUFFER_SIZE (4 * 1024U) 39 | /** 40 | * @brief Buffer size alignment 41 | * 42 | */ 43 | #define SIZE_ALIGNMENT 32U 44 | 45 | /** 46 | * @brief PCM Sink device information 47 | * 48 | */ 49 | typedef struct _DefaultSinkDeviceInfo 50 | { 51 | char *unaligned_buf[AUDIO_SINK_BUFFER_NUM]; /*!< @brief Pointers to unaligned audio buffers */ 52 | char *audbuf[AUDIO_SINK_BUFFER_NUM]; /*!< @brief Pointers to aligned audio buffers */ 53 | uint32_t alloc_size; /*!< @brief Unaligned_buf allocated size */ 54 | uint32_t input_size; /*!< @brief Input size */ 55 | uint8_t input_index; /*!< @brief Input index */ 56 | uint8_t device_state; /*!< @brief Device state */ 57 | bool init_params_done; /*!< @brief Initialization done flag */ 58 | bool resample; /*!< @brief Resampling flag */ 59 | } DefaultSinkDeviceInfo; 60 | 61 | /** 62 | * @brief Audio sink default init parameters 63 | * 64 | * @param audio_sink_ptr Audio sink pointer 65 | * @return AudioSinkStreamErrorType 66 | */ 67 | AudioSinkStreamErrorType audiosink_default_init_params(ElementAudioSink *audio_sink_ptr); 68 | 69 | /** 70 | * @brief Audio sink default init device 71 | * 72 | * @param audio_sink_ptr Audio sink pointer 73 | * @return AudioSinkStreamErrorType 74 | */ 75 | AudioSinkStreamErrorType audiosink_default_init_device(ElementAudioSink *audio_sink_ptr); 76 | 77 | /** 78 | * @brief Audio sink default deinit device 79 | * 80 | * @param audio_sink_ptr Audio sink pointer 81 | * @return AudioSinkStreamErrorType 82 | */ 83 | AudioSinkStreamErrorType audiosink_default_deinit_device(ElementAudioSink *audio_sink_ptr); 84 | 85 | /** 86 | * @brief Audio sink default sink pad activation handler 87 | * 88 | * @param pad Pad to be activated/deactivated 89 | * @param active Activate/deactivate 90 | * @return uint8_t 91 | */ 92 | uint8_t audiosink_default_sink_pad_activation_handler(StreamPad *pad, uint8_t active); 93 | 94 | /** 95 | * @brief Audio sink default sink pad chain handler 96 | * @details Handle the data buffer and send it to the appropriate audio device 97 | * 98 | * @param pad Pad pointer 99 | * @param buffer Buffer pointer 100 | * @return FlowReturn 101 | */ 102 | FlowReturn audiosink_default_sink_pad_chain_handler(StreamPad *pad, StreamBuffer *buffer); 103 | 104 | /** 105 | * @brief Audio sink default pad event handler 106 | * 107 | * @param pad Pad pointer 108 | * @param event Event to be handled 109 | * @return uint8_t 110 | */ 111 | uint8_t audiosink_default_sink_pad_event_handler(StreamPad *pad, StreamEvent *event); 112 | 113 | /** 114 | * @brief Audio sink default pad query handler 115 | * 116 | * @param pad Pad pointer 117 | * @param query Query pointer 118 | * @return uint8_t 119 | */ 120 | uint8_t audiosink_default_sink_pad_query_handler(StreamPad *pad, StreamQuery *query); 121 | 122 | /** 123 | * @brief Audio sink default start device 124 | * 125 | * @param audio_sink_ptr Audio sink pointer 126 | * @return AudioSinkStreamErrorType 127 | */ 128 | AudioSinkStreamErrorType audiosink_default_start_device(ElementAudioSink *audio_sink_ptr); 129 | 130 | /** 131 | * @brief Audio sink default stop device 132 | * 133 | * @param audio_sink_ptr Audio sink pointer 134 | * @return AudioSinkStreamErrorType 135 | */ 136 | AudioSinkStreamErrorType audiosink_default_stop_device(ElementAudioSink *audio_sink_ptr); 137 | 138 | /** 139 | * @brief Audio sink default play device 140 | * 141 | * @param audio_sink_ptr Audio sink pointer 142 | * @return AudioSinkStreamErrorType 143 | */ 144 | AudioSinkStreamErrorType audiosink_default_play_device(ElementAudioSink *audio_sink_ptr); 145 | 146 | /** 147 | * @brief Audio sink default pause device 148 | * 149 | * @param audio_sink_ptr Audio sink pointer 150 | * @return AudioSinkStreamErrorType 151 | */ 152 | AudioSinkStreamErrorType audiosink_default_pause_device(ElementAudioSink *audio_sink_ptr); 153 | 154 | /** 155 | * @brief Audio sink default set volume 156 | * 157 | * @param audio_sink_ptr Audio sink pointer 158 | * @param volume Volume to be set 159 | * @return AudioSinkStreamErrorType 160 | */ 161 | AudioSinkStreamErrorType audiosink_default_set_volume(ElementAudioSink *audio_sink_ptr, int volume); 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /src/devices/audio_src_default.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef AUDIO_SOURCE_DEFAULT_H 8 | #define AUDIO_SOURCE_DEFAULT_H 9 | 10 | /*! 11 | * @file audio_src_default.h 12 | * @brief This is the header file for the audio source element of default. 13 | */ 14 | 15 | #include "audio_src.h" 16 | #include "streamer.h" 17 | 18 | /** 19 | * @brief Audio source buffer number 20 | * 21 | */ 22 | #if !defined(AUDIO_SRC_BUFFER_NUM) 23 | #if defined(SAI_XFER_QUEUE_SIZE) 24 | #define AUDIO_SRC_BUFFER_NUM (SAI_XFER_QUEUE_SIZE + 1) 25 | #elif defined(I2S_NUM_BUFFERS) 26 | #define AUDIO_SRC_BUFFER_NUM (I2S_NUM_BUFFERS + 1) 27 | #else 28 | #define AUDIO_SRC_BUFFER_NUM (3) 29 | #endif 30 | #endif 31 | 32 | /* 33 | * @brief Structure used for the synchronization 34 | * 35 | */ 36 | typedef struct _AudioSrcBufferQueue_T 37 | { 38 | #if AUDIO_SRC_BUFFER_NUM >= 4 39 | int8_t buffer_idx[AUDIO_SRC_BUFFER_NUM]; 40 | #else 41 | int8_t buffer_idx[5]; // More than SAI_XFER_QUEUE_SIZE or I2S_NUM_BUFFERS 42 | #endif 43 | int8_t read_idx; 44 | int8_t write_idx; 45 | int8_t size; 46 | } AudioSrcBufferQueue_t; 47 | 48 | /** 49 | * @brief Buffer size alignment 50 | * 51 | */ 52 | #define SIZE_ALIGNMENT 32 53 | 54 | /** 55 | * @brief PCM Source device information 56 | * 57 | */ 58 | typedef struct _DefaultSrcDeviceInfo 59 | { 60 | char *unaligned_buf[AUDIO_SRC_BUFFER_NUM]; /*!< @brief Pointers to unaligned buffers */ 61 | char *audbuf[AUDIO_SRC_BUFFER_NUM]; /*!< @brief Pointers to aligned audio buffers */ 62 | uint32_t buff_size[AUDIO_SRC_BUFFER_NUM]; /*!< @brief Size of the data in the audbuf */ 63 | uint8_t buff_index; /*!< @brief Current buffer index */ 64 | uint8_t device_state; /*!< @brief Device state */ 65 | bool init_params_done; /*!< @brief Initialization done flag */ 66 | bool continuous_read; /*!< @brief Continuous read flag */ 67 | AudioSrcBufferQueue_t buffer_queue; /*!< @brief Queue of the requested audio buffer index */ 68 | } DefaultSrcDeviceInfo; 69 | 70 | /** 71 | * @brief Audio source default device initialization function 72 | * 73 | * @param audio_src_element Audio source pointer 74 | * @return AudioSrcStreamErrorType 75 | */ 76 | AudioSrcStreamErrorType audio_src_default_init_device(ElementAudioSrc *audio_src_element); 77 | 78 | /** 79 | * @brief Audio source default device deinitialization function 80 | * 81 | * @param audio_src_element Audio source pointer 82 | * @return AudioSrcStreamErrorType 83 | */ 84 | AudioSrcStreamErrorType audio_src_default_deinit_device(ElementAudioSrc *audio_src_element); 85 | 86 | /** 87 | * @brief Audio source default device read function 88 | * 89 | * @param audio_src_element Audio source pointer 90 | * @param length Length to be read 91 | * @param buf buffer pointer 92 | * @return AudioSrcStreamErrorType 93 | */ 94 | AudioSrcStreamErrorType audio_src_default_read_device(ElementAudioSrc *audio_src_element, 95 | uint32_t length, 96 | StreamBuffer *buf); 97 | 98 | /** 99 | * @brief Audio source default device start device function 100 | * 101 | * @param audio_src_element Audio source pointer 102 | * @return AudioSrcStreamErrorType 103 | */ 104 | AudioSrcStreamErrorType audio_src_default_start_device(ElementAudioSrc *audio_src_element); 105 | 106 | /** 107 | * @brief Audio source default device stop device function 108 | * 109 | * @param audio_src_element Audio source pointer 110 | * @return AudioSrcStreamErrorType 111 | */ 112 | AudioSrcStreamErrorType audio_src_default_stop_device(ElementAudioSrc *audio_src_element); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/elements/decoder_pads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef DECODER_PADS_H 8 | #define DECODER_PADS_H 9 | 10 | /*! 11 | * @file decoder_pads.h 12 | * @brief This file defines the pad functions used for the decoder element. 13 | * 14 | */ 15 | 16 | /*! 17 | * @brief decoder_src_pad_activation_handler 18 | * @details This function is an empty implementation of the src pad 19 | * activation handler. 20 | * 21 | * @param pad pad handle 22 | * @param active activate/deactivate pad 23 | * 24 | * @returns PAD ERROR 25 | */ 26 | uint8_t decoder_src_pad_activation_handler(StreamPad *pad, uint8_t active); 27 | 28 | /*! 29 | * @brief decoder_src_pad_event_handler 30 | * @details This function is the empty implementation of the src pad 31 | * event handler. 32 | * 33 | * @param pad pad handle 34 | * @param event event enumeration 35 | * 36 | * @returns PAD ERROR 37 | */ 38 | uint8_t decoder_src_pad_event_handler(StreamPad *pad, StreamEvent *event); 39 | 40 | /*! 41 | * @brief decoder_src_pad_query_handler 42 | * @details This function is the empty implementation of the src pad 43 | * query handler. 44 | * 45 | * @param pad pad handle 46 | * @param query query 47 | * 48 | * @returns uint8_t 49 | */ 50 | uint8_t decoder_src_pad_query_handler(StreamPad *pad, StreamQuery *query); 51 | 52 | /*! 53 | * @brief decoder_sink_pad_activation_handler 54 | * @details This function is calls the specified decoder implementation of 55 | * the sink pad activation handler. 56 | * 57 | * @param pad pad handle 58 | * @param active activate/deactivate pad 59 | * 60 | * @returns PAD ERROR 61 | */ 62 | uint8_t decoder_sink_pad_activation_handler(StreamPad *pad, uint8_t active); 63 | 64 | /*! 65 | * @brief decoder_sink_pad_event_handler 66 | * @details This function is the calls the specified decoder 67 | * implementation ofthe sink pad event handler. 68 | * 69 | * @param pad pad handle 70 | * @param event event enumeration 71 | * 72 | * @returns PAD ERROR 73 | */ 74 | uint8_t decoder_sink_pad_event_handler(StreamPad *pad, StreamEvent *event); 75 | 76 | /*! 77 | * @brief decoder_sink_pad_chain_handler 78 | * @details This function calls the specified decoder implementation of the 79 | * sink pad chain handler. This is used in push mode, to receive 80 | * data passed from peer. 81 | * 82 | * @param pad pad handle 83 | * @param buffer input buffer 84 | * 85 | * @returns PAD ERROR 86 | */ 87 | FlowReturn decoder_sink_pad_chain_handler(StreamPad *pad, StreamBuffer *buffer); 88 | 89 | /*! 90 | * @brief decoder_sink_pad_process_handler 91 | * @details This function calls the specified decoder implementation of the 92 | * sink pad process handler. This is used in pull mode, to request 93 | * data from peer. 94 | * 95 | * @param pad pad handle 96 | * 97 | * @returns PAD ERROR 98 | */ 99 | int32_t decoder_sink_pad_process_handler(StreamPad *pad); 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /src/elements/encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _OPUS_ENC_H_ 8 | #define _OPUS_ENC_H_ 9 | 10 | #include "streamer_element.h" 11 | #include "cei.h" 12 | #include "cei_table.h" 13 | 14 | /*! 15 | * Opus encoder element data structure 16 | */ 17 | typedef struct 18 | { 19 | int32_t (*change_state)(struct _StreamElement *, PipelineState); /*!< @brief Change state function pointer */ 20 | int32_t (*set_property)(struct _StreamElement *, 21 | uint16_t prop, 22 | uintptr_t val); /*!< @brief Set property function pointer */ 23 | int32_t (*get_property)(struct _StreamElement *, 24 | uint16_t prop, 25 | uint64_t *val_ptr); /*!< @brief Get property function pointer */ 26 | void *parent; /*!< @brief Parent pointer */ 27 | int8_t key; /*!< @brief Key */ 28 | int8_t depth; /*!< @brief Depth */ 29 | PipelineState state; /*!< @brief Pipeline state */ 30 | StreamElementType type; /*!< @brief Element type */ 31 | PadSrc src_pad[MAX_NUM_PADS]; /*!< @brief Source pads */ 32 | PadSink sink_pad[MAX_NUM_PADS]; /*!< @brief Sink pads */ 33 | struct _StreamElement *sibling; /*!< @brief Sibling pointer */ 34 | 35 | uint32_t chunk_size; /*!< @brief Chunk size */ 36 | uint8_t bitstream_info_specified; /*!< @brief Bitstream info flag */ 37 | CeiBitstreamInfo bitstream_info; /*!< @brief Bitstream info */ 38 | uint8_t initialized; /*!< @brief Initialized flag */ 39 | uint8_t eos_done; /*!< @brief End of stream flag */ 40 | uint32_t offset; /*!< @brief Input buffer offset */ 41 | uint32_t outOffset; /*!< @brief Output buffer offset */ 42 | CeiEncoderType enc_type; /*!< @brief Encoder type */ 43 | void *enc_info; /*!< @brief Pointer to encoder info structure */ 44 | void *initial_config_ptr; /*!< @brief Initial configuration pointer */ 45 | BufferInfo inBuf; /*!< @brief Input buffer info */ 46 | BufferInfo outBuf; /*!< @brief Output buffer info */ 47 | } ElementEncoder; 48 | 49 | int32_t encoder_init_element(StreamElement *element); 50 | 51 | /* Source pad handler functions */ 52 | uint8_t encoder_src_pad_activation_handler(StreamPad *pad, uint8_t active); 53 | int32_t encoder_src_pad_process_handler(StreamPad *pad); 54 | 55 | // Property functions 56 | int32_t encoder_get_property(StreamElement *element, uint16_t prop, uint64_t *val_ptr); 57 | int32_t encoder_set_property(StreamElement *element, uint16_t prop, uintptr_t val); 58 | 59 | #endif /* _OPUS_ENC_H_ */ 60 | -------------------------------------------------------------------------------- /src/elements/file_sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef FILESINK_H 8 | #define FILESINK_H 9 | 10 | /*! 11 | * @file file_sink.h 12 | * @brief This file includes defines, enums and typedefs for file sink. 13 | */ 14 | 15 | #include "streamer_element.h" 16 | #ifdef FILE_ENABLE_FATFS 17 | #include "ff.h" 18 | #endif // FILE_ENABLE_FATFS 19 | 20 | /** 21 | * @brief Default file sink location (file name) 22 | * 23 | */ 24 | #define DEFAULT_FILESINK_LOCATION "rec.pcm" 25 | 26 | /*! 27 | * File Sink Element data structure 28 | */ 29 | struct _ElementFileSink 30 | { 31 | int32_t (*change_state)(struct _StreamElement *, PipelineState); /*!< @brief Change state function pointer */ 32 | int32_t (*set_property)(struct _StreamElement *, 33 | uint16_t prop, 34 | uint32_t val); /*!< @brief Set property function pointer */ 35 | int32_t (*get_property)(struct _StreamElement *, 36 | uint16_t prop, 37 | uint32_t *val_ptr); /*!< @brief Get property function pointer */ 38 | void *parent; /*!< @brief Parent pointer */ 39 | int8_t key; /*!< @brief Key */ 40 | int8_t depth; /*!< @brief Depth */ 41 | PipelineState state; /*!< @brief Pipeline state */ 42 | StreamElementType type; /*!< @brief Element type */ 43 | PadSrc src_pad[MAX_NUM_PADS]; /*!< @brief Source pads */ 44 | PadSink sink_pad[MAX_NUM_PADS]; /*!< @brief Sink pads */ 45 | struct _StreamElement *sibling; /*!< @brief Sibling pointer */ 46 | 47 | int32_t fd; /*!< @brief File descriptor */ 48 | char location[MAX_LOCATION_PATH_LENGTH]; /*!< @brief File location */ 49 | uint32_t chunk_size; /*!< @brief Chunk size */ 50 | uint8_t end_of_stream; /*!< @brief End of stream flag */ 51 | uint8_t raw_write; /*!< @brief Raw write flag */ 52 | void *pullbuf; /*!< @brief Pull buffer pointer */ 53 | }; 54 | typedef struct _ElementFileSink ElementFileSink; 55 | 56 | /*! 57 | * File dump structure 58 | */ 59 | typedef struct _FileDump 60 | { 61 | ElementFileSink *file_sink_element; /*!< @brief File sink element pointer */ 62 | int8_t *data_ptr; /*!< @brief Data pointer */ 63 | uint32_t data_ptr_size; /*!< @brief Data buffer size */ 64 | uint32_t size; /*!< @brief File dump size */ 65 | FlowReturn ret; /*!< @brief Return value */ 66 | volatile bool run; /*!< @brief File dump task run flag */ 67 | volatile bool first_run; /*!< @brief File dump task first run flag */ 68 | OSA_SEMAPHORE_HANDLE_DEFINE(sem_Read); /*!< @brief Read semaphore */ 69 | OSA_SEMAPHORE_HANDLE_DEFINE(sem_Write); /*!< @brief Write semaphore */ 70 | OSA_SEMAPHORE_HANDLE_DEFINE(sem_End); /*!< @brief End semaphore */ 71 | OSA_MUTEX_HANDLE_DEFINE(fileDataMutex); /*!< @brief File data mutex */ 72 | } FileDump; 73 | 74 | /*! 75 | * 76 | * @param param NULL 77 | * 78 | * @brief this function is a task that writes data to the SD card 79 | * 80 | */ 81 | void FILE_Dump_Task(void *param); 82 | 83 | /*! 84 | * 85 | * @param element an element which is created by parent element 86 | * 87 | * @brief this function initializes the audio sink element and sink pads 88 | * 89 | * @returns StreamReturnType 90 | * @retval STREAM_OK if successful 91 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 92 | * 93 | */ 94 | int32_t filesink_init_element(StreamElement *element); 95 | 96 | /*! 97 | * 98 | * @param element element handle 99 | * @param path pointer to a file path 100 | * 101 | * @brief This function sets a destiniaiton file to be writen by file sink 102 | * 103 | * @returns StreamReturnType 104 | * 105 | * @retval STREAM_OK if successful 106 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 107 | * 108 | */ 109 | int32_t filesink_set_location(ElementHandle element, char *path); 110 | 111 | /*! 112 | * @param element element handle 113 | * @param write_mode write mode raw (or) packet header 114 | * 115 | * @brief Set the raw write mode or the packet header mode to write to file 116 | * 117 | * @returns: StreamReturnType 118 | * @retval STREAM_OK if successful 119 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 120 | */ 121 | int32_t filesink_set_write_mode(ElementHandle element, uint8_t write_mode); 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /src/elements/mem_sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef MEMSINK_H 8 | #define MEMSINK_H 9 | 10 | /*! 11 | * @file mem_sink.h 12 | * @brief This file includes defines, enums and typedefs for memory sink. 13 | */ 14 | 15 | #include "streamer_element.h" 16 | 17 | /*! 18 | * @brief Memory sink element's data structure. 19 | * @details This data structure is created by create_element, 20 | * initialized by memsink_init_element 21 | */ 22 | struct _ElementMemSink 23 | { 24 | int32_t (*change_state)(struct _StreamElement *, PipelineState); /*!< @brief Change state function pointer */ 25 | int32_t (*set_property)(struct _StreamElement *, 26 | uint16_t prop, 27 | uint32_t val); /*!< @brief Set property function pointer */ 28 | int32_t (*get_property)(struct _StreamElement *, 29 | uint16_t prop, 30 | uint32_t *val_ptr); /*!< @brief Get property function pointer */ 31 | void *parent; /*!< @brief Parent pointer */ 32 | int8_t key; /*!< @brief Key */ 33 | int8_t depth; /*!< @brief Depth */ 34 | PipelineState state; /*!< @brief Pipeline state */ 35 | StreamElementType type; /*!< @brief Element type */ 36 | PadSrc src_pad[MAX_NUM_PADS]; /*!< @brief Source pads */ 37 | PadSink sink_pad[MAX_NUM_PADS]; /*!< @brief Sink pads */ 38 | struct _StreamElement *sibling; /*!< @brief Sibling pointer */ 39 | 40 | char *location; /*!< @brief pointer to memory buffer start address */ 41 | uint8_t raw_write; /*!< @brief raw write mode */ 42 | uint32_t size; /*!< @brief memory buffer size */ 43 | uint32_t current_index; /*!< @brief internal used for memory buffer */ 44 | }; 45 | typedef struct _ElementMemSink ElementMemSink; 46 | 47 | /*! 48 | * @param element_hdl element handle 49 | * @param location_ptr location path 50 | * @param size memory buffer size 51 | * 52 | * @brief Set the location of the memory buffer to write to as well as the size 53 | * 54 | * @returns StreamReturnType 55 | * @retval STREAM_OK success 56 | * @retval STREAM_ERR_INVALID_ARGS invalid parameters 57 | * @retval STREAM_ERR_GENERAL status is bigger than or eque to STATE_PAUSED 58 | */ 59 | int32_t memsink_set_buffer(ElementHandle element_hdl, char *location_ptr, uint32_t size); 60 | 61 | /*! 62 | * @param element_hdl element handle 63 | * @param raw_write_mode write mode raw (or) packet header 64 | * 65 | * @brief This function sets the raw write mode or the packet 66 | * header mode to write to memory. 67 | * (write_mode == true) means only data will be written (no packet headers) 68 | * (write_mode == false) means packet header will be written aOSA_LONG with data 69 | * 70 | * @returns StreamReturnType 71 | * @retval STREAM_OK success 72 | * @retval STREAM_ERR_INVALID_ARGS invalid arguments 73 | * @retval STREAM_ERR_GENERAL value is bigger than or eque to STATE_PAUSED 74 | */ 75 | int32_t memsink_set_raw_write_mode(ElementHandle element_hdl, uint8_t raw_write_mode); 76 | 77 | /*! 78 | * @param element_ptr pointer of memory sink element instance 79 | * 80 | * @brief This function initializes the memory sink element 81 | * and sink pads. 82 | * 83 | * @returns StreamReturnType 84 | * @retval STREAM_OK success 85 | * @retval STREAM_ERR_ELEMENT_NOT_FOUND invalid instance pointer of element_ptr 86 | */ 87 | int32_t memsink_init_element(StreamElement *element_ptr); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/elements/mem_src.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef MEMSRC_H 8 | #define MEMSRC_H 9 | 10 | /*! 11 | * @file mem_src.h 12 | * @brief This is the header file for the memory source element. 13 | */ 14 | 15 | #include "streamer_element.h" 16 | 17 | /* 18 | * CONSTANTS, DEFINES AND MACROS 19 | */ 20 | 21 | /*! 22 | * Default read size 23 | */ 24 | #define MEMSRC_DEFAULT_CHUNK_SIZE 1024 25 | 26 | /*! 27 | * Memory Source Element data structure 28 | */ 29 | struct _ElementMemSrc 30 | { 31 | int32_t (*change_state)(struct _StreamElement *, PipelineState); /*!< @brief Change state function pointer */ 32 | int32_t (*set_property)(struct _StreamElement *, 33 | uint16_t prop, 34 | uintptr_t val); /*!< @brief Set property function pointer */ 35 | int32_t (*get_property)(struct _StreamElement *, 36 | uint16_t prop, 37 | uint32_t *val_ptr); /*!< @brief Get property function pointer */ 38 | void *parent; /*!< @brief Parent pointer */ 39 | int8_t key; /*!< @brief Key */ 40 | int8_t depth; /*!< @brief Depth */ 41 | PipelineState state; /*!< @brief Pipeline state */ 42 | StreamElementType type; /*!< @brief Element type */ 43 | PadSrc src_pad[MAX_NUM_PADS]; /*!< @brief Source pads */ 44 | PadSink sink_pad[MAX_NUM_PADS]; /*!< @brief Sink pads */ 45 | struct _StreamElement *sibling; /*!< @brief Sibling pointer */ 46 | 47 | uint32_t chunk_size; /*!< @brief Chunk size */ 48 | int8_t *location; /*!< @brief File location */ 49 | int8_t *buffer; /*!< @brief Buffer pointer */ 50 | uint8_t end_of_stream; /*!< @brief End of stream flag */ 51 | uint32_t read_position; /*!< @brief Last read offset */ 52 | uint32_t size; /*!< @brief Overall size */ 53 | uint8_t mem_type; /*!< @brief Memory type */ 54 | uint32_t sample_rate; /*!< @brief Sample rate */ 55 | uint8_t num_channels; /*!< @brief Number of channels */ 56 | uint8_t bit_width; /*!< @brief Bit width */ 57 | }; 58 | typedef struct _ElementMemSrc ElementMemSrc; 59 | 60 | /*! 61 | * @ingroup coreapi 62 | * @{ 63 | */ 64 | 65 | /* 66 | * FUNCTION PROTOTYPES 67 | */ 68 | 69 | /*! 70 | * 71 | * @brief this function initializes the memory source element and source pad. 72 | * all the pad's handlers are intialized. 73 | * 74 | * @param element pointer to element 75 | * 76 | * @returns StreamReturnType 77 | * @retval STREAM_OK if successful 78 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 79 | * 80 | */ 81 | int32_t memsrc_init(StreamElement *element); 82 | 83 | /*! 84 | * 85 | * @brief This function sets a destiniaiton buffer to be read 86 | * by memory source element 87 | * 88 | * @param element: element handle 89 | * @param location: memory location 90 | * @param size: memory size 91 | * 92 | * @returns StreamReturnType 93 | * @retval STREAM_OK if successful 94 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 95 | * 96 | */ 97 | int32_t memsrc_set_buffer(ElementHandle element, int8_t *location, uint32_t size); 98 | 99 | /*! 100 | * 101 | * @brief This function sets the chunk size in which the momery source sends 102 | * the data in push mode 103 | * 104 | * @param element element handle 105 | * @param chunk_size chunk size 106 | * 107 | * @returns StreamReturnType 108 | * @retval STREAM_OK if successful 109 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 110 | * 111 | */ 112 | int32_t memsrc_set_push_chunk_size(ElementHandle element, uint32_t chunk_size); 113 | /*! 114 | * 115 | * @brief This function gets the chunk size 116 | * 117 | * @param element element handle 118 | * @param chunk_size chunk size 119 | * 120 | * @returns StreamReturnType 121 | * @retval STREAM_OK if successful 122 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 123 | * 124 | */ 125 | int32_t memsrc_get_push_chunk_size(ElementHandle element, uint32_t *chunk_size); 126 | 127 | /*! @} */ 128 | 129 | #endif 130 | 131 | /* end of file */ 132 | -------------------------------------------------------------------------------- /src/elements/netbuf_src.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef NETBUFSRC_H 8 | #define NETBUFSRC_H 9 | 10 | /*! 11 | * @file netbuf_src.h 12 | * @brief This is the header file for the network buffer source 13 | */ 14 | 15 | #include "streamer_element.h" 16 | 17 | /*! 18 | * Memory Source Element data structure 19 | */ 20 | typedef struct _ElementNetbufSrc 21 | { 22 | int32_t (*change_state)(struct _StreamElement *, PipelineState); /*!< @brief Change state function pointer */ 23 | int32_t (*set_property)(struct _StreamElement *, 24 | uint16_t prop, 25 | uintptr_t val); /*!< @brief Set property function pointer */ 26 | int32_t (*get_property)(struct _StreamElement *, 27 | uint16_t prop, 28 | uint32_t *val_ptr); /*!< @brief Get property function pointer */ 29 | void *parent; /*!< @brief Parent pointer */ 30 | int8_t key; /*!< @brief Key */ 31 | int8_t depth; /*!< @brief Depth */ 32 | PipelineState state; /*!< @brief Pipeline state */ 33 | StreamElementType type; /*!< @brief Element type */ 34 | PadSrc src_pad[MAX_NUM_PADS]; /*!< @brief Source pads */ 35 | PadSink sink_pad[MAX_NUM_PADS]; /*!< @brief Sink pads */ 36 | struct _StreamElement *sibling; /*!< @brief Sibling pointer */ 37 | 38 | uint8_t end_of_stream; /*!< @brief End of stream flag */ 39 | int32_t (*audio_callback)(int8_t *buffer, uint32_t size); /*!< @brief Audio callback function pointer */ 40 | } ElementNetbufSrc; 41 | 42 | /** 43 | * @brief Audio callback function pointer for read 44 | * 45 | * @param buffer Buffer pointer 46 | * @param size Buffer size 47 | * @return typedef 48 | */ 49 | typedef int32_t audio_callback_t(int8_t *buffer, uint32_t size); 50 | 51 | /*! 52 | * 53 | * @brief this function initializes the netbuf source element and source pad. 54 | * all the pad's handlers are intialized. 55 | * 56 | * @param element pointer to element 57 | * 58 | * @returns StreamReturnType 59 | * @retval STREAM_OK if successful 60 | * @retval STREAM_ERR_INVALID_ARGS means invalid arguments 61 | * 62 | */ 63 | int32_t netbufsrc_init(StreamElement *element); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/inc/audio_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _AUDIO_CFG_H_ 8 | #define _AUDIO_CFG_H_ 9 | 10 | /* 11 | * Metadata Configuration 12 | */ 13 | #define CASCFG_META_DEFAULT_ARTIST_NAME "Unknown Artist" 14 | #define CASCFG_META_DEFAULT_ALBUM_NAME "Unknown Album" 15 | #define CASCFG_META_DEFAULT_GENRE_NAME "Unknown Genre" 16 | #define CASCFG_TRACK_TITLE_LEN 64 17 | #define CASCFG_TRACK_ARTIST_LEN 64 18 | #define CASCFG_TRACK_ALBUM_LEN 64 19 | #define CASCFG_TRACK_GENRE_LEN 34 20 | #define CASCFG_TRACK_YEAR_LEN 5 21 | 22 | /* 23 | * Log Level - Message levels to always display 24 | */ 25 | #define CASCFG_LOGLVL_DEFAULT_CATASTROPHIC 1 26 | #define CASCFG_LOGLVL_DEFAULT_ERROR 1 27 | #define CASCFG_LOGLVL_DEFAULT_WARNING 1 28 | #define CASCFG_LOGLVL_DEFAULT_INFO 1 29 | /* CASCFG_LOGLVL_DEFAULT_FUNCTIONS is not set */ 30 | /* CASCFG_LOGLVL_DEFAULT_DEBUG is not set */ 31 | 32 | /* 33 | * Log Output - Initial setting for message output 34 | */ 35 | /* CASCFG_LOG_DEFAULT_OUTPUT_OFF is not set */ 36 | #define CASCFG_LOG_DEFAULT_OUTPUT_CONSOLE 1 37 | /* CASCFG_LOG_DEFAULT_OUTPUT_FILE is not set */ 38 | /* CASCFG_LOG_DEFAULT_OUTPUT_BOTH is not set */ 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/inc/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __ERROR_H_ 8 | #define __ERROR_H_ 9 | 10 | /*! 11 | * @file error.h 12 | * @brief Contains common error codes and definitions. 13 | */ 14 | 15 | /** @brief Error code no error */ 16 | #define ERRCODE_NO_ERROR 0x0 17 | /** @brief Error code try again */ 18 | #define ERRCODE_TRY_AGAIN 0x1 19 | /** @brief Error code invalid argument */ 20 | #define ERRCODE_INVALID_ARGUMENT 0x02 21 | /** @brief Error code out of memory */ 22 | #define ERRCODE_OUT_OF_MEMORY 0x03 23 | /** @brief Error code out of space */ 24 | #define ERRCODE_OUT_OF_SPACE 0x04 25 | /** @brief Error code general error */ 26 | #define ERRCODE_GENERAL_ERROR 0x05 27 | /** @brief Error code deadlock */ 28 | #define ERRCODE_DEADLOCK 0x06 29 | /** @brief Error code not supported */ 30 | #define ERRCODE_NOT_SUPPORTED 0x07 31 | /** @brief Error code busy */ 32 | #define ERRCODE_BUSY 0x08 33 | /** @brief Error code permission denied */ 34 | #define ERRCODE_PERMISSION_DENIED 0x09 35 | /** @brief Error code timed out */ 36 | #define ERRCODE_TIMED_OUT 0x0A 37 | /** @brief Error code system limit */ 38 | #define ERRCODE_SYSTEM_LIMIT 0x0B 39 | /** @brief Error code parameter exists */ 40 | #define ERRCODE_PARAMETER_EXISTS 0x0C 41 | /** @brief Error code end of directory */ 42 | #define ERRCODE_END_OF_DIRECTORY 0x0D 43 | /** @brief Error code not found */ 44 | #define ERRCODE_NOT_FOUND 0x0E 45 | /** @brief Error code unknown */ 46 | #define ERRCODE_UNKNOWN 0x0F 47 | /** @brief Error code internal */ 48 | #define ERRCODE_INTERNAL 0x10 49 | /** @brief Error code overflow */ 50 | #define ERRCODE_OVERFLOW 0x11 51 | /** @brief Error code message failure */ 52 | #define ERRCODE_MSG_FAILURE 0x12 53 | /** @brief Error code thread failure */ 54 | #define ERRCODE_THREAD_FAILURE 0x13 55 | /** @brief Error code mutex failure */ 56 | #define ERRCODE_MUTEX_FAILURE 0x14 57 | /** @brief Error code device element exists */ 58 | #define ERRCODE_DEVICE_ELEMENT_EXISTS 0x15 59 | /** @brief Error code not seekable */ 60 | #define ERRCODE_NOT_SEEKABLE 0x16 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/inc/streamer_message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef STREAMER_MESSAGE_H 8 | #define STREAMER_MESSAGE_H 9 | 10 | /*! 11 | * @file streamer_message.h 12 | * @brief This file includes definitions for messages used by the Streamer 13 | * library 14 | */ 15 | 16 | /* 17 | * CONSTANTS, DEFINES AND MACROS 18 | */ 19 | 20 | /** 21 | * @brief Build a message 22 | * 23 | * 24 | * @param msg: Message id 25 | * @param type: message type 26 | * 27 | * @details 28 | * Max ID of message is 8. Each ID can have 24 types. 29 | * Bits 31-24: Message ID 30 | * Bits 23-0: Message type 31 | * 32 | * 33 | */ 34 | #define BLD_MESSAGE(msg, type) ((uint32_t)(((uint32_t)(msg) << 24) | ((uint32_t)(type)))) 35 | 36 | /** 37 | * @brief Get message ID 38 | * 39 | */ 40 | #define MESSAGE_ID(msg) (uint32_t)((msg) >> 24) 41 | 42 | /** 43 | * @brief Get message type 44 | * 45 | */ 46 | #define MESSAGE_TYPE(msg) (uint32_t)((msg)&0xFFF) 47 | 48 | /*-------------------------------- Messages ---------------------------------*/ 49 | 50 | /** @brief Null message */ 51 | #define MSG_NULL (uint32_t)0 52 | 53 | /** @brief End of stream message from the pipeline. */ 54 | #define MSG_EOS BLD_MESSAGE(MESSAGE_EOS, 0) 55 | 56 | /** @brief Actual error type will be decoder dependent passed on in message data field. */ 57 | #define MSG_ERROR_AUDIO BLD_MESSAGE(MESSAGE_ERROR, ERROR_AUDIO_FATAL) 58 | 59 | /** @brief Actual warning type will be decoder dependent passed on in message data field */ 60 | #define MSG_WARNING_AUDIO BLD_MESSAGE(MESSAGE_ERROR, WARNING_AUDIO) 61 | 62 | /** @brief Message data will contain the bitrate in bits per second. */ 63 | #define MSG_INFO_AUDIO_BITRATE BLD_MESSAGE(MESSAGE_INFO, INFO_AUDIO_BITRATE) 64 | 65 | /** @brief Message data will contain the number of channels supported. */ 66 | #define MSG_INFO_AUDIO_CHANNELS BLD_MESSAGE(MESSAGE_INFO, INFO_AUDIO_CHANNELS) 67 | 68 | /** @brief Message data will contain the audio sampling rate in Hz. */ 69 | #define MSG_INFO_AUDIO_SAMPLERATE BLD_MESSAGE(MESSAGE_INFO, INFO_AUDIO_SAMPLERATE) 70 | 71 | /** @brief Message data will contain the type of audio. Audio type depends on the decoders supported. */ 72 | #define MSG_INFO_AUDIO_TYPE BLD_MESSAGE(MESSAGE_INFO, INFO_AUDIO_TYPE) 73 | 74 | /** @brief Message data will contain the pointer to a string of codec info */ 75 | #define MSG_INFO_CODEC_INFO BLD_MESSAGE(MESSAGE_INFO, INFO_CODEC_INFO) 76 | 77 | /** @brief Message data will contain the total duration of playback in milliseconds. */ 78 | #define MSG_INFO_DURATION BLD_MESSAGE(MESSAGE_INFO, INFO_DURATION) 79 | 80 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 81 | #define MSG_INFO_ALBUM BLD_MESSAGE(MESSAGE_INFO, INFO_ALBUM) 82 | 83 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 84 | #define MSG_INFO_ARTIST BLD_MESSAGE(MESSAGE_INFO, INFO_ARTIST) 85 | 86 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 87 | #define MSG_INFO_TITLE BLD_MESSAGE(MESSAGE_INFO, INFO_TITLE) 88 | 89 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 90 | #define MSG_INFO_GENRE BLD_MESSAGE(MESSAGE_INFO, INFO_GENRE) 91 | 92 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 93 | #define MSG_INFO_YEAR BLD_MESSAGE(MESSAGE_INFO, INFO_YEAR) 94 | 95 | /** @brief Nothing in message data. get tag function should be called to get the required tag. */ 96 | #define MSG_INFO_TRACK BLD_MESSAGE(MESSAGE_INFO, INFO_TRACK) 97 | 98 | /** @brief Message data will contain the total duration of playback in milliseconds. */ 99 | #define MSG_INFO_ALBUMART BLD_MESSAGE(MESSAGE_INFO, INFO_ALBUMART_IMAGE) 100 | 101 | /** @brief Message data will contain the current time of playback in milliseconds. */ 102 | #define MSG_INFO_POSITION BLD_MESSAGE(MESSAGE_INFO, INFO_POSITION) 103 | 104 | /** @brief Nothing in message data. indicate that all stream information is updated */ 105 | #define MSG_STREAM_INFO_UPDATED BLD_MESSAGE(MESSAGE_INFO, INFO_STREAM_INFO_UPDATE) 106 | 107 | /** @brief Nothing in message data. indicate that all metadata information is updated */ 108 | #define MSG_META_INFO_UPDATED BLD_MESSAGE(MESSAGE_INFO, INFO_META_INFO_UPDATE) 109 | 110 | /** @brief Message data will contain the error type. */ 111 | #define MSG_STREAM_ERROR BLD_MESSAGE(MESSAGE_INFO, INFO_ERROR) 112 | 113 | #endif /* STREAMER_MESSAGE_H */ 114 | -------------------------------------------------------------------------------- /src/inc/types.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | //! \addtogroup cci_type CCI Types and Definitions 3 | //! @{ 4 | // 5 | // Copyright 2013-2014 Freescale, Inc. 6 | // 7 | // SPDX-License-Identifier: BSD-3-Clause 8 | // 9 | //! \file types.h 10 | //! \brief Contains standard data types. 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef _TYPES_H 14 | #define _TYPES_H 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | typedef struct 21 | { 22 | uint32_t val[4]; 23 | } uint128_t; 24 | 25 | /*! 26 | * \brief CircularBuffer structure 27 | */ 28 | typedef struct __CircularBuffer 29 | { 30 | unsigned char *pu8HeadPtr; //!< buffer head pointer 31 | unsigned char *pu8TailPtr; //!< buffer tail pointer 32 | unsigned char *pu8BaseAddr; //!< buffer base address 33 | unsigned char *pu8EndAddr; //!< buffer end address 34 | unsigned int i32BufferSize; //!< buffer size 35 | } CircularBuffer_t; 36 | /*! 37 | * \brief Buffer Descriptor 38 | */ 39 | typedef struct 40 | { 41 | CircularBuffer_t ReadBuffer; //!< read circular buffer 42 | CircularBuffer_t WriteBuffer; //!< write circular buffer 43 | uint32_t minInput; //!< minimum input frame 44 | uint32_t minOutput; //!< minimum output space 45 | } tBufferDesc; 46 | 47 | #define CONFIGURE_CIRCULAR_DESC(desc, buffer, size) \ 48 | desc.pu8HeadPtr = desc.pu8TailPtr = desc.pu8BaseAddr = (uint8_t *)buffer; \ 49 | desc.pu8EndAddr = (uint8_t *)desc.pu8BaseAddr + size; \ 50 | desc.i32BufferSize = size; 51 | 52 | #ifndef RETCODE 53 | #define RETCODE int 54 | #endif 55 | 56 | #ifdef ERROR 57 | #undef ERROR 58 | #define ERROR -1 59 | #endif 60 | 61 | #ifdef NOERROR 62 | #undef NOERROR 63 | #define NOERROR 0 64 | #endif 65 | //------------------------------------------------------------------------------ 66 | // All of the following defs are included for compatability. Please use the 67 | // ANSI C99 defs for all new work. 68 | //------------------------------------------------------------------------------ 69 | 70 | #ifdef FALSE 71 | #undef FALSE 72 | #define FALSE false 73 | #endif 74 | 75 | #ifdef TRUE 76 | #undef TRUE 77 | #define TRUE true 78 | #endif 79 | 80 | //! \brief 81 | #ifdef NULL 82 | #undef NULL 83 | #define NULL 0 84 | #endif 85 | 86 | //! \brief 87 | typedef bool BOOL; 88 | 89 | //! \brief 90 | typedef uint8_t UINT8; 91 | //! \brief 92 | typedef uint8_t BYTE; 93 | //! \brief 94 | typedef uint8_t PACKED_BYTE; 95 | 96 | //! \brief 97 | typedef uint16_t UINT16; 98 | //! \brief 99 | typedef uint16_t USHORT; 100 | //! \brief 101 | typedef uint16_t WCHAR; 102 | //! \brief 103 | typedef uint16_t UCS3; 104 | //! \brief 105 | typedef int16_t SHORT; 106 | 107 | //! \brief 108 | typedef uint32_t UINT32; 109 | //! \brief 110 | typedef uint32_t WORD; 111 | //! \brief 112 | typedef uint32_t SECTOR_BUFFER; 113 | //! \brief 114 | typedef uint32_t *P_SECTOR_BUFFER; 115 | 116 | //! \brief 117 | typedef uint64_t DWORD; 118 | //! \brief 119 | typedef int64_t INT64; 120 | //! \brief 121 | typedef int64_t UINT64; 122 | 123 | //! \brief 124 | typedef uint128_t UINT128; 125 | 126 | //! \brief 127 | typedef float FLOAT; 128 | 129 | //! \brief 130 | #define FRACT _fract 131 | //! \brief 132 | #define CIRC _circ 133 | 134 | #ifndef __LANGUAGE_ASM__ 135 | #ifndef RT_STATUS_T_DEFINED 136 | #define RT_STATUS_T_DEFINED 137 | typedef int RtStatus_t; 138 | #endif 139 | #endif 140 | 141 | //------------------------------------------------------------------------------ 142 | // SystemHalt macros in types.h? 143 | //------------------------------------------------------------------------------ 144 | 145 | #ifdef __THUMB 146 | #define SystemHalt() __asm(" .half 0xbebe") 147 | #elif defined(_WIN32) 148 | #ifdef __cplusplus 149 | extern "C" { 150 | #endif 151 | void _assert(const char *, const char *, const int); 152 | #ifdef __cplusplus 153 | } 154 | #endif 155 | #define SystemHalt() _assert(__FILE__, __FUNCTION__, __LINE__) 156 | #else 157 | #define SystemHalt() __asm(" .word 0xbebebebe"); 158 | #endif 159 | // Debug macros in types.h? 160 | //------------------------------------------------------------------------------ 161 | 162 | //! \brief 163 | #ifdef DEBUG 164 | #define IFDEBUG(x) x 165 | #else 166 | #define IFDEBUG(x) 167 | #endif 168 | 169 | //------------------------------------------------------------------------------ 170 | // This sets the default build of the target 171 | //------------------------------------------------------------------------------ 172 | 173 | //! \brief 174 | #if !defined(HW_TARGET_ASIC) && !defined(HW_TARGET_SIMULATOR) 175 | #define HW_TARGET_BRAZOS 1 176 | #endif 177 | 178 | //------------------------------------------------------------------------------ 179 | // Win32 compatibility? 180 | //------------------------------------------------------------------------------ 181 | 182 | //! \brief 183 | #ifdef _WIN32 184 | #define inline __inline 185 | #endif 186 | 187 | #endif // #ifndef _TYPES_H 188 | 189 | /////////////////////////////////////////////////////////////////////////////// 190 | // End of file 191 | /////////////////////////////////////////////////////////////////////////////// 192 | //! @} 193 | -------------------------------------------------------------------------------- /src/parsers/cci/cci_codec_type_conversion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /*! 8 | * @file cci_codec_type_conversion.c 9 | * @brief This file Contains CCI decoder type conversion APIs 10 | * 11 | */ 12 | 13 | /* 14 | * Includes 15 | */ 16 | #include 17 | #include "audio_cfg.h" 18 | #include "streamer.h" 19 | #include "streamer_api.h" 20 | #include "codec_interface_public_api.h" 21 | 22 | /* 23 | * Prototypes 24 | */ 25 | 26 | /*! @brief Convert CCI stream type to a decoder type. 27 | * 28 | * 29 | * @param[in] stream_type CCI stream type. 30 | * 31 | * @retval Decoder Type 32 | */ 33 | int32_t stream_type_conversion(int32_t stream_type) 34 | { 35 | int32_t decoder_type; 36 | 37 | switch (stream_type) 38 | { 39 | case STREAM_TYPE_PCM: 40 | case STREAM_TYPE_MSADPCM: 41 | case STREAM_TYPE_IMAADPCM: 42 | decoder_type = DECODER_TYPE_WAV; 43 | break; 44 | case STREAM_TYPE_MP3: 45 | decoder_type = DECODER_TYPE_MP3; 46 | break; 47 | case STREAM_TYPE_AAC: 48 | decoder_type = DECODER_TYPE_AAC; 49 | break; 50 | case STREAM_TYPE_FLAC: 51 | decoder_type = DECODER_TYPE_FLAC; 52 | break; 53 | default: 54 | decoder_type = DECODER_TYPE_UNKNOWN; 55 | break; 56 | } 57 | 58 | return decoder_type; 59 | } 60 | /*! @brief Convert Decoder type to CCI stream type. 61 | * 62 | * 63 | * @param[in] decoder_type Decoder type. 64 | * 65 | * @retval CCI Stream Type 66 | */ 67 | uint8_t cci_decoder_type_conversion(DecoderType decoder_type) 68 | { 69 | audio_stream_type_t cci_type; 70 | 71 | STREAMER_FUNC_ENTER(DBG_CCID); 72 | switch (decoder_type) 73 | { 74 | case DECODER_TYPE_WAV: 75 | cci_type = STREAM_TYPE_PCM; 76 | break; 77 | case DECODER_TYPE_MP3: 78 | cci_type = STREAM_TYPE_MP3; 79 | break; 80 | case DECODER_TYPE_OPUS: 81 | cci_type = STREAM_TYPE_OPUS; 82 | break; 83 | case DECODER_TYPE_OGG_OPUS: 84 | cci_type = STREAM_TYPE_OGG_OPUS; 85 | break; 86 | case DECODER_TYPE_AAC: 87 | cci_type = STREAM_TYPE_AAC; 88 | break; 89 | case DECODER_TYPE_FLAC: 90 | cci_type = STREAM_TYPE_FLAC; 91 | break; 92 | default: 93 | cci_type = STREAM_TYPE_UNKNOWN; 94 | break; 95 | } 96 | STREAMER_FUNC_EXIT(DBG_CCID); 97 | return cci_type; 98 | } 99 | 100 | /* 101 | * End of file 102 | * @} 103 | */ 104 | -------------------------------------------------------------------------------- /src/utils/inc/file_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef FILE_UTILS_H 8 | #define FILE_UTILS_H 9 | 10 | /*! 11 | * @file file_utils.h 12 | * @brief This file provides file manipulation functions. 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | /** 20 | * @brief FatFS enabled 21 | * 22 | */ 23 | #ifdef SD_ENABLED 24 | #define FILE_ENABLE_FATFS 25 | #endif // SD_ENABLED 26 | #ifndef FILE_ENABLE_SEMI 27 | #define FILE_ENABLE_FATFS 28 | #endif // FILE_ENABLE_SEMI 29 | 30 | /** 31 | * @brief No file utils wrapper used 32 | * 33 | */ 34 | #define FILE_UTILS_NONE 0 35 | /** 36 | * @brief FatFS file utils wrapper used 37 | * 38 | */ 39 | #define FILE_UTILS_FATFS 1 40 | /** 41 | * @brief Semihosting file utils wrapper used 42 | * 43 | */ 44 | #define FILE_UTILS_SEMI 2 45 | 46 | /** 47 | * @brief Selection of file system 48 | * 49 | */ 50 | #ifdef FILE_ENABLE_SEMI 51 | #define FILE_UTILS_FS_SEL FILE_UTILS_SEMI 52 | /** 53 | * @brief Enable use of cache in semihosting mode 54 | * 55 | */ 56 | #define FILE_UTILS_SEMI_CACHE 57 | #else 58 | #define FILE_UTILS_FS_SEL FILE_UTILS_FATFS 59 | #endif // FILE_ENABLE_SEMI 60 | 61 | /** 62 | * @brief Maximal number of open files 63 | * 64 | */ 65 | #ifndef FILE_FS_TABLE_SIZE 66 | #define FILE_FS_TABLE_SIZE 1u 67 | #endif // FILE_FS_TABLE_SIZE 68 | 69 | /** 70 | * @brief File access mode read only 71 | * 72 | */ 73 | #define FILE_RDONLY 0x01u 74 | /** 75 | * @brief File access mode write only 76 | * 77 | */ 78 | #define FILE_WRONLY 0x02u 79 | /** 80 | * @brief File access mode read write 81 | * 82 | */ 83 | #define FILE_RDWR 0x04u 84 | /** 85 | * @brief File access mode append 86 | * 87 | */ 88 | #define FILE_APPEND 0x08u 89 | /** 90 | * @brief File access mode create 91 | * 92 | */ 93 | #define FILE_CREAT 0x10u 94 | 95 | /** 96 | * @brief File access mode create and truncates it to 0. 97 | * 98 | */ 99 | #define FILE_TRUNC 0x20u 100 | 101 | /*! 102 | * @ingroup utils 103 | * @brief file_open 104 | * @details Function to get handle of open device 105 | * @param pathname File path 106 | * @param mode file mode 107 | * @returns file descriptor 108 | */ 109 | int32_t file_open(const char *pathname, uint32_t mode); 110 | 111 | /*! 112 | * @ingroup utils 113 | * @brief file_close 114 | * @details Function to close file 115 | * @param fd File descriptor 116 | * @returns error code of operation 117 | */ 118 | int32_t file_close(int32_t fd); 119 | 120 | /*! 121 | * @ingroup utils 122 | * @brief file_read 123 | * @details Function to read data from file given by handle 124 | * @param fd File descriptor 125 | * @param buff buffer pointer 126 | * @param btr bytes to be read 127 | * @returns bytes read 128 | */ 129 | int32_t file_read(int32_t fd, void *buff, size_t btr); 130 | 131 | /*! 132 | * @ingroup utils 133 | * @brief file_write 134 | * @details Function to write data to file given by handle 135 | * @param fd File descriptor 136 | * @param buff buffer pointer 137 | * @param cnt bytes to be written 138 | * @returns bytes writen 139 | */ 140 | int32_t file_write(int32_t fd, void *buff, size_t cnt); 141 | 142 | /*! 143 | * @ingroup utils 144 | * @brief file_seek 145 | * @details Function to seek in given by handle 146 | * @param fd File descriptor 147 | * @param offset from start of the file 148 | * @returns error code of operation 149 | */ 150 | int32_t file_seek(int32_t fd, size_t offset); 151 | 152 | /*! 153 | * @ingroup utils 154 | * @brief file_getsize 155 | * @details Function to get the device file size. 156 | * @param fd File handle 157 | * @returns size of file in bytes 158 | */ 159 | int32_t file_getsize(int32_t fd); 160 | 161 | #ifdef FILE_ENABLE_FATFS 162 | /*! 163 | * @ingroup utils 164 | * @brief file_exists 165 | * @details Returns true if the given file exists on disk and false if not 166 | * @param filename Name and path of the file to test for existence 167 | * @returns true or false 168 | */ 169 | bool file_exists(const char *filename); 170 | #endif // FILE_ENABLE_FATFS 171 | 172 | /*! 173 | * @ingroup utils 174 | * @brief dir_exists 175 | * @details Returns true if the given directory exists on disk and false if not 176 | * @param dirname Name and path of the directory to test for existence 177 | * @returns true or false 178 | */ 179 | bool dir_exists(const char *dirname); 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /src/utils/inc/ringbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 NXP. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _RINGBUFFER_H_ 8 | #define _RINGBUFFER_H_ 9 | 10 | /*! 11 | * @file ringbuffer.h 12 | * @brief Implements a data ringbuffer. 13 | */ 14 | 15 | #include 16 | 17 | /** 18 | * @brief Ringbuffer structure 19 | * 20 | */ 21 | struct ringbuf 22 | { 23 | uint8_t *buf; /*!< @brief buffer pointer */ 24 | uint32_t head; /*!< @brief buffer head */ 25 | uint32_t tail; /*!< @brief buffer tail */ 26 | uint32_t size; /*!< @brief buffer size */ 27 | uint32_t occ; /*!< @brief buffer occupancy*/ 28 | }; 29 | 30 | typedef struct ringbuf ringbuf_t; 31 | 32 | /*! 33 | * @brief Create and initialize a ring buffer structure 34 | * 35 | * @param size Buffer size to be malloc'd 36 | * @returns Initialized and allocated pointer to ring buffer object 37 | */ 38 | ringbuf_t *ringbuf_create(uint32_t size); 39 | 40 | /*! 41 | * @brief Destroy and free ring buffer structure 42 | * 43 | * @param rb Pointer to ring buffer object created with ringbuf_create 44 | */ 45 | void ringbuf_destroy(ringbuf_t *rb); 46 | 47 | /*! 48 | * @brief Empty ring buffer structure 49 | * 50 | * @param rb Pointer to ring buffer object created with ringbuf_create 51 | */ 52 | void ringbuf_clear(ringbuf_t *rb); 53 | 54 | /*! 55 | * @brief Return the number of bytes stored in the ringbuffer 56 | * 57 | * @param rb Pointer to ring buffer object created with ringbuf_create 58 | * @returns Number of bytes of data currently occupying space in the buffer 59 | */ 60 | uint32_t ringbuf_get_occupancy(ringbuf_t *rb); 61 | 62 | /*! 63 | * @brief Write data to ring buffer 64 | * 65 | * @param rb Pointer to ring buffer object created with ringbuf_create 66 | * @param data Input buffer of data to write to ring buffer 67 | * @param size Number of bytes to write to ring buffer, from 'data' 68 | * @returns Number of bytes successfully written to buffer 69 | */ 70 | uint32_t ringbuf_write(ringbuf_t *rb, uint8_t *data, uint32_t size); 71 | 72 | /*! 73 | * @brief Read data from ring buffer 74 | * 75 | * @param rb Pointer to ring buffer object created with ringbuf_create 76 | * @param data Output buffer of data to write from ring buffer. 77 | * Can be NULL, in which case data is discarded. 78 | * @param size Number of bytes to read from ring buffer, to store in 'data' 79 | * @returns Number of bytes successfully read to buffer or discarded 80 | */ 81 | uint32_t ringbuf_read(ringbuf_t *rb, uint8_t *data, uint32_t size); 82 | 83 | /*! 84 | * @brief Peak data from ring buffer without removing it 85 | * 86 | * @param rb Pointer to ring buffer object created with ringbuf_create 87 | * @param data Output buffer of data to write from ring buffer. 88 | * @param size Number of bytes to read from ring buffer, to store in 'data' 89 | * @returns Number of bytes successfully read to buffer 90 | */ 91 | uint32_t ringbuf_peek(ringbuf_t *rb, uint8_t *data, uint32_t size); 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /west-freestanding.yml: -------------------------------------------------------------------------------- 1 | # Freestanding Maestro west manifest 2 | # 3 | # Description: 4 | # Used for setting up freestanding Maestro with its components and its 5 | # own Zephyr and only necessary Zephyr components. 6 | # 7 | # How to set up: 8 | # Maestro Initialization 9 | # 1. west init -m --mr --mf west-freestanding.yml 10 | # 2. cd 11 | # 3. west update 12 | # 13 | # For more information, see zephyr/README.rst 14 | # 15 | 16 | manifest: 17 | version: "1.2" 18 | 19 | projects: 20 | # Audio libraries used by Maestro 21 | - name: vit 22 | description: | 23 | VIT library making voice command recognition. 24 | url: https://github.com/nxp-mcuxpresso/VIT.git 25 | path: vit 26 | revision: 24.12.00 27 | 28 | - name: audio_voice_components 29 | description: | 30 | NXP audio libraries (encoders, decoders, libraries) 31 | url: https://github.com/nxp-mcuxpresso/audio-voice-components 32 | path: audio_voice_components 33 | revision: 24.12.00 34 | 35 | # Zephyr project 36 | - name: zephyr 37 | url: https://github.com/zephyrproject-rtos/zephyr.git 38 | path: zephyr 39 | revision: v4.0.0 40 | import: 41 | name-whitelist: 42 | - hal_nxp 43 | - cmsis 44 | - cmsis-dsp 45 | - segger 46 | self: 47 | path: maestro -------------------------------------------------------------------------------- /west.yml: -------------------------------------------------------------------------------- 1 | # Maestro west manifest 2 | # 3 | # Description: 4 | # Used for setting up maestro directly from Zephyr manifest 5 | # 6 | # Append into the Zephyr's manifest, project part: 7 | # - name: maestro 8 | # url: 9 | # path: modules/audio/maestro 10 | # revision: 11 | # import: west.yml 12 | # 13 | # For more information, see zephyr/README.rst 14 | # 15 | 16 | manifest: 17 | version: "1.2" 18 | 19 | projects: 20 | # Audio libraries used by Maestro 21 | - name: vit 22 | description: | 23 | VIT library making voice recognition. 24 | url: https://github.com/nxp-mcuxpresso/VIT 25 | path: modules/audio/vit 26 | revision: 24.12.00 27 | 28 | - name: audio_voice_components 29 | description: | 30 | NXP audio libraries (encoders, decoders, libraries) 31 | url: https://github.com/nxp-mcuxpresso/audio-voice-components 32 | path: modules/audio/audio_voice_components 33 | revision: 24.12.00 34 | self: 35 | path: maestro -------------------------------------------------------------------------------- /zephyr/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | menuconfig MAESTRO_AUDIO_FRAMEWORK 5 | bool "Audio Maestro framework support" 6 | select EVENTS # Maestro uses Events API for signaling. It is not enabled in Zephyr by default 7 | help 8 | This option enables the audio Maestro framework 9 | 10 | if MAESTRO_AUDIO_FRAMEWORK 11 | 12 | menu "Elements" 13 | config MAESTRO_ELEMENTS_ALL_ENABLE 14 | bool "Enables all supported elements" 15 | default n 16 | select MAESTRO_ELEMENT_MEM_SRC_ENABLE 17 | select MAESTRO_ELEMENT_MEM_SINK_ENABLE 18 | select MAESTRO_ELEMENT_AUDIO_SRC_ENABLE 19 | select MAESTRO_ELEMENT_AUDIO_SINK_ENABLE 20 | select MAESTRO_ELEMENT_PROCESS_SINK_ENABLE 21 | select MAESTRO_ELEMENT_DECODER_ENABLE 22 | select MAESTRO_ELEMENT_ENCODER_ENABLE 23 | 24 | config MAESTRO_ELEMENT_MEM_SRC_ENABLE 25 | bool "Memory source" 26 | default n 27 | 28 | config MAESTRO_ELEMENT_MEM_SINK_ENABLE 29 | bool "Memory sink" 30 | default n 31 | 32 | config MAESTRO_ELEMENT_AUDIO_SRC_ENABLE 33 | bool "Audio source" 34 | default n 35 | 36 | config MAESTRO_ELEMENT_AUDIO_SINK_ENABLE 37 | bool "Audio sink" 38 | default n 39 | 40 | menuconfig MAESTRO_ELEMENT_PROCESS_SINK_ENABLE 41 | bool "Process sink" 42 | default n 43 | if MAESTRO_ELEMENT_PROCESS_SINK_ENABLE 44 | config MAESTRO_ELEMENT_PROCESS_SINK_VIT_ENABLE 45 | bool "Enable VIT library" 46 | select NXP_VIT 47 | endif # MAESTRO_ELEMENT_PROCESS_SINK_ENABLE 48 | 49 | menuconfig MAESTRO_ELEMENT_DECODER_ENABLE 50 | bool "Decoder" 51 | default n 52 | select MAESTRO_CCI_ENABLE 53 | if MAESTRO_ELEMENT_DECODER_ENABLE 54 | config MAESTRO_ELEMENT_DECODER_MP3_ENABLE 55 | bool "MP3 decoder" 56 | select NXP_AUDIO_VOICE_COMPONENTS_DECODER_MP3 57 | default n 58 | config MAESTRO_ELEMENT_DECODER_WAV_ENABLE 59 | bool "WAV decoder" 60 | select NXP_AUDIO_VOICE_COMPONENTS_DECODER_WAV 61 | default n 62 | config MAESTRO_ELEMENT_DECODER_FLAC_ENABLE 63 | bool "FLAC decoder" 64 | select NXP_AUDIO_VOICE_COMPONENTS_DECODER_FLAC 65 | default n 66 | config MAESTRO_ELEMENT_DECODER_AAC_ENABLE 67 | bool "AAC decoder" 68 | select NXP_AUDIO_VOICE_COMPONENTS_DECODER_AAC 69 | default n 70 | config MAESTRO_ELEMENT_DECODER_OPUS_OGG_ENABLE 71 | bool "OPUS decoder using OGG" 72 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS 73 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS_OGG 74 | select NXP_AUDIO_VOICE_COMPONENTS_OPUSFILE 75 | default n 76 | config MAESTRO_ELEMENT_DECODER_OPUS_ENABLE 77 | bool "OPUS decoder" 78 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS 79 | default n 80 | endif # MAESTRO_ELEMENT_DECODER_ENABLE 81 | 82 | menuconfig MAESTRO_ELEMENT_ENCODER_ENABLE 83 | bool "Encoder" 84 | default n 85 | select MAESTRO_CEI_ENABLE 86 | select MAESTRO_CCI_ENABLE 87 | if MAESTRO_ELEMENT_ENCODER_ENABLE 88 | config MAESTRO_ELEMENT_ENCODER_OPUS_OGG_ENABLE 89 | bool "OPUS encoder using OGG" 90 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS 91 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS_OGG 92 | select NXP_AUDIO_VOICE_COMPONENTS_OPUSFILE 93 | default n 94 | config MAESTRO_ELEMENT_ENCODER_OPUS_ENABLE 95 | bool "OPUS encoder" 96 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS 97 | select NXP_AUDIO_VOICE_COMPONENTS_OPUS_OGG 98 | select NXP_AUDIO_VOICE_COMPONENTS_OPUSFILE 99 | endif # MAESTRO_ELEMENT_ENCODER_ENABLE 100 | 101 | # config MAESTRO_ELEMENT_AUDIO_PROC_ENABLE 102 | # bool "Audio process" 103 | # default n 104 | 105 | # config MAESTRO_ELEMENT_VOICE_SEEKER_ENABLE 106 | # bool "Enables VoiceSeeker processing element" 107 | # select MAESTRO_ENABLE_ELEMENT_AUDIO_PROC 108 | # default n 109 | 110 | # config MAESTRO_ELEMENT_FILE_SINK_ENABLE 111 | # bool "File sink" 112 | # default n 113 | 114 | # config MAESTRO_ELEMENT_FILE_SRC_ENABLE 115 | # bool "File source" 116 | # default n 117 | 118 | # config MAESTRO_ELEMENT_NETBUF_SRC_ENABLE 119 | # bool "Netbuf source" 120 | # default n 121 | 122 | endmenu # Elements 123 | 124 | config MAESTRO_CCI_ENABLE 125 | bool "Enables Common codec interface" 126 | select MAESTRO_CEI_ENABLE # dependency on common API 127 | default n 128 | 129 | config MAESTRO_CEI_ENABLE 130 | bool "Enables Common encoder interface" 131 | default n 132 | 133 | config MAESTRO_RTOS_ZEPHYR 134 | bool 135 | default y 136 | 137 | endif # MAESTRO_AUDIO_FRAMEWORK 138 | 139 | -------------------------------------------------------------------------------- /zephyr/audioTracks/Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/audioTracks/Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.raw -------------------------------------------------------------------------------- /zephyr/audioTracks/Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/audioTracks/Tone_CH0_440HZ_CH1_660HZ_48KHZ_2CHAN_16b.wav -------------------------------------------------------------------------------- /zephyr/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS = --conf-dir ./ 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = ../ 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /zephyr/doc/conf.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Configuration file for the Sphinx documentation builder. 5 | # 6 | # For the full list of built-in configuration values, see the documentation: 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 8 | 9 | # -- Project information ----------------------------------------------------- 10 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 11 | project = 'Maestro on Zephyr' 12 | copyright = '2024' 13 | author = 'NXP' 14 | 15 | master_doc = 'README' 16 | 17 | # -- General configuration --------------------------------------------------- 18 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 19 | 20 | extensions = [] 21 | 22 | templates_path = [] 23 | exclude_patterns = [] 24 | 25 | 26 | 27 | # -- Options for HTML output ------------------------------------------------- 28 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 29 | 30 | html_theme = 'alabaster' 31 | -------------------------------------------------------------------------------- /zephyr/doc/doc/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file records the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 5c077b9486e521d089fac92a3aaf8bb6 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/environment.pickle -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/samples/record_ram/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/samples/record_ram/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/samples/record_vit/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/samples/record_vit/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/tests/decoder/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/tests/decoder/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/tests/encoder/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/tests/encoder/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/.doctrees/tests/memToMem/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/.doctrees/tests/memToMem/README.doctree -------------------------------------------------------------------------------- /zephyr/doc/doc/_sources/samples/record_ram/README.rst.txt: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_record_ram: 2 | 3 | ######################################################## 4 | Maestro sample for recording data from microphone to RAM 5 | ######################################################## 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | This sample records data from microphone (alias ``dmic0`` in devicetree) and stores them to a buffer in RAM. 12 | 13 | Currently one PDM channel with fixed 16 kHz sample rate and 16 bit sample width is supported. 14 | 15 | For configuration options, see Kconfig and prj.conf. 16 | 17 | ***************** 18 | User Input/Output 19 | ***************** 20 | 21 | * Input: 22 | 23 | None. 24 | 25 | * Output: 26 | 27 | UART Output: 28 | 29 | * ``Demo result: OK`` if everything went OK 30 | * ``Demo result: FAIL`` otherwise 31 | 32 | ******************* 33 | Supported platforms 34 | ******************* 35 | 36 | Currently tested for: 37 | 38 | * RD_RW612_BGA. 39 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_sources/samples/record_vit/README.rst.txt: -------------------------------------------------------------------------------- 1 | .. _Maestro_sample_record_vit: 2 | 3 | ######################################## 4 | Maestro voice detection sample using VIT 5 | ######################################## 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Records data from microphone (alias ``dmic0`` in devicetree) and detects voice commands from selected language model. Detected commands are printed via UART. 12 | 13 | Language model may be changed via Kconfig using ``CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE`` selection. For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 14 | 15 | This project requires an NXP board supported by the VIT library. 16 | 17 | The example has to be modified if a new board needs to be added. Please create an issue in that case. 18 | 19 | ***************** 20 | User Input/Output 21 | ***************** 22 | 23 | * Input: 24 | 25 | None. 26 | 27 | * Output: 28 | 29 | UART Output: 30 | 31 | * List of voice commands the model can detect (printed immediately after start) 32 | * ```` if voice command was detected 33 | * ``Demo result: FAIL`` otherwise 34 | 35 | ************ 36 | Dependencies 37 | ************ 38 | 39 | * VIT library: https://www.nxp.com/design/design-center/software/embedded-software/voice-intelligent-technology-wake-word-and-voice-command-engines:VOICE-INTELLIGENT-TECHNOLOGY 40 | 41 | ******************* 42 | Supported platforms 43 | ******************* 44 | 45 | Currently tested for: 46 | 47 | * RD_RW612_BGA. 48 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_sources/tests/decoder/README.rst.txt: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_decoder: 2 | 3 | ###################### 4 | Maestro decoder sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests and demonstrates decoder functionality in Maestro pipeline. 12 | 13 | Supported decoders: 14 | 15 | * MP3 16 | * WAV 17 | * AAC 18 | * FLAC 19 | * OPUS with OGG envelop 20 | * (RAW OPUS - TBD) 21 | 22 | Data Input: 23 | 24 | * Prepared encoded audio data (part of Maestro repository, folder ``zephyr/audioTracks``) 25 | * Prepared decoded audio data (RAW PCM format, part of Maestro repository, folder ``zephyr/audioTracks``) 26 | 27 | Function: 28 | 29 | #. Loads encoded data into source buffer stored in RAM 30 | #. Decodes audio data using selected decoder and stores data in RAM 31 | #. Compares prepared data with decoded data to check if its the same 32 | #. Prints ``Demo result: OK`` or ``Demo result: FAIL`` via UART 33 | 34 | ***************** 35 | User Input/Output 36 | ***************** 37 | 38 | * Input: 39 | 40 | None 41 | 42 | * Output: 43 | 44 | UART Output 45 | 46 | * ``Demo result: OK`` if everything went OK 47 | * ``Demo result: FAIL`` otherwise 48 | 49 | ************ 50 | Dependencies 51 | ************ 52 | 53 | * Audio voice component library (pulled in by Maestro's west), containing Decoder libraries 54 | 55 | ************* 56 | Configuration 57 | ************* 58 | 59 | * See ``prj.conf`` for user input sections 60 | 61 | * Selecting decoder may be done by enabling ``CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_`` in ``prj.conf`` file. When no decoder is selected, default one (WAV) is used instead. 62 | 63 | * System settings should be modified (stack size, heap size) based on selected decoder and system capabilities/requirements in ``prj.conf``. 64 | 65 | * For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 66 | 67 | ******************* 68 | Supported platforms 69 | ******************* 70 | 71 | Currently tested for: 72 | 73 | * RD_RW612_BGA - Working decoders: FLAC, WAV, OPUS OGG -------------------------------------------------------------------------------- /zephyr/doc/doc/_sources/tests/encoder/README.rst.txt: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_encoder: 2 | 3 | ###################### 4 | Maestro encoder sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests and demonstrates encoder functionality in Maestro pipeline. 12 | 13 | Supported encoders: 14 | * OPUS with OGG envelop - TBD 15 | * RAW OPUS - TBD 16 | 17 | Input: 18 | 19 | * Prepared decoded audio data (RAW PCM format, part of Maestro repository) 20 | * Prepared encoded audio data (part of Maestro repository) 21 | 22 | Function: 23 | 24 | #. Loads RAW data into source buffer stored in RAM 25 | #. Encodes audio data using selected encoder and stores data in RAM 26 | #. Compares prepared data with decoded data if same 27 | #. Prints ``Demo result: OK`` or ``Demo result: FAIL`` via UART 28 | 29 | ************ 30 | Dependencies 31 | ************ 32 | 33 | - Audio voice component library (pulled in by Maestro's west), containing Encoder libraries 34 | 35 | ***************** 36 | User Input/Output 37 | ***************** 38 | 39 | Input: 40 | 41 | - None 42 | 43 | Output: 44 | 45 | - UART Output 46 | 47 | - ``Demo result: OK`` if everything went OK 48 | - ``Demo result: FAIL`` otherwise 49 | 50 | ************* 51 | Configuration 52 | ************* 53 | 54 | * ``See prj.conf`` for user input sections 55 | 56 | * Selecting encoder may be done by enabling ``CONFIG_MAESTRO_EXAMPLE_ENCODER_SELECTED_`` in ``prj.conf`` file. When no encoder is selected, default one (OPUS) is used instead. 57 | 58 | * System settings should be modified (stack size, heap size) based on selected encoder and system capabilities/requirements in ``prj.conf`` file. 59 | 60 | * For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 61 | 62 | ******************* 63 | Supported platforms 64 | ******************* 65 | 66 | Currently tested for: 67 | 68 | * RD_RW612_BGA - Working encoders: None. 69 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_sources/tests/memToMem/README.rst.txt: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_memtomem: 2 | 3 | ###################### 4 | Maestro mem2mem sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests basic memory to memory pipeline. 12 | 13 | **Function:** 14 | 15 | #. Moves generated data with fixed size of 256B from memory source to memory sink. 16 | #. Compares copied data to check if they're the same. 17 | #. Returns ``Demo result: OK`` or ``Demo result: FAIL`` via UART. 18 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/custom.css: -------------------------------------------------------------------------------- 1 | /* This file intentionally left blank. */ 2 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Base JavaScript utilities for all Sphinx HTML documentation. 3 | */ 4 | "use strict"; 5 | 6 | const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ 7 | "TEXTAREA", 8 | "INPUT", 9 | "SELECT", 10 | "BUTTON", 11 | ]); 12 | 13 | const _ready = (callback) => { 14 | if (document.readyState !== "loading") { 15 | callback(); 16 | } else { 17 | document.addEventListener("DOMContentLoaded", callback); 18 | } 19 | }; 20 | 21 | /** 22 | * Small JavaScript module for the documentation. 23 | */ 24 | const Documentation = { 25 | init: () => { 26 | Documentation.initDomainIndexTable(); 27 | Documentation.initOnKeyListeners(); 28 | }, 29 | 30 | /** 31 | * i18n support 32 | */ 33 | TRANSLATIONS: {}, 34 | PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), 35 | LOCALE: "unknown", 36 | 37 | // gettext and ngettext don't access this so that the functions 38 | // can safely bound to a different name (_ = Documentation.gettext) 39 | gettext: (string) => { 40 | const translated = Documentation.TRANSLATIONS[string]; 41 | switch (typeof translated) { 42 | case "undefined": 43 | return string; // no translation 44 | case "string": 45 | return translated; // translation exists 46 | default: 47 | return translated[0]; // (singular, plural) translation tuple exists 48 | } 49 | }, 50 | 51 | ngettext: (singular, plural, n) => { 52 | const translated = Documentation.TRANSLATIONS[singular]; 53 | if (typeof translated !== "undefined") 54 | return translated[Documentation.PLURAL_EXPR(n)]; 55 | return n === 1 ? singular : plural; 56 | }, 57 | 58 | addTranslations: (catalog) => { 59 | Object.assign(Documentation.TRANSLATIONS, catalog.messages); 60 | Documentation.PLURAL_EXPR = new Function( 61 | "n", 62 | `return (${catalog.plural_expr})` 63 | ); 64 | Documentation.LOCALE = catalog.locale; 65 | }, 66 | 67 | /** 68 | * helper function to focus on search bar 69 | */ 70 | focusSearchBar: () => { 71 | document.querySelectorAll("input[name=q]")[0]?.focus(); 72 | }, 73 | 74 | /** 75 | * Initialise the domain index toggle buttons 76 | */ 77 | initDomainIndexTable: () => { 78 | const toggler = (el) => { 79 | const idNumber = el.id.substr(7); 80 | const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); 81 | if (el.src.substr(-9) === "minus.png") { 82 | el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; 83 | toggledRows.forEach((el) => (el.style.display = "none")); 84 | } else { 85 | el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; 86 | toggledRows.forEach((el) => (el.style.display = "")); 87 | } 88 | }; 89 | 90 | const togglerElements = document.querySelectorAll("img.toggler"); 91 | togglerElements.forEach((el) => 92 | el.addEventListener("click", (event) => toggler(event.currentTarget)) 93 | ); 94 | togglerElements.forEach((el) => (el.style.display = "")); 95 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); 96 | }, 97 | 98 | initOnKeyListeners: () => { 99 | // only install a listener if it is really needed 100 | if ( 101 | !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && 102 | !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS 103 | ) 104 | return; 105 | 106 | document.addEventListener("keydown", (event) => { 107 | // bail for input elements 108 | if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; 109 | // bail with special keys 110 | if (event.altKey || event.ctrlKey || event.metaKey) return; 111 | 112 | if (!event.shiftKey) { 113 | switch (event.key) { 114 | case "ArrowLeft": 115 | if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; 116 | 117 | const prevLink = document.querySelector('link[rel="prev"]'); 118 | if (prevLink && prevLink.href) { 119 | window.location.href = prevLink.href; 120 | event.preventDefault(); 121 | } 122 | break; 123 | case "ArrowRight": 124 | if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; 125 | 126 | const nextLink = document.querySelector('link[rel="next"]'); 127 | if (nextLink && nextLink.href) { 128 | window.location.href = nextLink.href; 129 | event.preventDefault(); 130 | } 131 | break; 132 | } 133 | } 134 | 135 | // some keyboard layouts may need Shift to get / 136 | switch (event.key) { 137 | case "/": 138 | if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; 139 | Documentation.focusSearchBar(); 140 | event.preventDefault(); 141 | } 142 | }); 143 | }, 144 | }; 145 | 146 | // quick alias for translations 147 | const _ = Documentation.gettext; 148 | 149 | _ready(Documentation.init); 150 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | const DOCUMENTATION_OPTIONS = { 2 | VERSION: '', 3 | LANGUAGE: 'en', 4 | COLLAPSE_INDEX: false, 5 | BUILDER: 'html', 6 | FILE_SUFFIX: '.html', 7 | LINK_SUFFIX: '.html', 8 | HAS_SOURCE: true, 9 | SOURCELINK_SUFFIX: '.txt', 10 | NAVIGATION_WITH_KEYS: false, 11 | SHOW_SEARCH_SUMMARY: true, 12 | ENABLE_SEARCH_SHORTCUTS: true, 13 | }; -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/_static/file.png -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/github-banner.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/_static/minus.png -------------------------------------------------------------------------------- /zephyr/doc/doc/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/_static/plus.png -------------------------------------------------------------------------------- /zephyr/doc/doc/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Index — Maestro on Zephyr documentation 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
29 | 30 | 31 |
32 | 33 | 34 |

Index

35 | 36 |
37 | 38 |
39 | 40 | 41 |
42 | 43 |
44 |
45 | 92 |
93 |
94 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /zephyr/doc/doc/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nxp-mcuxpresso/maestro/05ef474e9799bf5c62638c41bb0b0e10b011b3b6/zephyr/doc/doc/objects.inv -------------------------------------------------------------------------------- /zephyr/doc/doc/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Search — Maestro on Zephyr documentation 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 |
36 | 37 | 38 |
39 | 40 |

Search

41 | 42 | 50 | 51 | 52 |

53 | Searching for multiple words only shows matches that contain 54 | all words. 55 |

56 | 57 | 58 |
59 | 60 | 61 | 62 |
63 | 64 | 65 |
66 | 67 | 68 |
69 | 70 |
71 |
72 | 110 |
111 |
112 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /zephyr/doc/doc/tests/memToMem/README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Maestro mem2mem sample — Maestro on Zephyr documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 | 33 |
34 | 35 |
36 |

Maestro mem2mem sample

37 |
38 |

Description

39 |

Tests basic memory to memory pipeline.

40 |

Function:

41 |
    42 |
  1. Moves generated data with fixed size of 256B from memory source to memory sink.

  2. 43 |
  3. Compares copied data to check if they’re the same.

  4. 44 |
  5. Returns Demo result: OK or Demo result: FAIL via UART.

  6. 45 |
46 |
47 |
48 | 49 | 50 |
51 | 52 |
53 |
54 | 105 |
106 |
107 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /zephyr/doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=../ 11 | set BUILDDIR=doc/ 12 | set CONFIGDIR=./ 13 | 14 | %SPHINXBUILD% >NUL 2>NUL 15 | if errorlevel 9009 ( 16 | echo. 17 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 18 | echo.installed, then set the SPHINXBUILD environment variable to point 19 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 20 | echo.may add the Sphinx directory to PATH. 21 | echo. 22 | echo.If you don't have Sphinx installed, grab it from 23 | echo.https://www.sphinx-doc.org/ 24 | exit /b 1 25 | ) 26 | 27 | if "%1" == "" goto help 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% --conf-dir %CONFIGDIR% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% --conf-dir %CONFIGDIR% %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 34 | 35 | :end 36 | popd 37 | 38 | pause 39 | -------------------------------------------------------------------------------- /zephyr/module.yml: -------------------------------------------------------------------------------- 1 | name: maestro 2 | build: 3 | cmake: ./zephyr/ 4 | kconfig: ./zephyr/Kconfig 5 | # depends: 6 | # - hal_nxp 7 | samples: 8 | - ./zephyr/samples 9 | tests: 10 | - ./zephyr/tests 11 | -------------------------------------------------------------------------------- /zephyr/samples/record_ram/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.20.0) 5 | 6 | add_compile_definitions(FSL_OSA_TASK_ENABLE=1) 7 | set(CONFIG_USE_component_osa_zephyr true) 8 | 9 | # Explicitelly enforcing to find specific Zephyr installation 10 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 11 | project(maestro_record_ram) 12 | 13 | # Target_sources must be specified directly after find_package. Target "app" 14 | target_sources(app PRIVATE src/main.c) 15 | target_sources(app PRIVATE src/app_streamer_element_pcm.c) 16 | 17 | target_include_directories(app PRIVATE src/) -------------------------------------------------------------------------------- /zephyr/samples/record_ram/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | menu "Maestro Record RAM Example" 5 | depends on MAESTRO_AUDIO_FRAMEWORK 6 | 7 | config MAESTRO_EXAMPLE_MAESTRO_LOGGING_ON 8 | bool "Turns on logging of Maestro library" 9 | default n 10 | 11 | config MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B 12 | int "Stack size of streamer task running the pipeline." 13 | default 4096 14 | 15 | config MAESTRO_EXAMPLE_RECORD_TIME_MS 16 | int "Maestro Record example - Approximate record time [ms]" 17 | default 2000 18 | 19 | endmenu 20 | 21 | source "Kconfig.zephyr" -------------------------------------------------------------------------------- /zephyr/samples/record_ram/README.rst: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_record_ram: 2 | 3 | ######################################################## 4 | Maestro sample for recording data from microphone to RAM 5 | ######################################################## 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | This sample records data from microphone (alias ``dmic0`` in devicetree) and stores them to a buffer in RAM. 12 | 13 | Currently one PDM channel with fixed 16 kHz sample rate and 16 bit sample width is supported. 14 | 15 | For configuration options, see Kconfig and prj.conf. 16 | 17 | ***************** 18 | User Input/Output 19 | ***************** 20 | 21 | * Input: 22 | 23 | None. 24 | 25 | * Output: 26 | 27 | UART Output: 28 | 29 | * ``Demo result: OK`` if everything went OK 30 | * ``Demo result: FAIL`` otherwise 31 | 32 | ******************* 33 | Supported platforms 34 | ******************* 35 | 36 | Currently tested for: 37 | 38 | * RD_RW612_BGA. 39 | -------------------------------------------------------------------------------- /zephyr/samples/record_ram/prj.conf: -------------------------------------------------------------------------------- 1 | # Maestro and OSA configuration 2 | CONFIG_MAESTRO_AUDIO_FRAMEWORK=y 3 | 4 | # Enable maestro's specific elements 5 | CONFIG_MAESTRO_ELEMENT_MEM_SINK_ENABLE=y 6 | CONFIG_MAESTRO_ELEMENT_AUDIO_SRC_ENABLE=y 7 | 8 | # Example settings 9 | CONFIG_MAESTRO_EXAMPLE_RECORD_TIME_MS=2000 10 | 11 | # System settings - Memory space 12 | # May be tuned according to platform capabilities 13 | CONFIG_HEAP_MEM_POOL_SIZE=60000 14 | CONFIG_MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B=4096 15 | CONFIG_MAIN_STACK_SIZE=40096 16 | 17 | # System settings 18 | CONFIG_SYS_HEAP_ALLOC_LOOPS=12 19 | CONFIG_SYS_HEAP_AUTO=y 20 | CONFIG_MAIN_THREAD_PRIORITY=10 21 | 22 | # DMIC driver 23 | CONFIG_AUDIO=y 24 | CONFIG_AUDIO_DMIC=y 25 | -------------------------------------------------------------------------------- /zephyr/samples/record_ram/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: Records data from microphone and stores into RAM memory 3 | name: Maestro record into RAM 4 | common: 5 | tags: audio maestro 6 | depends_on: dmic 7 | arch_allow: arm 8 | tests: 9 | maestro.sample.record.ram: 10 | integration_platforms: 11 | - rd_rw612_bga 12 | timeout: 3 13 | harness: console 14 | harness_config: 15 | type: one_line 16 | regex: 17 | - "OK" 18 | min_ram: 65 19 | min_flash: 190 20 | 21 | -------------------------------------------------------------------------------- /zephyr/samples/record_vit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.20.0) 5 | 6 | add_compile_definitions(FSL_OSA_TASK_ENABLE=1) 7 | set(CONFIG_USE_component_osa_zephyr true) 8 | 9 | # Explicitelly enforcing to find specific Zephyr installation 10 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 11 | project(maestro_record_vit) 12 | 13 | # Target_sources must be specified directly after find_package. Target "app" 14 | target_sources(app PRIVATE src/main.c) 15 | target_sources(app PRIVATE src/app_streamer_element_pcm.c) 16 | target_sources(app PRIVATE src/app_streamer_element_vit.c) 17 | 18 | target_include_directories(app PRIVATE src/) -------------------------------------------------------------------------------- /zephyr/samples/record_vit/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | menu "Maestro VIT Example" 5 | depends on MAESTRO_AUDIO_FRAMEWORK 6 | 7 | config MAESTRO_EXAMPLE_MAESTRO_LOGGING_ON 8 | bool "Turns on Maestro library logging" 9 | default n 10 | 11 | config MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B 12 | int "Stack size of streamer task running the pipeline." 13 | default 4096 14 | 15 | choice MAESTRO_EXAMPLE_VIT_LANGUAGE 16 | prompt "VIT languages support" 17 | default MAESTRO_EXAMPLE_VIT_LANGUAGE_EN_ENABLE 18 | 19 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_EN_ENABLE 20 | bool "Enables English language pack" 21 | 22 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_CN_ENABLE 23 | bool "Enables Chinese language pack" 24 | 25 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_DE_ENABLE 26 | bool "Enables Deutch language pack" 27 | 28 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_ES_ENABLE 29 | bool "Enables Espanol language pack" 30 | 31 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_FR_ENABLE 32 | bool "Enables French language pack" 33 | 34 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_IT_ENABLE 35 | bool "Enables Italian language pack" 36 | 37 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_JA_ENABLE 38 | bool "Enables Japaneese language pack" 39 | 40 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_KO_ENABLE 41 | bool "Enables Korean language pack" 42 | 43 | config MAESTRO_EXAMPLE_VIT_LANGUAGE_TR_ENABLE 44 | bool "Enables Turkish language pack" 45 | 46 | endchoice 47 | endmenu 48 | 49 | source "Kconfig.zephyr" -------------------------------------------------------------------------------- /zephyr/samples/record_vit/README.rst: -------------------------------------------------------------------------------- 1 | .. _Maestro_sample_record_vit: 2 | 3 | ######################################## 4 | Maestro voice detection sample using VIT 5 | ######################################## 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Records data from microphone (alias ``dmic0`` in devicetree) and detects voice commands from selected language model. Detected commands are printed via UART. 12 | 13 | Language model may be changed via Kconfig using ``CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE`` selection. For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 14 | 15 | This project requires an NXP board supported by the VIT library. 16 | 17 | The example has to be modified if a new board needs to be added. Please create an issue in that case. 18 | 19 | ***************** 20 | User Input/Output 21 | ***************** 22 | 23 | * Input: 24 | 25 | None. 26 | 27 | * Output: 28 | 29 | UART Output: 30 | 31 | * List of voice commands the model can detect (printed immediately after start) 32 | * ```` if voice command was detected 33 | * ``Demo result: FAIL`` otherwise 34 | 35 | ************ 36 | Dependencies 37 | ************ 38 | 39 | * VIT library: https://www.nxp.com/design/design-center/software/embedded-software/voice-intelligent-technology-wake-word-and-voice-command-engines:VOICE-INTELLIGENT-TECHNOLOGY 40 | 41 | ******************* 42 | Supported platforms 43 | ******************* 44 | 45 | Currently tested for: 46 | 47 | * RD_RW612_BGA. 48 | -------------------------------------------------------------------------------- /zephyr/samples/record_vit/prj.conf: -------------------------------------------------------------------------------- 1 | # Maestro and OSA configuration 2 | CONFIG_MAESTRO_AUDIO_FRAMEWORK=y 3 | 4 | # Enable maestro's specific elements 5 | CONFIG_MAESTRO_ELEMENT_AUDIO_SRC_ENABLE=y 6 | CONFIG_MAESTRO_ELEMENT_PROCESS_SINK_ENABLE=y 7 | CONFIG_MAESTRO_ELEMENT_PROCESS_SINK_VIT_ENABLE=y 8 | 9 | # ============================================= 10 | # = USER INPUT NEEDED 11 | # ============================================= 12 | # Select one precompiled VIT language model pack. 13 | CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_EN_ENABLE=y 14 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_CN_ENABLE=y 15 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_DE_ENABLE=y 16 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_ES_ENABLE=y 17 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_FR_ENABLE=y 18 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_IT_ENABLE=y 19 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_JA_ENABLE=y 20 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_KO_ENABLE=y 21 | # CONFIG_MAESTRO_EXAMPLE_VIT_LANGUAGE_TR_ENABLE=y 22 | # ============================================= 23 | 24 | # System settings - Memory space 25 | # May be tuned according to platform capabilities 26 | CONFIG_HEAP_MEM_POOL_SIZE=350000 27 | CONFIG_MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B=4096 28 | CONFIG_MAIN_STACK_SIZE=20000 29 | 30 | # System settings 31 | CONFIG_SYS_HEAP_ALLOC_LOOPS=12 32 | CONFIG_SYS_HEAP_AUTO=y 33 | CONFIG_MAIN_THREAD_PRIORITY=10 34 | CONFIG_CMSIS_DSP=y 35 | CONFIG_CMSIS_DSP_MATRIX=y 36 | CONFIG_FP_HARDABI=y 37 | CONFIG_FPU=y 38 | 39 | # DMIC driver 40 | CONFIG_AUDIO=y 41 | CONFIG_AUDIO_DMIC=y 42 | -------------------------------------------------------------------------------- /zephyr/samples/record_vit/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: Records data from microphone and detects voice commands in selected language using VIT library 3 | name: Maestro voice recognition sample (VIT) 4 | common: 5 | tags: audio maestro vit 6 | depends_on: dmic 7 | arch_allow: arm 8 | tests: 9 | maestro.sample.record.vit: 10 | integration_platforms: 11 | - rd_rw612_bga 12 | platform_allow: 13 | - rd_rw612_bga 14 | harness: console 15 | timeout: 1 16 | harness_config: 17 | type: one_line 18 | regex: 19 | - "Number of channels supported by VIT lib" 20 | min_ram: 470 21 | min_flash: 400 -------------------------------------------------------------------------------- /zephyr/samples/record_vit/src/app_streamer_element_vit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 NXP 3 | * All rights reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | * 7 | * @file app_Streamer_element_pcm.c 8 | * @brief Implementation of application dependent vit element 9 | */ 10 | 11 | #ifndef _STREAMER_ELEMENT_VIT_H_ 12 | #define _STREAMER_ELEMENT_VIT_H_ 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #include "PL_platformTypes_CortexM.h" 19 | #include "VIT.h" 20 | 21 | typedef int (*VIT_Initialize_T)(void *arg); 22 | typedef int (*VIT_Execute_T)(void *arg, void *inputBuffer, int size); 23 | typedef int (*VIT_Deinit_T)(void); 24 | 25 | extern VIT_Initialize_T VIT_Initialize_func; 26 | extern VIT_Execute_T VIT_Execute_func; 27 | extern VIT_Deinit_T VIT_Deinit_func; 28 | 29 | #if defined(__cplusplus) 30 | } 31 | #endif 32 | 33 | #endif // _STREAMER_ELEMENT_VIT_H_ 34 | -------------------------------------------------------------------------------- /zephyr/tests/decoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.20.0) 5 | 6 | add_compile_definitions(FSL_OSA_TASK_ENABLE=1) 7 | set(CONFIG_USE_component_osa_zephyr true) 8 | 9 | # Explicitelly enforcing to find specific Zephyr installation 10 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 11 | project(maestro_decoder) 12 | 13 | # Target_sources must be specified directly after find_package. Target "app" 14 | target_sources(app PRIVATE src/main.c) 15 | 16 | zephyr_include_directories(${ZEPHYR_MAESTRO_MODULE_DIR}/zephyr/audioTracks) 17 | -------------------------------------------------------------------------------- /zephyr/tests/decoder/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | menu "Maestro Decoder Test" 5 | depends on MAESTRO_AUDIO_FRAMEWORK 6 | 7 | config MAESTRO_EXAMPLE_MAESTRO_LOGGING_ON 8 | bool "Turns on Maestro library logging" 9 | default n 10 | 11 | config MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B 12 | int "Stack size of streamer task running the pipeline." 13 | default 160000 14 | 15 | config MAESTRO_EXAMPLE_DECODER_SELECTED 16 | bool 17 | default n 18 | help 19 | True if any decoder is enabled. 20 | 21 | choice MAESTRO_EXAMPLE_DECODER_SELECTION 22 | prompt "Decoder library selection" 23 | default MAESTRO_EXAMPLE_DECODER_SELECTED_WAV 24 | 25 | config MAESTRO_EXAMPLE_DECODER_SELECTED_MP3 26 | bool "MP3 decoder" 27 | select MAESTRO_ELEMENT_DECODER_MP3_ENABLE 28 | config MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS 29 | bool "OPUS decoder" 30 | select MAESTRO_ELEMENT_DECODER_OPUS_ENABLE 31 | config MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS_OGG 32 | bool "OPUS OGG decoder" 33 | select MAESTRO_ELEMENT_DECODER_OPUS_OGG_ENABLE 34 | config MAESTRO_EXAMPLE_DECODER_SELECTED_WAV 35 | bool "WAV decoder" 36 | select MAESTRO_ELEMENT_DECODER_WAV_ENABLE 37 | config MAESTRO_EXAMPLE_DECODER_SELECTED_FLAC 38 | bool "FLAC decoder" 39 | select MAESTRO_ELEMENT_DECODER_FLAC_ENABLE 40 | config MAESTRO_EXAMPLE_DECODER_SELECTED_AAC 41 | bool "AAC decoder" 42 | select MAESTRO_ELEMENT_DECODER_AAC_ENABLE 43 | endchoice # "Decoder library selection" 44 | 45 | endmenu # "Maestro Decoder Test" 46 | 47 | source "Kconfig.zephyr" -------------------------------------------------------------------------------- /zephyr/tests/decoder/README.rst: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_decoder: 2 | 3 | ###################### 4 | Maestro decoder sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests and demonstrates decoder functionality in Maestro pipeline. 12 | 13 | Supported decoders: 14 | 15 | * MP3 16 | * WAV 17 | * AAC 18 | * FLAC 19 | * OPUS with OGG envelop 20 | * (RAW OPUS - TBD) 21 | 22 | Data Input: 23 | 24 | * Prepared encoded audio data (part of Maestro repository, folder ``zephyr/audioTracks``) 25 | * Prepared decoded audio data (RAW PCM format, part of Maestro repository, folder ``zephyr/audioTracks``) 26 | 27 | Function: 28 | 29 | #. Loads encoded data into source buffer stored in RAM 30 | #. Decodes audio data using selected decoder and stores data in RAM 31 | #. Compares prepared data with decoded data to check if its the same 32 | #. Prints ``Demo result: OK`` or ``Demo result: FAIL`` via UART 33 | 34 | ***************** 35 | User Input/Output 36 | ***************** 37 | 38 | * Input: 39 | 40 | None 41 | 42 | * Output: 43 | 44 | UART Output 45 | 46 | * ``Demo result: OK`` if everything went OK 47 | * ``Demo result: FAIL`` otherwise 48 | 49 | ************ 50 | Dependencies 51 | ************ 52 | 53 | * Audio voice component library (pulled in by Maestro's west), containing Decoder libraries 54 | 55 | ************* 56 | Configuration 57 | ************* 58 | 59 | * See ``prj.conf`` for user input sections 60 | 61 | * Selecting decoder may be done by enabling ``CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_`` in ``prj.conf`` file. When no decoder is selected, default one (WAV) is used instead. 62 | 63 | * System settings should be modified (stack size, heap size) based on selected decoder and system capabilities/requirements in ``prj.conf``. 64 | 65 | * For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 66 | 67 | ******************* 68 | Supported platforms 69 | ******************* 70 | 71 | Currently tested for: 72 | 73 | * RD_RW612_BGA - Working decoders: FLAC, WAV, OPUS OGG -------------------------------------------------------------------------------- /zephyr/tests/decoder/prj.conf: -------------------------------------------------------------------------------- 1 | # Maestro settings 2 | CONFIG_MAESTRO_AUDIO_FRAMEWORK=y 3 | CONFIG_MAESTRO_ELEMENT_MEM_SRC_ENABLE=y 4 | CONFIG_MAESTRO_ELEMENT_MEM_SINK_ENABLE=y 5 | CONFIG_MAESTRO_ELEMENT_DECODER_ENABLE=y 6 | 7 | # ======================================================= 8 | # USER INPUT NEEDED - Decoder selection 9 | # ======================================================= 10 | # Uncomment specific decoder to use it 11 | # Selected automatically whe using twister twister 12 | # CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_MP3=y 13 | # CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS=y 14 | CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS_OGG=y 15 | # CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_WAV=y 16 | # CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_FLAC=y 17 | # CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_AAC=y 18 | # End of USER INPUT 19 | # ======================================================= 20 | 21 | # ======================================================= 22 | # USER INPUT NEEDED - System settings 23 | # ======================================================= 24 | # Values dependent on selected decoder. Adjust accordingly based on your platform/system capabilities/requirements 25 | CONFIG_HEAP_MEM_POOL_SIZE=200000 26 | CONFIG_MAIN_STACK_SIZE=32096 27 | CONFIG_MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B=160000 28 | # End of USER INPUT 29 | # ======================================================= 30 | 31 | # System settings 32 | CONFIG_SYS_HEAP_ALLOC_LOOPS=12 33 | CONFIG_SYS_HEAP_AUTO=y 34 | CONFIG_MAIN_THREAD_PRIORITY=10 35 | CONFIG_CMSIS_DSP=y 36 | CONFIG_CMSIS_DSP_MATRIX=y 37 | CONFIG_FP_HARDABI=y 38 | CONFIG_FPU=y 39 | -------------------------------------------------------------------------------- /zephyr/tests/decoder/src/decoder.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "decoder", 5 | "path": ".." 6 | } 7 | ], 8 | "settings": { 9 | "files.associations": { 10 | "testwav.h": "c", 11 | "testmp3.h": "c", 12 | "fsl_os_abstraction.h": "c", 13 | "fsl_os_abstraction_zephyr.h": "c" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /zephyr/tests/decoder/testcase.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | tags: 3 | - audio 4 | - maestro 5 | harness: console 6 | harness_config: 7 | type: one_line 8 | regex: 9 | - "(.*)Result: OK(.*)" 10 | timeout: 1 11 | integration_platforms: 12 | - rd_rw612_bga 13 | arch_allow: arm 14 | tests: 15 | maestro.test.decoder.mp3: 16 | extra_configs: 17 | - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_MP3=y 18 | filter: (CONFIG_CPU_CORTEX_M33 or CONFIG_CPU_CORTEX_M7) and CONFIG_DSP 19 | # maestro.test.decoder.opus: 20 | # extra_configs: 21 | # - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS=y 22 | maestro.test.decoder.opus_ogg: 23 | extra_configs: 24 | - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_OPUS_OGG=y 25 | # Flash and RAM usage depend on track files sizes 26 | min_flash: 275 27 | min_ram: 336 28 | maestro.test.decoder.wav: 29 | extra_configs: 30 | - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_WAV=y 31 | # Flash and RAM usage depend on track files sizes 32 | min_flash: 265 33 | min_ram: 336 34 | filter: CONFIG_CPU_CORTEX_M33 or CONFIG_CPU_CORTEX_M7 35 | maestro.test.decoder.flac: 36 | extra_configs: 37 | - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_FLAC=y 38 | # Flash and RAM usage depend on track files sizes 39 | min_flash: 217 40 | min_ram: 336 41 | filter: CONFIG_CPU_CORTEX_M33 or CONFIG_CPU_CORTEX_M7 42 | maestro.test.decoder.aac: 43 | extra_configs: 44 | - CONFIG_MAESTRO_EXAMPLE_DECODER_SELECTED_AAC=y 45 | filter: (CONFIG_CPU_CORTEX_M33 or CONFIG_CPU_CORTEX_M7) and CONFIG_DSP 46 | -------------------------------------------------------------------------------- /zephyr/tests/encoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.20.0) 5 | 6 | add_compile_definitions(FSL_OSA_TASK_ENABLE=1) 7 | set(CONFIG_USE_component_osa_zephyr true) 8 | 9 | # Explicitelly enforcing to find specific Zephyr installation 10 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 11 | project(maestro_encoder) 12 | 13 | # Target_sources must be specified directly after find_package. Target "app" 14 | target_sources(app PRIVATE src/main.c) 15 | 16 | zephyr_include_directories(${ZEPHYR_MAESTRO_MODULE_DIR}/zephyr/audioTracks) 17 | -------------------------------------------------------------------------------- /zephyr/tests/encoder/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | menu "Maestro Encoder Test" 5 | depends on MAESTRO_AUDIO_FRAMEWORK 6 | 7 | config MAESTRO_EXAMPLE_MAESTRO_LOGGING_ON 8 | bool "Turns on Maestro library logging" 9 | default n 10 | 11 | config MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B 12 | int "Stack size of streamer task running the pipeline." 13 | default 128000 14 | 15 | config MAESTRO_EXAMPLE_ENCODER_SELECTED 16 | bool 17 | default n 18 | help 19 | True if any encoder is enabled. 20 | 21 | choice MAESTRO_EXAMPLE_ENCODER_SELECTED 22 | prompt "Encoder to test" 23 | default MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS 24 | 25 | config MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS 26 | select MAESTRO_ELEMENT_ENCODER_OPUS_ENABLE 27 | bool "OPUS encoder" 28 | # config MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS_OGG 29 | # select MAESTRO_ELEMENT_ENCODER_OPUS_OGG_ENABLE 30 | # bool "OPUS OGG encoder" 31 | endchoice # "Encoder to test" 32 | 33 | endmenu # "Maestro Encoder Test" 34 | 35 | source "Kconfig.zephyr" -------------------------------------------------------------------------------- /zephyr/tests/encoder/README.rst: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_encoder: 2 | 3 | ###################### 4 | Maestro encoder sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests and demonstrates encoder functionality in Maestro pipeline. 12 | 13 | Supported encoders: 14 | * OPUS with OGG envelop - TBD 15 | * RAW OPUS - TBD 16 | 17 | Input: 18 | 19 | * Prepared decoded audio data (RAW PCM format, part of Maestro repository) 20 | * Prepared encoded audio data (part of Maestro repository) 21 | 22 | Function: 23 | 24 | #. Loads RAW data into source buffer stored in RAM 25 | #. Encodes audio data using selected encoder and stores data in RAM 26 | #. Compares prepared data with decoded data if same 27 | #. Prints ``Demo result: OK`` or ``Demo result: FAIL`` via UART 28 | 29 | ************ 30 | Dependencies 31 | ************ 32 | 33 | - Audio voice component library (pulled in by Maestro's west), containing Encoder libraries 34 | 35 | ***************** 36 | User Input/Output 37 | ***************** 38 | 39 | Input: 40 | 41 | - None 42 | 43 | Output: 44 | 45 | - UART Output 46 | 47 | - ``Demo result: OK`` if everything went OK 48 | - ``Demo result: FAIL`` otherwise 49 | 50 | ************* 51 | Configuration 52 | ************* 53 | 54 | * ``See prj.conf`` for user input sections 55 | 56 | * Selecting encoder may be done by enabling ``CONFIG_MAESTRO_EXAMPLE_ENCODER_SELECTED_`` in ``prj.conf`` file. When no encoder is selected, default one (OPUS) is used instead. 57 | 58 | * System settings should be modified (stack size, heap size) based on selected encoder and system capabilities/requirements in ``prj.conf`` file. 59 | 60 | * For other configuration options, see example's ``Kconfig`` and ``prj.conf``. 61 | 62 | ******************* 63 | Supported platforms 64 | ******************* 65 | 66 | Currently tested for: 67 | 68 | * RD_RW612_BGA - Working encoders: None. 69 | -------------------------------------------------------------------------------- /zephyr/tests/encoder/prj.conf: -------------------------------------------------------------------------------- 1 | # Maestro settings 2 | CONFIG_MAESTRO_AUDIO_FRAMEWORK=y 3 | CONFIG_MAESTRO_ELEMENT_MEM_SRC_ENABLE=y 4 | CONFIG_MAESTRO_ELEMENT_MEM_SINK_ENABLE=y 5 | CONFIG_MAESTRO_ELEMENT_ENCODER_ENABLE=y 6 | 7 | # ======================================================= 8 | # USER INPUT NEEDED - Encoder selection 9 | # ======================================================= 10 | # Uncomment specific encoder to use it 11 | # Selected automatically whe using twister twister 12 | # CONFIG_MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS=y 13 | # End of USER INPUT 14 | # ======================================================= 15 | 16 | # ======================================================= 17 | # USER INPUT NEEDED - System settings 18 | # ======================================================= 19 | # Values dependent on selected encoder. Adjust accordingly based on your platform/system capabilities/requirements 20 | CONFIG_HEAP_MEM_POOL_SIZE=200000 21 | CONFIG_MAIN_STACK_SIZE=32096 22 | CONFIG_MAESTRO_EXAMPLE_STREAMER_TASK_STACK_SIZE_B=128000 23 | # End of USER INPUT 24 | # ======================================================= 25 | 26 | # System settings 27 | CONFIG_SYS_HEAP_ALLOC_LOOPS=12 28 | CONFIG_SYS_HEAP_AUTO=y 29 | CONFIG_MAIN_THREAD_PRIORITY=10 30 | CONFIG_CMSIS_DSP=y 31 | CONFIG_CMSIS_DSP_MATRIX=y 32 | CONFIG_FP_HARDABI=y 33 | CONFIG_FPU=y 34 | -------------------------------------------------------------------------------- /zephyr/tests/encoder/testcase.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | tags: 3 | - audio 4 | - maestro 5 | harness: console 6 | harness_config: 7 | type: one_line 8 | regex: 9 | - "(.*)Result: OK(.*)" 10 | timeout: 1 11 | integration_platforms: 12 | - rd_rw612_bga 13 | platform_allow: 14 | - rd_rw612_bga 15 | arch_allow: arm 16 | tests: 17 | maestro.test.encoder.opus: 18 | build_only: true 19 | extra_configs: 20 | - CONFIG_MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS=y 21 | # maestro.test.encoder.opus_ogg: 22 | # extra_configs: 23 | # - CONFIG_MAESTRO_EXAMPLE_ENCODER_SELECTED_OPUS_OGG=y 24 | -------------------------------------------------------------------------------- /zephyr/tests/memToMem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.20.0) 5 | 6 | add_compile_definitions(FSL_OSA_TASK_ENABLE=1) 7 | set(CONFIG_USE_component_osa_zephyr true) 8 | 9 | # Explicitelly enforcing to find specific Zephyr installation 10 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 11 | project(maestro_memtomem) 12 | 13 | # Target_sources must be specified directly after find_package. Target "app" 14 | target_sources(app PRIVATE src/main.c) 15 | 16 | zephyr_include_directories(${MAESTRO_OSA_DIR}) 17 | -------------------------------------------------------------------------------- /zephyr/tests/memToMem/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 NXP 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | source "Kconfig.zephyr" -------------------------------------------------------------------------------- /zephyr/tests/memToMem/README.rst: -------------------------------------------------------------------------------- 1 | .. _Maestro_Sample_memtomem: 2 | 3 | ###################### 4 | Maestro mem2mem sample 5 | ###################### 6 | 7 | *********** 8 | Description 9 | *********** 10 | 11 | Tests basic memory to memory pipeline. 12 | 13 | **Function:** 14 | 15 | #. Moves generated data with fixed size of 256B from memory source to memory sink. 16 | #. Compares copied data to check if they're the same. 17 | #. Returns ``Demo result: OK`` or ``Demo result: FAIL`` via UART. 18 | -------------------------------------------------------------------------------- /zephyr/tests/memToMem/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MAESTRO_AUDIO_FRAMEWORK=y 2 | 3 | CONFIG_MAESTRO_ELEMENT_MEM_SRC_ENABLE=y 4 | CONFIG_MAESTRO_ELEMENT_MEM_SINK_ENABLE=y 5 | 6 | CONFIG_HEAP_MEM_POOL_SIZE=40000 7 | CONFIG_SYS_HEAP_ALLOC_LOOPS=12 8 | CONFIG_SYS_HEAP_AUTO=y 9 | 10 | CONFIG_MAIN_THREAD_PRIORITY=10 11 | CONFIG_MAIN_STACK_SIZE=4096 -------------------------------------------------------------------------------- /zephyr/tests/memToMem/testcase.yaml: -------------------------------------------------------------------------------- 1 | common: 2 | tags: 3 | - audio 4 | - maestro 5 | integration_platforms: 6 | - rd_rw612_bga 7 | arch_allow: arm 8 | tests: 9 | maestro.test.system.mem2mem: 10 | tags: 11 | - audio 12 | - maestro 13 | harness: console 14 | harness_config: 15 | type: one_line 16 | regex: 17 | - "(.*)Result: OK(.*)" 18 | timeout: 1 19 | min_flash: 52 20 | min_ram: 52 -------------------------------------------------------------------------------- /zephyr/wrappers/fsl_debug_console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 NXP 3 | * All rights reserved. 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | * 7 | * @file app_Streamer_element_pcm.c 8 | * @brief Replaces fsl_Debug_console.h used in NXP's SDK. 9 | * 10 | * Purpose of this file is to provide simple interface for text I/O. 11 | */ 12 | 13 | #ifndef _FSL_DEBUGCONSOLE_H_ 14 | #define _FSL_DEBUGCONSOLE_H_ 15 | 16 | #if (CONFIG_MAESTRO_RTOS_ZEPHYR == 1) 17 | 18 | // #include 19 | #include "zephyr/sys/printk.h" 20 | 21 | static inline int debugConsole_Disabled(void) 22 | { 23 | return -1; 24 | } 25 | 26 | #define PRINTF printk 27 | #define SCANF(...) debugConsole_Disabled() 28 | #define PUTCHAR(...) debugConsole_Disabled() 29 | #define GETCHAR(...) debugConsole_Disabled() 30 | 31 | #endif 32 | 33 | #endif /* _FSL_DEBUGCONSOLE_H_ */ 34 | --------------------------------------------------------------------------------