snapshot
This commit is contained in:
36
libraries/audio-tools/tests-cmake/codec/CMakeLists.txt
Normal file
36
libraries/audio-tools/tests-cmake/codec/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(tests-codec)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror" )
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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()
|
||||
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/aac-faad ${CMAKE_CURRENT_BINARY_DIR}/aac-faad)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/aac-fdk ${CMAKE_CURRENT_BINARY_DIR}/aac-fdk)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/aac-fdk-encode ${CMAKE_CURRENT_BINARY_DIR}/aac-fdk-encode)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp3-helix ${CMAKE_CURRENT_BINARY_DIR}/mp3-helix)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/aac-helix ${CMAKE_CURRENT_BINARY_DIR}/aac-helix)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp3-lame ${CMAKE_CURRENT_BINARY_DIR}/mp3-lame)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp3-mad ${CMAKE_CURRENT_BINARY_DIR}/mp3-mad)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp3-metadata ${CMAKE_CURRENT_BINARY_DIR}/mp3-metadata)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/opus ${CMAKE_CURRENT_BINARY_DIR}/opus)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/opusogg ${CMAKE_CURRENT_BINARY_DIR}/opusogg)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/container-avi ${CMAKE_CURRENT_BINARY_DIR}/container-avi)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hls ${CMAKE_CURRENT_BINARY_DIR}/hls)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/container-m4a ${CMAKE_CURRENT_BINARY_DIR}/container-m4a)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/m4a-extractor ${CMAKE_CURRENT_BINARY_DIR}/m4a-extractor)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp4-parser ${CMAKE_CURRENT_BINARY_DIR}/mp4-parser)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mp3-parser ${CMAKE_CURRENT_BINARY_DIR}/mp3-parser)
|
||||
|
||||
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/container-avi-movie ${CMAKE_CURRENT_BINARY_DIR}/container-avi-movie)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 2.34)
|
||||
|
||||
# set the project name
|
||||
project(aac-faad)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS -Werror )
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with libfaad
|
||||
FetchContent_Declare(libfaad GIT_REPOSITORY https://github.com/pschatzmann/arduino-libfaad.git GIT_TAG main )
|
||||
FetchContent_GetProperties(libfaad)
|
||||
if(NOT libfaad_POPULATED)
|
||||
FetchContent_Populate(libfaad)
|
||||
add_subdirectory(${libfaad_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/libfaad)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (aac-faad aac-faad.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(aac-faad PUBLIC -DARDUINO -DIS_DESKTOP -DANALYSIS)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(aac-faad arduino_emulator libfaad arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACFAAD.h"
|
||||
//#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "audio.h"
|
||||
|
||||
MemoryStream aac(gs_16b_2c_44100hz_aac, gs_16b_2c_44100hz_aac_len);
|
||||
//PortAudioStream out; // Output of sound on desktop
|
||||
CsvOutput<int16_t> out(Serial, 2);
|
||||
EncodedAudioStream dec(&out, new AACDecoderFAAD()); // aac data source
|
||||
StreamCopy copier(dec, aac); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
dec.begin();
|
||||
|
||||
out.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (aac) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the aac file is %d", info.sample_rate);
|
||||
LOGI("The channels from the aac file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
20136
libraries/audio-tools/tests-cmake/codec/aac-faad/audio.h
Normal file
20136
libraries/audio-tools/tests-cmake/codec/aac-faad/audio.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(aac-fdk-encode)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with arduino-fdk-aac
|
||||
FetchContent_Declare(fdk_aac GIT_REPOSITORY "https://github.com/pschatzmann/arduino-fdk-aac.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(fdk_aac)
|
||||
if(NOT fdk_aac_POPULATED)
|
||||
FetchContent_Populate(fdk_aac)
|
||||
add_subdirectory(${fdk_aac_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/fdk_aac)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (aac-fdk-encode aac-fdk-encode.cpp )
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(aac-fdk-encode PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(aac-fdk-encode arduino_emulator fdk_aac arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
|
||||
//#include <stdlib.h> // for rand
|
||||
|
||||
|
||||
HexDumpOutput out(Serial);
|
||||
AACEncoderFDK aac(out);
|
||||
AudioInfo info;
|
||||
int16_t buffer[512];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
info.channels = 1;
|
||||
info.sample_rate = 16000;
|
||||
aac.begin(info);
|
||||
|
||||
Serial.println("starting...");
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int j=0;j<512;j++){
|
||||
buffer[j] = (rand() % 100) - 50;
|
||||
}
|
||||
if (aac.write((uint8_t*)buffer, 512*sizeof(int16_t))){
|
||||
out.flush();
|
||||
Serial.println("512 samples of random data written");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(aac-fdk)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with arduino-fdk-aac
|
||||
FetchContent_Declare(fdk_aac GIT_REPOSITORY "https://github.com/pschatzmann/arduino-fdk-aac.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(fdk_aac)
|
||||
if(NOT fdk_aac_POPULATED)
|
||||
FetchContent_Populate(fdk_aac)
|
||||
add_subdirectory(${fdk_aac_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/fdk_aac)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (aac-fdk aac-fdk.cpp )
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(aac-fdk PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(aac-fdk portaudio arduino_emulator fdk_aac arduino-audio-tools)
|
||||
|
||||
32
libraries/audio-tools/tests-cmake/codec/aac-fdk/aac-fdk.cpp
Normal file
32
libraries/audio-tools/tests-cmake/codec/aac-fdk/aac-fdk.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "audio.h"
|
||||
|
||||
MemoryStream aac(gs_16b_2c_44100hz_aac, gs_16b_2c_44100hz_aac_len);
|
||||
PortAudioStream portaudio_stream; // Output of sound on desktop
|
||||
EncodedAudioStream dec(&portaudio_stream, new AACDecoderFDK()); // aac data source
|
||||
StreamCopy copier(dec, aac); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
dec.addNotifyAudioChange(portaudio_stream);
|
||||
dec.begin();
|
||||
|
||||
portaudio_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (aac) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the aac file is %d", info.sample_rate);
|
||||
LOGI("The channels from the aac file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
20136
libraries/audio-tools/tests-cmake/codec/aac-fdk/audio.h
Normal file
20136
libraries/audio-tools/tests-cmake/codec/aac-fdk/audio.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(aac-helix)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 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()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (aac-helix aac-helix.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(aac-helix PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(aac-helix portaudio arduino_emulator arduino_helix arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACHelix.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "audio.h"
|
||||
|
||||
MemoryStream aac(gs_16b_2c_44100hz_aac, gs_16b_2c_44100hz_aac_len);
|
||||
PortAudioStream portaudio_stream; // Output of sound on desktop
|
||||
EncodedAudioStream dec(&portaudio_stream, new AACDecoderHelix()); // aac data source
|
||||
StreamCopy copier(dec, aac); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
dec.addNotifyAudioChange(portaudio_stream);
|
||||
dec.begin();
|
||||
|
||||
portaudio_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (aac) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the aac file is %d", info.sample_rate);
|
||||
LOGI("The channels from the aac file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
20136
libraries/audio-tools/tests-cmake/codec/aac-helix/audio.h
Normal file
20136
libraries/audio-tools/tests-cmake/codec/aac-helix/audio.h
Normal file
File diff suppressed because it is too large
Load Diff
45
libraries/audio-tools/tests-cmake/codec/adpcm/CMakeLists.txt
Normal file
45
libraries/audio-tools/tests-cmake/codec/adpcm/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(adpcm-test)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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 with arduino-adpcm
|
||||
FetchContent_Declare(adpcm_ffmpeg GIT_REPOSITORY "https://github.com/pschatzmann/adpcm" GIT_TAG main )
|
||||
FetchContent_GetProperties(adpcm_ffmpeg)
|
||||
if(NOT adpcm_ffmpeg)
|
||||
FetchContent_Populate(adpcm_ffmpeg)
|
||||
add_subdirectory(${adpcm_ffmpeg_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/adpcm)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (adpcm-test adpcm.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(adpcm-test PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(adpcm-test portaudio arduino_emulator adpcm_ffmpeg arduino-audio-tools)
|
||||
|
||||
52
libraries/audio-tools/tests-cmake/codec/adpcm/adpcm.cpp
Normal file
52
libraries/audio-tools/tests-cmake/codec/adpcm/adpcm.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file test-codec-adpcm.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> PortAudioStream
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
AudioInfo info(16000, 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
|
||||
//I2SStream out;
|
||||
PortAudioStream out;
|
||||
//CsvOutput<int16_t> out(Serial);
|
||||
EncodedAudioStream decoder(&out, new ADPCMDecoder(AV_CODEC_ID_ADPCM_IMA_WAV)); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new ADPCMEncoder(AV_CODEC_ID_ADPCM_IMA_WAV)); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(container-avi-movie)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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()
|
||||
|
||||
# OpenCV
|
||||
find_package( OpenCV REQUIRED )
|
||||
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (container-avi-movie container-avi-movie.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(container-avi-movie PUBLIC -DUSE_PORTAUDIO -DIS_MIN_DESKTOP)
|
||||
target_include_directories(container-avi-movie PRIVATE "${arduino_emulator_SOURCE_DIR}/ArduinoCore-Linux/libraries/SdFat" )
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(container-avi-movie portaudio arduino-audio-tools ${OpenCV_LIBS})
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file container-avi-movie.cpp
|
||||
* @author Phil Schatzmann
|
||||
* @brief Play AVI test movie downloaded from https://archive.org/embed/Test_Avi
|
||||
* To build execute the following steps
|
||||
* - mkdir build
|
||||
* - cd build
|
||||
* - cmake ..
|
||||
* - make
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerAVI.h"
|
||||
#include "AudioTools/AudioLibs/Desktop/File.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "Video/JpegOpenCV.h"
|
||||
|
||||
PortAudioStream out; // Output of sound on desktop
|
||||
JpegOpenCV jpegDisplay;
|
||||
AVIDecoder codec(new DecoderL8(), &jpegDisplay);
|
||||
EncodedAudioOutput avi(&out, &codec);
|
||||
File file;
|
||||
StreamCopy copier(avi, file);
|
||||
VideoAudioBufferedSync videoSync(10*1024, -20);
|
||||
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
file.open("/data/resources/test1.avi",FILE_READ);
|
||||
codec.setOutputVideoStream(jpegDisplay);
|
||||
codec.setVideoAudioSync(&videoSync);
|
||||
//codec.setMute(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(!copier.copy()){
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(container-avi)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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 with helix
|
||||
# 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()
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (container-avi container-avi.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(container-avi PUBLIC -DUSE_PORTAUDIO -DIS_MIN_DESKTOP -DHELIX_PRINT)
|
||||
target_include_directories(container-avi PRIVATE "${arduino_emulator_SOURCE_DIR}/ArduinoCore-Linux/libraries/SdFat" )
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(container-avi portaudio arduino_helix arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file communication-container-binary.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerAVI.h"
|
||||
#include "AudioTools/AudioLibs/Desktop/File.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
//CsvOutput<int16_t> out;
|
||||
PortAudioStream out; // Output of sound on desktop
|
||||
//AVIDecoder codec;
|
||||
AVIDecoder codec(new DecoderL8());
|
||||
EncodedAudioOutput riff(&out, &codec);
|
||||
File file;
|
||||
StreamCopy copier(riff, file);
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
file.open("/data/resources/test1.avi",FILE_READ);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(!copier.copy()){
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(container-binary)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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
|
||||
add_executable (container-binary container-binary.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(container-binary PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(container-binary arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file communication-container-binary.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerBinary.h"
|
||||
|
||||
AudioInfo info(8000,1,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);
|
||||
EncodedAudioStream decoder(&out,new BinaryContainerDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&out,new BinaryContainerEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start
|
||||
Serial.println("starting...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
54
libraries/audio-tools/tests-cmake/codec/hls/CMakeLists.txt
Normal file
54
libraries/audio-tools/tests-cmake/codec/hls/CMakeLists.txt
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(hls)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Activate Emulator and Portaudio
|
||||
set(ADD_ARDUINO_EMULATOR ON CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "Add Portaudio Library")
|
||||
|
||||
# Build with arduino-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 with tms
|
||||
FetchContent_Declare(tsdemux GIT_REPOSITORY "https://github.com/pschatzmann/arduino-tsdemux" )
|
||||
FetchContent_GetProperties(tsdemux)
|
||||
if(NOT tsdemux_POPULATED)
|
||||
FetchContent_Populate(tsdemux)
|
||||
add_subdirectory(${tsdemux_SOURCE_DIR} tsdemux)
|
||||
endif()
|
||||
|
||||
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 helix)
|
||||
add_subdirectory(${helix_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/helix)
|
||||
endif()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
# build sketch as executable
|
||||
set_source_files_properties(hls.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (hls hls.cpp )
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(hls PUBLIC -DARDUINO -DIS_DESKTOP -DHELIX_PRINT)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(hls PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(hls arduino-audio-tools arduino_emulator tsdemux arduino_helix)
|
||||
|
||||
|
||||
|
||||
|
||||
51
libraries/audio-tools/tests-cmake/codec/hls/hls.cpp
Normal file
51
libraries/audio-tools/tests-cmake/codec/hls/hls.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecTSDemux.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADTS.h"
|
||||
#include "AudioTools/AudioCodecs/CodecHelix.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMTS.h"
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
#include "AudioTools/Communication/HLSStream.h"
|
||||
|
||||
AudioInfo info(48000,2,16);
|
||||
HLSStream hls_stream("NA", "NA");
|
||||
// HexDumpOutput hex(Serial);
|
||||
// NullStream null;
|
||||
//CsvOutput<int16_t> out(Serial, 2); // Or use StdOuput
|
||||
MiniAudioStream out;
|
||||
//MTSDecoder mts;
|
||||
//ADTSDecoder adts;
|
||||
AACDecoderHelix aac;
|
||||
MP3DecoderHelix mp3;
|
||||
MultiDecoder multi;
|
||||
//EncodedAudioStream aac_stream(&out, &aac);
|
||||
//EncodedAudioStream adts_stream(&aac_stream, &adts);
|
||||
//EncodedAudioStream mts_stream(&adts_stream, &mts);
|
||||
EncodedAudioStream dec(&out, &mp3);
|
||||
StreamCopy copier(dec, hls_stream);
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
//Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
//hls_stream.setLogLevel(AudioLogger::Debug); // hls_stream is quite chatty at Info
|
||||
//adts_stream.setLogLevel(AudioLogger::Debug);
|
||||
//mts_stream.setLogLevel(AudioLogger::Debug);
|
||||
|
||||
aac.setAudioInfoNotifications(false);
|
||||
|
||||
auto cfg = out.defaultConfig(TX_MODE);
|
||||
cfg.copyFrom(info);
|
||||
out.begin();
|
||||
|
||||
//mts_stream.begin();
|
||||
//aac_stream.begin();
|
||||
//adts_stream.begin();
|
||||
|
||||
if (hls_stream.begin("http://audio-edge-cmc51.fra.h.radiomast.io/ref-128k-mp3-stereo/hls.m3u8"))
|
||||
Serial.println("playing...");
|
||||
}
|
||||
|
||||
// Arduino loop
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(m4a-extractor)
|
||||
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-extrator.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (m4a-extractor m4a-extrator.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(m4a-extractor PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
target_compile_options(m4a-extractor 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-extractor PRIVATE
|
||||
codec-alac
|
||||
arduino_emulator
|
||||
arduino_helix
|
||||
arduino-audio-tools)
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file m4a-extractor.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Decode M4A file and output to CSV
|
||||
* @version 0.1
|
||||
*
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/M4AAudioFileDemuxer.h"
|
||||
#include "AudioTools/AudioCodecs/CodecALAC.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACHelix.h"
|
||||
#include "AudioTools/AudioCodecs/MultiDecoder.h"
|
||||
#include "SD.h"
|
||||
|
||||
MultiDecoder multi_decoder;
|
||||
AACDecoderHelix dec_aac;
|
||||
DecoderALAC dec_alac;
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
|
||||
//MP4Parser parser;
|
||||
M4AAudioFileDemuxer demux;
|
||||
File 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;
|
||||
}
|
||||
|
||||
// Setup decoder
|
||||
multi_decoder.setOutput(out);
|
||||
multi_decoder.addDecoder(dec_aac, "audio/aac");
|
||||
multi_decoder.addDecoder(dec_alac, "audio/alac");
|
||||
demux.setDecoder(multi_decoder);
|
||||
|
||||
if (!demux.begin(file)){
|
||||
Serial.println("Failed to open demuxer!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
demux.copy();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3-helix)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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 with helix
|
||||
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()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (mp3-helix mp3-helix.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(mp3-helix PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
#target_compile_definitions(portaudio PUBLIC -DPA_USE_COREAUDIO=1)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp3-helix portaudio arduino_emulator arduino_helix arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
PortAudioStream portaudio_stream; // Output of sound on desktop
|
||||
EncodedAudioStream dec(&portaudio_stream, new MP3DecoderHelix()); // MP3 data source
|
||||
StreamCopy copier(dec, mp3); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
dec.addNotifyAudioChange(portaudio_stream);
|
||||
dec.begin();
|
||||
|
||||
portaudio_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (mp3) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the mp3 file is %d", info.sample_rate);
|
||||
LOGI("The channels from the mp3 file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3-lame)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
# set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
#endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with liblame
|
||||
FetchContent_Declare(arduino_liblame GIT_REPOSITORY "https://github.com/pschatzmann/arduino-liblame.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(arduino_liblame)
|
||||
if(NOT arduino_liblame_POPULATED)
|
||||
FetchContent_Populate(arduino_liblame)
|
||||
add_subdirectory(${arduino_liblame_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino_liblame)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (mp3-lame mp3-lame.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(mp3-lame PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp3-lame portaudio arduino_emulator arduino_liblame arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3LAME.h"
|
||||
//#include <stdlib.h> // for rand
|
||||
|
||||
HexDumpOutput out(Serial);
|
||||
MP3EncoderLAME mp3(out);
|
||||
AudioInfoLAME info;
|
||||
int16_t buffer[512];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
info.channels = 1;
|
||||
info.sample_rate = 16000;
|
||||
mp3.begin(info);
|
||||
|
||||
Serial.println("starting...");
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int j=0;j<512;j++){
|
||||
buffer[j] = (rand() % 100) - 50;
|
||||
}
|
||||
if (mp3.write((uint8_t*)buffer, 512*sizeof(int16_t))){
|
||||
out.flush();
|
||||
Serial.println("512 samples of random data written");
|
||||
}
|
||||
}
|
||||
39630
libraries/audio-tools/tests-cmake/codec/mp3-mad/BabyElephantWalk60_mp3.h
Normal file
39630
libraries/audio-tools/tests-cmake/codec/mp3-mad/BabyElephantWalk60_mp3.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3-mad)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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 with libmad
|
||||
FetchContent_Declare(arduino_libmad GIT_REPOSITORY "https://github.com/pschatzmann/arduino-libmad.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(arduino_libmad)
|
||||
if(NOT arduino_libmad_POPULATED)
|
||||
FetchContent_Populate(arduino_libmad)
|
||||
add_subdirectory(${arduino_libmad_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino_libmad)
|
||||
endif()
|
||||
|
||||
# build sketch as executabl
|
||||
add_executable (mp3-mad mp3-mad.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(mp3-mad PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP )
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp3-mad portaudio arduino_emulator arduino_libmad arduino-audio-tools )
|
||||
# ESP32: CONFIG_ARDUINO_LOOP_STACK_SIZE 8192 -> so we test it with this setting "-Wl,-z,stack-size=8192"
|
||||
#add_link_options("-z,stack-size=8192")
|
||||
|
||||
33
libraries/audio-tools/tests-cmake/codec/mp3-mad/mp3-mad.cpp
Normal file
33
libraries/audio-tools/tests-cmake/codec/mp3-mad/mp3-mad.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3MAD.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
PortAudioStream portaudio_stream; // Output of sound on desktop
|
||||
EncodedAudioStream dec(&portaudio_stream, new MP3DecoderMAD()); // MP3 data source
|
||||
StreamCopy copier(dec, mp3); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
dec.addNotifyAudioChange(portaudio_stream);
|
||||
dec.begin();
|
||||
|
||||
portaudio_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (mp3) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the mp3 file is %d", info.sample_rate);
|
||||
LOGI("The channels from the mp3 file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3-metadata)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
# Build with arduino-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
|
||||
add_executable (mp3-metadata mp3-metadata.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(mp3-metadata PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp3-metadata portaudio arduino_emulator arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "sample-12s.h"
|
||||
|
||||
MemoryStream mp3(sample_12s_mp3, sample_12s_mp3_len);
|
||||
MetaDataOutput out;
|
||||
StreamCopy copier(out, mp3); // copy in to out
|
||||
bool title_printed = false;
|
||||
|
||||
void printMetaData(MetaDataType type, const char* str, int len){
|
||||
Serial.print("==> ");
|
||||
Serial.print(toStr(type));
|
||||
Serial.print(": ");
|
||||
Serial.println(str);
|
||||
title_printed = true;
|
||||
}
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
out.setCallback(printMetaData);
|
||||
out.begin();
|
||||
mp3.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (mp3) {
|
||||
copier.copy();
|
||||
} else {
|
||||
assert(title_printed);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
17232
libraries/audio-tools/tests-cmake/codec/mp3-metadata/sample-12s.h
Normal file
17232
libraries/audio-tools/tests-cmake/codec/mp3-metadata/sample-12s.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3_mini)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# provide minimp3
|
||||
FetchContent_Declare(arduino_minimp3 GIT_REPOSITORY "https://github.com/pschatzmann/arduino-minimp3.git" )
|
||||
FetchContent_GetProperties(arduino_minimp3)
|
||||
if(NOT arduino_minimp3_POPULATED)
|
||||
FetchContent_Populate(arduino_minimp3)
|
||||
add_subdirectory(${arduino_minimp3_SOURCE_DIR})
|
||||
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(mp3-mini.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (mp3_mini mp3-mini.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(arduino_minimp3 INTERFACE -DARDUINO -DMINIMP3_NO_SIMD)
|
||||
target_compile_definitions(mp3_mini PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
|
||||
# set compile optioins
|
||||
target_compile_options(portaudio PRIVATE -Wno-deprecated -Wno-inconsistent-missing-override)
|
||||
target_compile_options(arduino_minimp3 INTERFACE -Wdouble-promotion)
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
|
||||
# specify libraries
|
||||
#target_link_libraries(arduino-audio-tools INTERFACE portaudio arduino_emulator arduino_minimp3 )
|
||||
target_link_libraries(mp3_mini PRIVATE arduino_minimp3 portaudio arduino_emulator arduino-audio-tools )
|
||||
|
||||
16
libraries/audio-tools/tests-cmake/codec/mp3-mini/README.md
Normal file
16
libraries/audio-tools/tests-cmake/codec/mp3-mini/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Playing Sound on your Desktop
|
||||
|
||||
We provide some generic output which will also work on Linux, Windows and OS/X
|
||||
The cmake is downloading all dependencies and builds an executable from the sketch.
|
||||
|
||||
We use the more comprehensive new EncodedAudioStream class.
|
||||
|
||||
You just need to provide an Arduino Sketch as cpp file. To build the example execute:
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#define MINIMP3_IMPLEMENTATION
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Mini.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
PortAudioStream out; // Output of sound on desktop
|
||||
EncodedAudioStream dec(&out, new MP3DecoderMini()); // MP3 data source
|
||||
StreamCopy copier(dec, mp3); // copy in to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
out.begin();
|
||||
mp3.begin();
|
||||
dec.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (mp3) {
|
||||
copier.copy();
|
||||
} else {
|
||||
auto info = dec.decoder().audioInfo();
|
||||
LOGI("The audio rate from the mp3 file is %d", info.sample_rate);
|
||||
LOGI("The channels from the mp3 file is %d", info.channels);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp3-parser)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
|
||||
# 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
|
||||
add_executable (mp3-parser mp3-parser.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(mp3-parser PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
|
||||
# set compile optioins
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp3-parser PRIVATE arduino_emulator arduino-audio-tools )
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/// Testing the MP3ParserEncoder: the mp3 data must start with a sync word
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/MP3Parser.h"
|
||||
#include "AudioTools/AudioLibs/Desktop/File.h"
|
||||
|
||||
MP3ParserEncoder enc; // mp3 packaging
|
||||
MetaDataFilterEncoder filter(enc);
|
||||
CallbackStream cb;
|
||||
EncodedAudioOutput out_stream(&cb, &filter);
|
||||
File file;
|
||||
StreamCopy copier(out_stream, file);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
file = SD.open("/home/pschatzmann/Music/test.mp3", FILE_READ);
|
||||
out_stream.begin();
|
||||
|
||||
auto write_cb = [](const uint8_t* data, size_t size) {
|
||||
// Ensure each emitted chunk starts with an MP3 sync word (0xFFE?)
|
||||
if (size >= 2) {
|
||||
assert(data[0] == 0xFF && (data[1] & 0xE0) == 0xE0);
|
||||
}
|
||||
char msg[120];
|
||||
snprintf(msg, 120,
|
||||
"write: %d, sample_rate: %d, samples: %d, duration: %u us",
|
||||
(int)size, (int)enc.audioInfo().sample_rate, enc.samplesPerFrame(),
|
||||
(unsigned)enc.frameDurationUs());
|
||||
Serial.println(msg);
|
||||
return size;
|
||||
};
|
||||
cb.setWriteCallback(write_cb);
|
||||
cb.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!copier.copy()) {
|
||||
out_stream.end();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mp4-parser)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
# 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(mp4-parser.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (mp4-parser mp4-parser.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(mp4-parser PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
target_compile_options(mp4-parser PRIVATE -Wno-multichar)
|
||||
|
||||
|
||||
# set compile optioins
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mp4-parser PRIVATE
|
||||
arduino_emulator
|
||||
arduino-audio-tools)
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @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/MP4Parser.h"
|
||||
#include "SD.h"
|
||||
|
||||
MP4Parser parser;
|
||||
File 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/aac.m4a");
|
||||
if (!file.isOpen()) {
|
||||
Serial.println("Failed to open file!");
|
||||
return;
|
||||
}
|
||||
|
||||
parser.begin();
|
||||
|
||||
Serial.println("MP4 Boxes:");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
char buffer[1024];
|
||||
int to_read = min(sizeof(buffer), parser.availableForWrite());
|
||||
size_t bytesRead = file.readBytes(buffer,to_read);
|
||||
assert(parser.write(buffer, bytesRead)== bytesRead);
|
||||
if (bytesRead == 0) {
|
||||
Serial.println("End of file reached.");
|
||||
exit(0); // Exit the process
|
||||
}
|
||||
}
|
||||
28
libraries/audio-tools/tests-cmake/codec/mts/CMakeLists.txt
Normal file
28
libraries/audio-tools/tests-cmake/codec/mts/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(mts)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
|
||||
|
||||
include(FetchContent)
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
|
||||
# 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(mts.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable (mts mts.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(mts PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
|
||||
target_compile_options(arduino-audio-tools INTERFACE -Wno-inconsistent-missing-override)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(mts PRIVATE arduino_emulator arduino-audio-tools )
|
||||
|
||||
31
libraries/audio-tools/tests-cmake/codec/mts/mts.ino
Normal file
31
libraries/audio-tools/tests-cmake/codec/mts/mts.ino
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMTS.h"
|
||||
|
||||
HexDumpOutput out;
|
||||
MTSDecoder codecMTS;
|
||||
FILE *fp;
|
||||
uint8_t buffer[1024];
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
fp = fopen(
|
||||
"/home/pschatzmann/Downloads/tmp/bbc_radio_one-audio=96000-272169555.ts",
|
||||
"rb");
|
||||
codecMTS.setOutput(out);
|
||||
codecMTS.begin();
|
||||
const size_t fileSize = fread(buffer, sizeof(unsigned char), 1024, fp);
|
||||
// Every 188th byte should be 0x47.
|
||||
assert(buffer[0] == 0x47);
|
||||
assert(buffer[188] == 0x47);
|
||||
codecMTS.write(buffer, fileSize);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
const size_t fileSize = fread(buffer, sizeof(unsigned char), 1024, fp);
|
||||
if (fileSize==0) {
|
||||
LOGI("End of File");
|
||||
stop();
|
||||
}
|
||||
codecMTS.write(buffer, fileSize);
|
||||
}
|
||||
32
libraries/audio-tools/tests-cmake/codec/opus/CMakeLists.txt
Normal file
32
libraries/audio-tools/tests-cmake/codec/opus/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(opus)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with libopus
|
||||
FetchContent_Declare(arduino_libopus GIT_REPOSITORY "https://github.com/pschatzmann/codec-opus.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(arduino_libopus)
|
||||
if(NOT arduino_libopus_POPULATED)
|
||||
FetchContent_Populate(arduino_libopus)
|
||||
add_subdirectory(${arduino_libopus_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino_libopus)
|
||||
endif()
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (opus opus.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(opus PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP )
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(opus portaudio arduino_emulator arduino_libopus arduino-audio-tools )
|
||||
# ESP32: CONFIG_ARDUINO_LOOP_STACK_SIZE 8192 -> so we test it with this setting "-Wl,-z,stack-size=8192"
|
||||
# add_link_options("-z,stack-size=8192")
|
||||
|
||||
51
libraries/audio-tools/tests-cmake/codec/opus/opus.cpp
Normal file
51
libraries/audio-tools/tests-cmake/codec/opus/opus.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file test-codec-opus.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpus.h"
|
||||
|
||||
int sample_rate = 24000;
|
||||
int channels = 1; // The stream will have 2 channels
|
||||
|
||||
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, 2); // Output of sound on desktop
|
||||
OpusAudioEncoder enc;
|
||||
OpusAudioDecoder dec;
|
||||
EncodedAudioStream decoder(&out, &dec); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Debug);
|
||||
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.sample_rate = sample_rate;
|
||||
cfgs.channels = channels;
|
||||
cfgs.bits_per_sample = 16;
|
||||
sineWave.begin(cfgs, N_B4);
|
||||
|
||||
// Opus decoder needs to know the audio info
|
||||
decoder.begin(cfgs);
|
||||
|
||||
// configure and start encoder
|
||||
enc.config().application = OPUS_APPLICATION_AUDIO;
|
||||
encoder.begin(cfgs);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(opusogg)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Build with arduino-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 with libogg
|
||||
FetchContent_Declare(arduino_libogg GIT_REPOSITORY "https://github.com/pschatzmann/codec-ogg.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(arduino_libogg)
|
||||
if(NOT arduino_libogg_POPULATED)
|
||||
FetchContent_Populate(arduino_libogg)
|
||||
# Need to provide both source and binary dirs because source is outside current tree
|
||||
add_subdirectory(${arduino_libogg_SOURCE_DIR} ${arduino_libogg_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
# Build with libopus
|
||||
FetchContent_Declare(arduino_libopus GIT_REPOSITORY "https://github.com/pschatzmann/codec-opus.git" GIT_TAG main )
|
||||
FetchContent_GetProperties(arduino_libopus)
|
||||
if(NOT arduino_libopus_POPULATED)
|
||||
FetchContent_Populate(arduino_libopus)
|
||||
# Provide explicit binary dir
|
||||
add_subdirectory(${arduino_libopus_SOURCE_DIR} ${arduino_libopus_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (opusogg opusogg.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(opusogg PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP )
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(opusogg portaudio arduino_emulator arduino_libogg arduino_libopus arduino-audio-tools )
|
||||
# ESP32: CONFIG_ARDUINO_LOOP_STACK_SIZE 8192 -> so we test it with this setting "-Wl,-z,stack-size=8192"
|
||||
# add_link_options("-z,stack-size=8192")
|
||||
|
||||
50
libraries/audio-tools/tests-cmake/codec/opusogg/opusogg.cpp
Normal file
50
libraries/audio-tools/tests-cmake/codec/opusogg/opusogg.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file test-codec-opusogg.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpusOgg.h"
|
||||
|
||||
int application = OPUS_APPLICATION_AUDIO; // Opus application
|
||||
AudioInfo info(24000, 1, 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); // Output of sound on desktop
|
||||
OpusOggEncoder enc;
|
||||
OpusOggDecoder dec;
|
||||
EncodedAudioStream decoder(&out, &dec); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// Setup output
|
||||
auto cfgo = out.defaultConfig();
|
||||
cfgo.copyFrom(info);
|
||||
out.begin(cfgo);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// Opus decoder needs to know the audio info
|
||||
decoder.begin(info);
|
||||
|
||||
// configure and start encoder
|
||||
enc.config().application = application;
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
42
libraries/audio-tools/tests-cmake/codec/wav/CMakeLists.txt
Normal file
42
libraries/audio-tools/tests-cmake/codec/wav/CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(wav-test)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Add Portaduio for desktop build
|
||||
add_compile_options(-DIS_DESKTOP)
|
||||
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
|
||||
FetchContent_GetProperties(portaudio)
|
||||
if(NOT portaudio_POPULATED)
|
||||
FetchContent_Populate(portaudio)
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
|
||||
endif()
|
||||
|
||||
# Build with arduino-adpcm
|
||||
FetchContent_Declare(adpcm_ffmpeg GIT_REPOSITORY "https://github.com/pschatzmann/adpcm" GIT_TAG main )
|
||||
FetchContent_GetProperties(adpcm_ffmpeg)
|
||||
if(NOT adpcm_ffmpeg)
|
||||
FetchContent_Populate(adpcm_ffmpeg)
|
||||
add_subdirectory(${adpcm_ffmpeg_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/adpcm)
|
||||
endif()
|
||||
|
||||
# Build with arduino-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
|
||||
add_executable (wav-test wav.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(wav-test PUBLIC -DARDUINO -DUSE_PORTAUDIO -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(wav-test portaudio arduino_emulator adpcm_ffmpeg arduino-audio-tools)
|
||||
|
||||
63
libraries/audio-tools/tests-cmake/codec/wav/wav.cpp
Normal file
63
libraries/audio-tools/tests-cmake/codec/wav/wav.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file test-codec-adpcm.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> PortAudioStream
|
||||
* We can select between PCM and ADPCM
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecWAV.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
#define USE_ADPCM true
|
||||
|
||||
AudioInfo info(16000, 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
|
||||
//I2SStream out;
|
||||
//PortAudioStream out;
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
#if USE_ADPCM
|
||||
ADPCMDecoder adpcm_decoder(AV_CODEC_ID_ADPCM_IMA_WAV);
|
||||
ADPCMEncoder adpcm_encoder(AV_CODEC_ID_ADPCM_IMA_WAV);
|
||||
EncodedAudioStream decoder(&out, new WAVDecoder(adpcm_decoder, AudioFormat::ADPCM)); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new WAVEncoder(adpcm_encoder, AudioFormat::ADPCM)); // encode and write
|
||||
#else
|
||||
EncodedAudioStream decoder(&out, new WAVDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new WAVEncoder()); // encode and write
|
||||
#endif
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Debug);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting Output...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user