snapshot
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(m4a)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
# Build with alac
|
||||
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()
|
||||
|
||||
# Build with libhelix
|
||||
FetchContent_Declare(helix GIT_REPOSITORY "https://github.com/pschatzmann/arduino-libhelix.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(helix)
|
||||
if(NOT helix_POPULATED)
|
||||
FetchContent_Populate(helix)
|
||||
add_subdirectory(${helix_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/helix)
|
||||
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(m4a.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (m4a m4a.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(m4a PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
target_compile_options(m4a PRIVATE -Wno-multichar)
|
||||
|
||||
|
||||
# set compile optioins
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
#target_compile_definitions(arduino-audio-tools INTERFACE -DUSE_ALLOCATOR)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(m4a PRIVATE
|
||||
codec-alac
|
||||
arduino_emulator
|
||||
arduino_helix
|
||||
arduino-audio-tools)
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @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"
|
||||
#include "AudioTools/AudioCodecs/CodecAACHelix.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerM4A.h"
|
||||
#include "AudioTools/AudioCodecs/MultiDecoder.h"
|
||||
#include "AudioTools/AudioCodecs/M4AFileSampleSizeBuffer.h"
|
||||
#include "SD.h"
|
||||
|
||||
MultiDecoder multi_decoder;
|
||||
ContainerM4A dec_m4a(multi_decoder);
|
||||
AACDecoderHelix dec_aac;
|
||||
DecoderALAC dec_alac;
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
EncodedAudioOutput decoder_output(&out, &dec_m4a);
|
||||
File file;
|
||||
StreamCopy copier(decoder_output, file);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
if (!SD.begin()){
|
||||
Serial.println("SD Card initialization failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
file = SD.open("/home/pschatzmann/Music/m4a/1-07 All You Need Is Love.m4a");
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file!");
|
||||
return;
|
||||
}
|
||||
|
||||
// mp4 supports alac and aac
|
||||
multi_decoder.addDecoder(dec_alac,"audio/alac");
|
||||
multi_decoder.addDecoder(dec_aac,"audio/aac");
|
||||
|
||||
// start decoder output
|
||||
if(!decoder_output.begin()) {
|
||||
Serial.println("Failed to start decoder output!");
|
||||
return;
|
||||
}
|
||||
|
||||
// start csv output
|
||||
if (!out.begin()){
|
||||
Serial.println("Failed to start CSV output!");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("M4A decoding started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user