snapshot
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(container-m4a-player)
|
||||
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(container-m4a-player.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (container-m4a-player container-m4a-player.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN -DUSE_FILESYSTEM)
|
||||
target_compile_definitions(container-m4a-player PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
target_compile_options(container-m4a-player 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(container-m4a-player PRIVATE
|
||||
codec-alac
|
||||
arduino_emulator
|
||||
arduino_helix
|
||||
arduino-audio-tools)
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file container-m4a-player.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Player with M4A files using a single MultiDecoder. However
|
||||
* I recommend to use 2 separate multi decoders one for the player and
|
||||
* a separate one for the M4A container.
|
||||
* @version 0.1
|
||||
*
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
*/
|
||||
//#include "SD.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecALAC.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACHelix.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerM4A.h"
|
||||
#include "AudioTools/AudioCodecs/MultiDecoder.h"
|
||||
#include "AudioTools/AudioCodecs/M4AFileSampleSizeBuffer.h"
|
||||
#include "AudioTools/Disk/AudioSourceSD.h"
|
||||
#include "WiFi.h"
|
||||
#include "AudioTools/Communication/RedisBuffer.h"
|
||||
|
||||
const char *startFilePath="/home/pschatzmann/Music/m4a";
|
||||
const char* ext="m4a";
|
||||
AudioSourceSD source(startFilePath, ext);
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
MultiDecoder multi_decoder;
|
||||
ContainerM4A dec_m4a(multi_decoder);
|
||||
AACDecoderHelix dec_aac;
|
||||
MP3DecoderHelix dec_mp3;
|
||||
DecoderALAC dec_alac;
|
||||
AudioPlayer player(source, out, multi_decoder);
|
||||
// Option 1 - using the played file
|
||||
//M4AFileSampleSizeBuffer sizes_buffer(player, dec_m4a);
|
||||
// Option 2 - using a file to buffer
|
||||
//File buffer_file;
|
||||
//RingBufferFile<File,stsz_sample_size_t> file_buffer(0);
|
||||
// Option 3 - using redis
|
||||
//WiFiClient client;
|
||||
//RedisBuffer<stsz_sample_size_t> redis(client,"m4a-buffer1",0, 1024, 0);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup multi decoder
|
||||
multi_decoder.addDecoder(dec_m4a, "audio/m4a");
|
||||
multi_decoder.addDecoder(dec_alac,"audio/alac");
|
||||
multi_decoder.addDecoder(dec_aac,"audio/aac");
|
||||
multi_decoder.addDecoder(dec_mp3,"audio/mp3");
|
||||
|
||||
// Option 1
|
||||
//dec_m4a.setSampleSizesBuffer(sizes_buffer);
|
||||
|
||||
// Option 2
|
||||
// set custom buffer to optimize the memory usage
|
||||
// buffer_file = SD.open("/home/pschatzmann/tmp.tmp", O_RDWR | O_CREAT);
|
||||
// file_buffer.begin(buffer_file);
|
||||
// dec_m4a.setSampleSizesBuffer(file_buffer);
|
||||
|
||||
// Option 3
|
||||
// WiFi.begin("ssid","pwd");
|
||||
// while ( WiFi.status() != WL_CONNECTED) {
|
||||
// Serial.print(".");
|
||||
// }
|
||||
// if (!client.connect(IPAddress(192,168,1,10),6379)){
|
||||
// Serial.println("redis error");
|
||||
// stop();
|
||||
// }
|
||||
// dec_m4a.setSampleSizesBuffer(redis);
|
||||
|
||||
// setup output
|
||||
auto cfg = out.defaultConfig(TX_MODE);
|
||||
out.begin(cfg);
|
||||
|
||||
//source.setTimeoutAutoNext(5000000);
|
||||
// setup player
|
||||
player.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
player.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user