snapshot
This commit is contained in:
39
libraries/audio-tools/tests-cmake/codec/alac/CMakeLists.txt
Normal file
39
libraries/audio-tools/tests-cmake/codec/alac/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(alac)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
# Build with arduino-fdk-aac
|
||||
FetchContent_Declare(codec-alac GIT_REPOSITORY "https://github.com/pschatzmann/codec-alac.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(codec-alac)
|
||||
if(NOT codec-alac_POPULATED)
|
||||
FetchContent_Populate(codec-alac)
|
||||
add_subdirectory(${codec-alac_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/codec-alac)
|
||||
endif()
|
||||
|
||||
# provide audio-tools
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../.. ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools )
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
set_source_files_properties(alac.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (alac alac.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(alac PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
target_compile_options(alac PRIVATE -Wno-multichar)
|
||||
|
||||
|
||||
# set compile optioins
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(alac PRIVATE codec-alac arduino_emulator arduino-audio-tools )
|
||||
|
||||
57
libraries/audio-tools/tests-cmake/codec/alac/alac.ino
Normal file
57
libraries/audio-tools/tests-cmake/codec/alac/alac.ino
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file test-codec-alac.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
*
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecALAC.h"
|
||||
|
||||
//SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
EncoderALAC enc_alac;
|
||||
DecoderALAC dec_alac;
|
||||
CodecNOP dec_nop;
|
||||
EncodedAudioStream decoder(&out, &dec_alac); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc_alac); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Debug);
|
||||
|
||||
// start Output
|
||||
Serial.println("starting Output...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
// optionally copy config from encoder to decoder
|
||||
// since decoder already has audio info and frames
|
||||
//dec_alac.setCodecConfig(enc_alac.config());
|
||||
//dec_alac.setCodecConfig(enc_alac.binaryConfig());
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user