snapshot
This commit is contained in:
33
libraries/audio-tools/tests-cmake/CMakeLists.txt
Normal file
33
libraries/audio-tools/tests-cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
|
||||
|
||||
# set the project name
|
||||
project(tests)
|
||||
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}/resample ${CMAKE_CURRENT_BINARY_DIR}/resample)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generator ${CMAKE_CURRENT_BINARY_DIR}/generator)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/effects ${CMAKE_CURRENT_BINARY_DIR}/effects)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fft ${CMAKE_CURRENT_BINARY_DIR}/fft)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ifft ${CMAKE_CURRENT_BINARY_DIR}/ifft)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fft-effect ${CMAKE_CURRENT_BINARY_DIR}/fft-effect)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/filter ${CMAKE_CURRENT_BINARY_DIR}/filter)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/filter-wav ${CMAKE_CURRENT_BINARY_DIR}/filter-wav)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/url-test ${CMAKE_CURRENT_BINARY_DIR}/url-test)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hdlc ${CMAKE_CURRENT_BINARY_DIR}/hdlc)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/codec)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pipeline)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/player-wav)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/rtsp)
|
||||
4
libraries/audio-tools/tests-cmake/README.md
Normal file
4
libraries/audio-tools/tests-cmake/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
In the subdirectories you find the test sketches that can be built on the desktop.
|
||||
For details [see the Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/Running-an-Audio-Sketch-on-the-Desktop)
|
||||
|
||||
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();
|
||||
}
|
||||
32
libraries/audio-tools/tests-cmake/effects/CMakeLists.txt
Normal file
32
libraries/audio-tools/tests-cmake/effects/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(effects)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
# 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 sketch as executable
|
||||
add_executable (effects effects.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(effects PUBLIC -DARDUINO -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(effects arduino_emulator arduino-audio-tools portaudio)
|
||||
|
||||
53
libraries/audio-tools/tests-cmake/effects/effects.cpp
Normal file
53
libraries/audio-tools/tests-cmake/effects/effects.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
PortAudioStream out;
|
||||
SineWaveGenerator<int16_t> sine;
|
||||
AudioEffects<SineWaveGenerator<int16_t>> effects(sine);
|
||||
ADSRGain adsr(0.0001,0.0001, 0.9 , 0.0002);
|
||||
GeneratedSoundStream<int16_t> in(effects);
|
||||
StreamCopy copier(out, in);
|
||||
uint64_t timeout=0;
|
||||
float freq = N_C4;
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
|
||||
|
||||
// setup effects
|
||||
effects.addEffect(adsr);
|
||||
|
||||
// Setup output
|
||||
auto cfg = out.defaultConfig();
|
||||
cfg.channels = 1;
|
||||
cfg.bits_per_sample = 16;
|
||||
cfg.sample_rate = 44100;
|
||||
out.begin(cfg);
|
||||
|
||||
// Setup sound generation based on AudioKit settins
|
||||
effects.begin(cfg);
|
||||
sine.begin(cfg, 0);
|
||||
in.begin(cfg);
|
||||
sine.setFrequency(freq);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
// simulate key press
|
||||
if (millis()>timeout){
|
||||
sine.setFrequency(freq);
|
||||
adsr.keyOn();
|
||||
timeout = millis()+3000;
|
||||
}
|
||||
// simulate key release
|
||||
if (millis()>timeout+1000){
|
||||
sine.setFrequency(freq);
|
||||
adsr.keyOff();
|
||||
}
|
||||
// output audio
|
||||
copier.copy();
|
||||
}
|
||||
|
||||
35
libraries/audio-tools/tests-cmake/fft-effect/CMakeLists.txt
Normal file
35
libraries/audio-tools/tests-cmake/fft-effect/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(fft-effect)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm -fno-omit-frame-pointer -fsanitize=address")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm -fno-omit-frame-pointer -fsanitize=address")
|
||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||
|
||||
# Emulator is not necessary for -DIS_MIN_DESKTOP
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio")
|
||||
|
||||
# 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()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (fft-effect fft-effect.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(fft-effect PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(fft-effect arduino-audio-tools)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(fft-effect PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
45
libraries/audio-tools/tests-cmake/fft-effect/fft-effect.cpp
Normal file
45
libraries/audio-tools/tests-cmake/fft-effect/fft-effect.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
#include "AudioTools/AudioLibs/FFTEffects.h"
|
||||
#include "AudioTools/AudioLibs/Desktop/File.h"
|
||||
|
||||
AudioInfo info(16000, 2, 16);
|
||||
MiniAudioStream out; // final output of decoded stream
|
||||
FFTPitchShift effect(out);
|
||||
//FFTNop effect(out);
|
||||
//FFTWhisper effect(out);
|
||||
//FFTRobotize effect(out);
|
||||
WAVDecoder wav;
|
||||
EncodedAudioOutput decoder(&effect, &wav); // Decoding stream
|
||||
StreamCopy copier;
|
||||
File audioFile;
|
||||
|
||||
void setup(){
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto config = out.defaultConfig(TX_MODE);
|
||||
config.copyFrom(info);
|
||||
out.begin(config);
|
||||
|
||||
auto econfig = effect.defaultConfig();
|
||||
econfig.copyFrom(info);
|
||||
econfig.shift = -20;
|
||||
effect.begin(econfig);
|
||||
|
||||
// setup file: must be in current directory
|
||||
audioFile.open("hal1600.wav");
|
||||
|
||||
// setup I2S based on sampling rate provided by decoder
|
||||
decoder.begin();
|
||||
|
||||
// begin copy
|
||||
copier.begin(decoder, audioFile);
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (!copier.copy()) {
|
||||
delay(5000);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
BIN
libraries/audio-tools/tests-cmake/fft-effect/hal1600.wav
Normal file
BIN
libraries/audio-tools/tests-cmake/fft-effect/hal1600.wav
Normal file
Binary file not shown.
35
libraries/audio-tools/tests-cmake/fft/CMakeLists.txt
Normal file
35
libraries/audio-tools/tests-cmake/fft/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(fft)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
|
||||
# Emulator is not necessary for -DIS_MIN_DESKTOP
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio")
|
||||
|
||||
# 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()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (fft fft.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(fft PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(fft arduino-audio-tools)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(fft PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
48
libraries/audio-tools/tests-cmake/fft/fft.cpp
Normal file
48
libraries/audio-tools/tests-cmake/fft/fft.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioRealFFT.h" // using RealFFT
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
AudioRealFFT afft; // or AudioKissFFT
|
||||
Hann hann;
|
||||
BufferedWindow buffered(&hann);
|
||||
SineWaveGenerator<int16_t> sineWave(32000);
|
||||
GeneratedSoundStream<int16_t> in(sineWave);
|
||||
StreamCopy copier(afft, in);
|
||||
//CsvOutput<int16_t> out(Serial);
|
||||
MiniAudioStream out;
|
||||
StreamCopy copierIFFT(out, afft);
|
||||
|
||||
// process fft result
|
||||
void fftResult(AudioFFTBase &fft) {
|
||||
// copy ifft result to output
|
||||
while (copierIFFT.copy());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// set the frequency
|
||||
sineWave.setFrequency(N_B4);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfg = in.defaultConfig();
|
||||
cfg.copyFrom(info);
|
||||
in.begin(cfg);
|
||||
|
||||
// Setup FFT
|
||||
auto tcfg = afft.defaultConfig(RXTX_MODE);
|
||||
tcfg.copyFrom(info);
|
||||
tcfg.length = 1024;
|
||||
tcfg.window_function = &buffered;
|
||||
tcfg.stride = 512;
|
||||
tcfg.callback = fftResult;
|
||||
afft.begin(tcfg);
|
||||
|
||||
// setup output
|
||||
auto ocfg = out.defaultConfig(TX_MODE);
|
||||
ocfg.copyFrom(info);
|
||||
out.begin(ocfg);
|
||||
}
|
||||
|
||||
void loop() { copier.copy(); }
|
||||
33
libraries/audio-tools/tests-cmake/filter-wav/CMakeLists.txt
Normal file
33
libraries/audio-tools/tests-cmake/filter-wav/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(filter-wav)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
# 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 sketch as executable
|
||||
add_executable (filter-wav filter-wav.cpp)
|
||||
target_include_directories(filter-wav PRIVATE "${arduino_emulator_SOURCE_DIR}/ArduinoCore-Linux/libraries/SdFat" )
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(filter-wav PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(filter-wav portaudio arduino_emulator arduino-audio-tools)
|
||||
|
||||
194
libraries/audio-tools/tests-cmake/filter-wav/filter-wav.cpp
Normal file
194
libraries/audio-tools/tests-cmake/filter-wav/filter-wav.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
#include "SdFat.h"
|
||||
|
||||
// define FIR filter https://fiiir.com/
|
||||
// sampleing rate : 44100
|
||||
// cutoff frequency: 2000
|
||||
// Transition bandwidth: 2000
|
||||
float coef[] = {
|
||||
0.000188725585189891,
|
||||
0.000091879473225926,
|
||||
-0.000016920442768766,
|
||||
-0.000133280461026043,
|
||||
-0.000251640080720683,
|
||||
-0.000364923626390918,
|
||||
-0.000464412185430885,
|
||||
-0.000539946399700805,
|
||||
-0.000580528007418057,
|
||||
-0.000575329172682575,
|
||||
-0.000515050625648420,
|
||||
-0.000393501287598472,
|
||||
-0.000209212939699419,
|
||||
0.000033137236602991,
|
||||
0.000321738209246393,
|
||||
0.000637316639800423,
|
||||
0.000953645970946306,
|
||||
0.001238992395833948,
|
||||
0.001458495336203241,
|
||||
0.001577364656923383,
|
||||
0.001564660155918535,
|
||||
0.001397314635940224,
|
||||
0.001063983705740325,
|
||||
0.000568265297502738,
|
||||
-0.000069161528118792,
|
||||
-0.000809871255352040,
|
||||
-0.001598785008585991,
|
||||
-0.002367155523627244,
|
||||
-0.003037394102238113,
|
||||
-0.003529490734672840,
|
||||
-0.003768583450610565,
|
||||
-0.003693062300853045,
|
||||
-0.003262467087264144,
|
||||
-0.002464373079849631,
|
||||
-0.001319467692097694,
|
||||
0.000115890783337027,
|
||||
0.001750175413602121,
|
||||
0.003460562753784068,
|
||||
0.005100198277458642,
|
||||
0.006508564756602457,
|
||||
0.007524348715512882,
|
||||
0.007999914326580530,
|
||||
0.007816265949382166,
|
||||
0.006897235277941903,
|
||||
0.005221586005661731,
|
||||
0.002831799051373308,
|
||||
-0.000161514004361169,
|
||||
-0.003580331626899644,
|
||||
-0.007185463286171087,
|
||||
-0.010688262221784543,
|
||||
-0.013767303340739213,
|
||||
-0.016089076144421111,
|
||||
-0.017331352983485829,
|
||||
-0.017207593283301702,
|
||||
-0.015490564521582872,
|
||||
-0.012033321379788043,
|
||||
-0.006785795029102398,
|
||||
0.000194498174472729,
|
||||
0.008738731003948556,
|
||||
0.018570633247558595,
|
||||
0.029318005390909025,
|
||||
0.040531349219315310,
|
||||
0.051708529390585928,
|
||||
0.062323892873769583,
|
||||
0.071859896969611939,
|
||||
0.079839064047870847,
|
||||
0.085854013433190587,
|
||||
0.089593426008022170,
|
||||
0.090862068888852371,
|
||||
0.089593426008022170,
|
||||
0.085854013433190587,
|
||||
0.079839064047870847,
|
||||
0.071859896969611939,
|
||||
0.062323892873769583,
|
||||
0.051708529390585928,
|
||||
0.040531349219315317,
|
||||
0.029318005390909029,
|
||||
0.018570633247558595,
|
||||
0.008738731003948556,
|
||||
0.000194498174472729,
|
||||
-0.006785795029102398,
|
||||
-0.012033321379788046,
|
||||
-0.015490564521582872,
|
||||
-0.017207593283301702,
|
||||
-0.017331352983485829,
|
||||
-0.016089076144421115,
|
||||
-0.013767303340739216,
|
||||
-0.010688262221784546,
|
||||
-0.007185463286171090,
|
||||
-0.003580331626899644,
|
||||
-0.000161514004361169,
|
||||
0.002831799051373308,
|
||||
0.005221586005661734,
|
||||
0.006897235277941905,
|
||||
0.007816265949382166,
|
||||
0.007999914326580530,
|
||||
0.007524348715512883,
|
||||
0.006508564756602457,
|
||||
0.005100198277458645,
|
||||
0.003460562753784068,
|
||||
0.001750175413602121,
|
||||
0.000115890783337027,
|
||||
-0.001319467692097694,
|
||||
-0.002464373079849632,
|
||||
-0.003262467087264142,
|
||||
-0.003693062300853045,
|
||||
-0.003768583450610565,
|
||||
-0.003529490734672841,
|
||||
-0.003037394102238113,
|
||||
-0.002367155523627246,
|
||||
-0.001598785008585990,
|
||||
-0.000809871255352040,
|
||||
-0.000069161528118792,
|
||||
0.000568265297502738,
|
||||
0.001063983705740327,
|
||||
0.001397314635940224,
|
||||
0.001564660155918536,
|
||||
0.001577364656923383,
|
||||
0.001458495336203241,
|
||||
0.001238992395833948,
|
||||
0.000953645970946307,
|
||||
0.000637316639800423,
|
||||
0.000321738209246393,
|
||||
0.000033137236602991,
|
||||
-0.000209212939699420,
|
||||
-0.000393501287598472,
|
||||
-0.000515050625648420,
|
||||
-0.000575329172682575,
|
||||
-0.000580528007418057,
|
||||
-0.000539946399700805,
|
||||
-0.000464412185430885,
|
||||
-0.000364923626390918,
|
||||
-0.000251640080720683,
|
||||
-0.000133280461026043,
|
||||
-0.000016920442768766,
|
||||
0.000091879473225926,
|
||||
0.000188725585189891
|
||||
};
|
||||
//
|
||||
uint16_t sample_rate=44100;
|
||||
uint8_t channels = 2; // The stream will have 2 channels
|
||||
SineWaveGenerator<int16_t> wave(32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> in_stream(wave); // Stream generated from sine wave
|
||||
FilteredStream<int16_t, float> in_filtered(in_stream, channels); // Defiles the filter as BaseConverter
|
||||
SdFat sd;
|
||||
SdFile file;
|
||||
EncodedAudioStream out(&file, new WAVEncoder()); // encode as wav file
|
||||
StreamCopy copier(out, in_filtered); // copies sound to out
|
||||
MusicalNotes notes;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto cfg = wave.defaultConfig();
|
||||
cfg.sample_rate = sample_rate;
|
||||
cfg.channels = channels;
|
||||
cfg.bits_per_sample = 16;
|
||||
wave.begin(cfg, 20);
|
||||
in_stream.begin();
|
||||
out.begin();
|
||||
|
||||
// setup filters on channel 1 only
|
||||
in_filtered.setFilter(1, new FIR<float>(coef));
|
||||
|
||||
if (!sd.begin(SS, SPI_HALF_SPEED)) sd.initErrorHalt();
|
||||
if (!file.open("wave.wav", O_RDWR | O_CREAT)) {
|
||||
sd.errorHalt("opening wave.wav for write failed");
|
||||
}
|
||||
|
||||
for (int j=45;j<notes.frequencyCount();j++){
|
||||
wave.setFrequency(notes.frequency(j));
|
||||
for (int i=0;i<10;i++){
|
||||
copier.copy();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
stop();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
}
|
||||
|
||||
32
libraries/audio-tools/tests-cmake/filter/CMakeLists.txt
Normal file
32
libraries/audio-tools/tests-cmake/filter/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(filter)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
# 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 sketch as executable
|
||||
add_executable (filter filter.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(filter PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(filter portaudio arduino_emulator arduino-audio-tools)
|
||||
|
||||
39
libraries/audio-tools/tests-cmake/filter/filter.cpp
Normal file
39
libraries/audio-tools/tests-cmake/filter/filter.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
// define FIR filter
|
||||
float coef[] = { 0.021, 0.096, 0.146, 0.096, 0.021};
|
||||
//
|
||||
uint16_t sample_rate=44100;
|
||||
uint8_t channels = 2; // The stream will have 2 channels
|
||||
WhiteNoiseGenerator<int16_t> noise(32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> in_stream(noise); // Stream generated from sine wave
|
||||
FilteredStream<int16_t, float> in_filtered(in_stream, channels); // Defiles the filter as BaseConverter
|
||||
PortAudioStream out; // Output to Desktop
|
||||
StreamCopy copier(out, in_stream, 1012); // copies sound to out
|
||||
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto cfg = noise.defaultConfig();
|
||||
cfg.sample_rate = sample_rate;
|
||||
cfg.channels = channels;
|
||||
cfg.bits_per_sample = 16;
|
||||
noise.begin(cfg);
|
||||
in_stream.begin();
|
||||
|
||||
// setup filters for all available channels
|
||||
in_filtered.setFilter(0, new FIR<float>(coef));
|
||||
in_filtered.setFilter(1, new FIR<float>(coef));
|
||||
|
||||
out.begin(cfg);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
|
||||
24
libraries/audio-tools/tests-cmake/generator/CMakeLists.txt
Normal file
24
libraries/audio-tools/tests-cmake/generator/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(generator)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
|
||||
|
||||
# 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 (generator generator.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(generator PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(generator arduino_emulator arduino-audio-tools)
|
||||
|
||||
29
libraries/audio-tools/tests-cmake/generator/generator.cpp
Normal file
29
libraries/audio-tools/tests-cmake/generator/generator.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/StdioStream.h"
|
||||
|
||||
//LinuxStdio out; // Output to Desktop
|
||||
CsvOutput<int24_t> out(Serial);
|
||||
SineWaveGenerator<int24_t> sine_wave; // subclass of SoundGenerator with max amplitude
|
||||
GeneratedSoundStream<int24_t> in_stream(sine_wave); // Stream generated from sine wave
|
||||
StreamCopy copier(out, in_stream); // copies sound to out
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto cfg = out.defaultConfig();
|
||||
cfg.bits_per_sample = 24;
|
||||
if (!out.begin(cfg)){
|
||||
stop();
|
||||
}
|
||||
|
||||
sine_wave.begin(cfg.channels, cfg.sample_rate, N_B4);
|
||||
in_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
|
||||
22
libraries/audio-tools/tests-cmake/hdlc/CMakeLists.txt
Normal file
22
libraries/audio-tools/tests-cmake/hdlc/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(hdlc)
|
||||
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 (hdlc hdlc.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(hdlc PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(hdlc arduino_emulator arduino-audio-tools)
|
||||
|
||||
58
libraries/audio-tools/tests-cmake/hdlc/hdlc.cpp
Normal file
58
libraries/audio-tools/tests-cmake/hdlc/hdlc.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Communication/HDLCStream.h"
|
||||
|
||||
RingBuffer<uint8_t> ringBuffer(5 * 1024);
|
||||
QueueStream<uint8_t> queueStream(ringBuffer);
|
||||
HDLCStream hdlcStream(queueStream, 1024);
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
// Open Serial
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
queueStream.begin();
|
||||
Serial.println(ringBuffer.available());
|
||||
|
||||
uint8_t data[1024];
|
||||
// write 100 bytes
|
||||
memset(data, 1, sizeof(data));
|
||||
size_t written = hdlcStream.write(data, 100);
|
||||
Serial.println(ringBuffer.available());
|
||||
assert(written == 100);
|
||||
|
||||
// write 200 bytes
|
||||
memset(data, 2, sizeof(data));
|
||||
written = hdlcStream.write(data, 200);
|
||||
Serial.println(ringBuffer.available());
|
||||
assert(written == 200);
|
||||
|
||||
// write 300 bytes
|
||||
memset(data, 3, sizeof(data));
|
||||
written = hdlcStream.write(data, 300);
|
||||
Serial.println(ringBuffer.available());
|
||||
assert(written == 300);
|
||||
|
||||
// read back first write
|
||||
size_t read = hdlcStream.readBytes(data, 1000);
|
||||
Serial.println(read);
|
||||
for (int j=0;j<100;j++) assert(data[j] == 1);
|
||||
assert(read == 100);
|
||||
|
||||
// read back second write
|
||||
read = hdlcStream.readBytes(data, 1000);
|
||||
Serial.println(read);
|
||||
for (int j=0;j<200;j++) assert(data[j] == 2);
|
||||
assert(read == 200);
|
||||
|
||||
// read back third write
|
||||
read = hdlcStream.readBytes(data, 1000);
|
||||
Serial.println(read);
|
||||
for (int j=0;j<300;j++) assert(data[j] == 3);
|
||||
assert(read == 300);
|
||||
Serial.println("END");
|
||||
}
|
||||
|
||||
// Arduino loop - copy sound to out
|
||||
void loop() {}
|
||||
35
libraries/audio-tools/tests-cmake/ifft/CMakeLists.txt
Normal file
35
libraries/audio-tools/tests-cmake/ifft/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(ifft)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
|
||||
# Emulator is not necessary for -DIS_MIN_DESKTOP
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio")
|
||||
|
||||
# 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()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (ifft ifft.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(ifft PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(ifft arduino-audio-tools)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(ifft PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
38
libraries/audio-tools/tests-cmake/ifft/ifft.cpp
Normal file
38
libraries/audio-tools/tests-cmake/ifft/ifft.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioRealFFT.h" // using RealFFT
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
AudioRealFFT afft; // or AudioKissFFT
|
||||
//CsvOutput<int16_t> out(Serial);
|
||||
MiniAudioStream out;
|
||||
StreamCopy copier(out, afft);
|
||||
int bin_idx = 0;
|
||||
|
||||
// privide fft data
|
||||
void fftFillData(AudioFFTBase &fft) {
|
||||
fft.clearBins();
|
||||
FFTBin bin{1.0f,1.0f};
|
||||
assert(fft.setBin(bin_idx, bin));
|
||||
|
||||
// restart from first bin
|
||||
if (++bin_idx>=fft.size()) bin_idx = 0;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// Setup FFT
|
||||
auto tcfg = afft.defaultConfig(RX_MODE);
|
||||
tcfg.copyFrom(info);
|
||||
tcfg.length = 1024;
|
||||
tcfg.callback = fftFillData;
|
||||
afft.begin(tcfg);
|
||||
|
||||
// setup output
|
||||
auto ocfg = out.defaultConfig(TX_MODE);
|
||||
ocfg.copyFrom(info);
|
||||
out.begin(ocfg);
|
||||
}
|
||||
|
||||
void loop() { copier.copy(); }
|
||||
36
libraries/audio-tools/tests-cmake/miniaudio/CMakeLists.txt
Normal file
36
libraries/audio-tools/tests-cmake/miniaudio/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(generator)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
|
||||
# Emulator is not necessary for -DIS_MIN_DESKTOP
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio")
|
||||
|
||||
# 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()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (generator generator.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(generator PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(generator arduino-audio-tools)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(generator PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
28
libraries/audio-tools/tests-cmake/miniaudio/generator.cpp
Normal file
28
libraries/audio-tools/tests-cmake/miniaudio/generator.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
#include "AudioTools/Disk/SDtdioStream.h"
|
||||
|
||||
//LinuxStdio out; // Output to stdio on Desktop
|
||||
MiniAudioStream out; // Output to MiniAudioStream
|
||||
SineWaveGenerator<int16_t> sine_wave; // subclass of SoundGenerator with max amplitude
|
||||
GeneratedSoundStream<int16_t> in_stream(sine_wave); // Stream generated from sine wave
|
||||
StreamCopy copier(out, in_stream); // copies sound to out
|
||||
|
||||
void setup(){
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto cfg = out.defaultConfig(TX_MODE);
|
||||
//cfg.sample_rate = 22000;
|
||||
if (!out.begin(cfg)){
|
||||
stop();
|
||||
}
|
||||
|
||||
sine_wave.begin(cfg, N_B4);
|
||||
in_stream.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
|
||||
37
libraries/audio-tools/tests-cmake/pipeline/CMakeLists.txt
Normal file
37
libraries/audio-tools/tests-cmake/pipeline/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(pipeline)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm")
|
||||
|
||||
# Emulator is not necessary for -DIS_MIN_DESKTOP
|
||||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library")
|
||||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio")
|
||||
|
||||
|
||||
# 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()
|
||||
|
||||
# Download miniaudio.h
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
|
||||
|
||||
|
||||
# build sketch as executable
|
||||
add_executable (pipeline pipeline.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(pipeline PUBLIC -DIS_MIN_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(pipeline arduino-audio-tools)
|
||||
|
||||
# access to miniaudio in sketch directory
|
||||
target_include_directories(pipeline PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
45
libraries/audio-tools/tests-cmake/pipeline/pipeline.cpp
Normal file
45
libraries/audio-tools/tests-cmake/pipeline/pipeline.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/MiniAudioStream.h"
|
||||
#include "AudioTools/AudioLibs/StdioStream.h"
|
||||
|
||||
int16_t AR1[] = { 0, 4560, 9031, 13327, 17363, 21062, 24350, 27165, 29450, 31163, 32269, 32747, 32587, 31793, 30381, 28377, 25820, 22761, 19259, 15383, 11206, 6812, 2285, -2285, -6812, -11206, -15383, -19259, -22761, -25820, -28377, -30381, -31793, -32587, -32747, -32269, -31163, -29450, -27165, -24350, -21062, -17363, -13327, -9031, -4560 };
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
GeneratorFromArray<int16_t> wave(AR1, 0, false);
|
||||
GeneratedSoundStream<int16_t> snd(wave);
|
||||
Pipeline pip;
|
||||
ResampleStream resample;
|
||||
VolumeStream volume;
|
||||
ChannelFormatConverterStream channels;
|
||||
NumberFormatConverterStream bits;
|
||||
MiniAudioStream out; // Output to MiniAudioStream
|
||||
//I2SStream i2s;
|
||||
StreamCopy copier(out, pip);
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
//Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
out.begin();
|
||||
resample.setStepSize(0.4f);
|
||||
volume.setVolume(0.5);
|
||||
channels.setToChannels(1);
|
||||
bits.setToBits(32);
|
||||
copier.setSynchAudioInfo(true);
|
||||
|
||||
pip.setInput(snd);
|
||||
pip.add(resample);
|
||||
pip.add(volume);
|
||||
pip.add(channels);
|
||||
pip.add(bits);
|
||||
//pip.addNotifyAudioChange(out);
|
||||
Serial.println("*** begin ***");
|
||||
pip.begin(info);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
34
libraries/audio-tools/tests-cmake/player-wav/CMakeLists.txt
Normal file
34
libraries/audio-tools/tests-cmake/player-wav/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(player-wav)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (DCMAKE_CXX_FLAGS "-Werror")
|
||||
|
||||
# add_compile_options(-Wstack-usage=1024)
|
||||
|
||||
# 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 sketch as executable
|
||||
add_executable (player-wav player-wav.cpp)
|
||||
target_include_directories(player-wav PRIVATE "${arduino_emulator_SOURCE_DIR}/ArduinoCore-Linux/libraries/SdFat" )
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(player-wav PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(player-wav portaudio arduino_emulator arduino-audio-tools)
|
||||
|
||||
29
libraries/audio-tools/tests-cmake/player-wav/player-wav.cpp
Normal file
29
libraries/audio-tools/tests-cmake/player-wav/player-wav.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Disk/AudioSourceSTD.h"
|
||||
#include "AudioTools/AudioLibs/StdioStream.h"
|
||||
#include "AudioTools/AudioLibs/PortAudioStream.h"
|
||||
|
||||
//StdioStream out; // Output to Desktop
|
||||
PortAudioStream out; // Output to Desktop
|
||||
const char *startFilePath="/home/pschatzmann/Downloads";
|
||||
const char* ext="wav";
|
||||
AudioSourceSTD source(startFilePath, ext);
|
||||
WAVDecoder decoder;
|
||||
AudioPlayer player(source, out, decoder);
|
||||
|
||||
|
||||
void setup() {
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// setup output
|
||||
auto cfg = out.defaultConfig();
|
||||
out.begin(cfg);
|
||||
|
||||
// setup player
|
||||
//source.setFileFilter("*Bob Dylan*");
|
||||
player.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
player.copy();
|
||||
}
|
||||
22
libraries/audio-tools/tests-cmake/resample/CMakeLists.txt
Normal file
22
libraries/audio-tools/tests-cmake/resample/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(resample)
|
||||
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 (resample resample.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(resample PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(resample arduino_emulator arduino-audio-tools)
|
||||
|
||||
39
libraries/audio-tools/tests-cmake/resample/resample.cpp
Normal file
39
libraries/audio-tools/tests-cmake/resample/resample.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Simple wrapper for Arduino sketch to compilable with cpp in cmake
|
||||
//#include "Arduino.h"
|
||||
#include "AudioTools.h"
|
||||
|
||||
AudioInfo info(44100, 1, 16);
|
||||
//SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
int16_t arsineC256[] = { 436, 657, 877, 1096, 1316, 1534, 1751, 1967, 2183, 2396, 2609, 2819, 3029, 3236, 3441, 3644, 3845, 4044, 4240, 4434, 4625, 4813, 4999, 5181, 5360, 5536, 5709, 5878, 6043, 6205, 6364, 6518, 6668, 6815, 6957, 7095, 7229, 7359, 7484, 7604, 7720, 7831, 7938, 8040, 8137, 8229, 8316, 8398, 8475, 8547, 8613, 8675, 8731, 8782, 8828, 8868, 8903, 8933, 8957, 8976, 8989, 8997, 9000, 8997, 8989, 8975, 8956, 8932, 8902, 8867, 8826, 8780, 8729, 8672, 8610, 8544, 8471, 8394, 8312, 8225, 8133, 8035, 7933, 7827, 7715, 7599, 7478, 7353, 7223, 7089, 6951, 6808, 6662, 6511, 6357, 6198, 6036, 5870, 5701, 5528, 5352, 5173, 4990, 4805, 4617, 4425, 4232, 4035, 3836, 3635, 3432, 3227, 3019, 2810, 2599, 2387, 2173, 1958, 1742, 1524, 1306, 1087, 867, 647, 426, 205, -16, -237, -458, -679, -899, -1118, -1337, -1556, -1773, -1989, -2204, -2418, -2630, -2840, -3049, -3256, -3461, -3664, -3865, -4064, -4260, -4453, -4644, -4832, -5017, -5199, -5378, -5553, -5726, -5894, -6060, -6221, -6379, -6533, -6683, -6829, -6971, -7109, -7242, -7371, -7496, -7616, -7731, -7842, -7948, -8050, -8146, -8238, -8324, -8406, -8482, -8554, -8620, -8681, -8736, -8787, -8832, -8872, -8906, -8936, -8959, -8978, -8990, -8998, -9000, -8997, -8988, -8974, -8954, -8929, -8898, -8863, -8822, -8775, -8723, -8666, -8604, -8537, -8464, -8386, -8304, -8216, -8123, -8025, -7923, -7816, -7704, -7587, -7466, -7340, -7210, -7076, -6937, -6794, -6647, -6496, -6341, -6182, -6020, -5854, -5684, -5511, -5334, -5155, -4972, -4786, -4598, -4406, -4212, -4016, -3817, -3615, -3412, -3206, -2999, -2789, -2578, -2366, -2152, -1936, -1720, -1502, -1284, -1065, -845, -625, -404, -183, 38, 180 };
|
||||
GeneratorFromArray<int16_t> sineWave(arsineC256,0,false);
|
||||
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
|
||||
ResampleStream out(sound); // We double the output sample rate
|
||||
CsvOutput<int16_t> csv(Serial); // Output to Serial
|
||||
InputMerge<int16_t> imerge;
|
||||
StreamCopy copier(csv, imerge, 1024); // copies sound to out
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
// Open Serial
|
||||
//Serial.begin(115200);
|
||||
//AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto config = out.defaultConfig();
|
||||
config.copyFrom(info);
|
||||
out.begin(config);
|
||||
|
||||
// Define CSV Output
|
||||
csv.begin(info);
|
||||
sound.begin(info);
|
||||
// sineWave.begin(config, N_B4);
|
||||
sineWave.begin(info);
|
||||
imerge.begin(info);
|
||||
imerge.add(out, 1);
|
||||
//Serial.println("started (mixer)...");
|
||||
}
|
||||
|
||||
// Arduino loop - copy sound to out
|
||||
void loop() {
|
||||
copier.copy();
|
||||
//Serial.println("----");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(resample_ext)
|
||||
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 (resample_ext resample_ext.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(resample_ext PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(resample_ext arduino_emulator arduino-audio-tools)
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "AudioTools.h"
|
||||
|
||||
AudioInfo info(44100, 1, 16);
|
||||
// subclass of SoundGenerator with max amplitude of 32000
|
||||
SineWaveGenerator<int16_t> sineWave(32000);
|
||||
// Stream generated from sine wave
|
||||
GeneratedSoundStream<int16_t> sound(sineWave);
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
//ResampleStreamT<LinearInterpolaror> resample(out);
|
||||
ResampleStreamT<BSplineInterpolator> resample(sound);
|
||||
StreamCopy copier(out, resample); // copies sound to out
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
// Open Serial
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// define resample
|
||||
auto rcfg = resample.defaultConfig();
|
||||
rcfg.copyFrom(info);
|
||||
rcfg.step_size = 0.5;
|
||||
resample.begin(rcfg);
|
||||
|
||||
// Define CSV Output
|
||||
out.begin(info);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
Serial.println("started...");
|
||||
}
|
||||
|
||||
// Arduino loop - copy sound to out
|
||||
void loop() { copier.copy(); }
|
||||
22
libraries/audio-tools/tests-cmake/rtsp/CMakeLists.txt
Normal file
22
libraries/audio-tools/tests-cmake/rtsp/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(rtsp)
|
||||
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 (rtsp rtsp.cpp)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(rtsp PUBLIC -DIS_DESKTOP)
|
||||
|
||||
# specify libraries
|
||||
target_link_libraries(rtsp arduino_emulator arduino-audio-tools)
|
||||
|
||||
42
libraries/audio-tools/tests-cmake/rtsp/rtsp.cpp
Normal file
42
libraries/audio-tools/tests-cmake/rtsp/rtsp.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Disk/AudioSourceSTD.h"
|
||||
#include "AudioTools/AudioCodecs/MP3Parser.h"
|
||||
#include "AudioTools/Communication/RTSP/RTSPPlatformWiFi.h"
|
||||
#include "AudioTools/Communication/RTSP.h"
|
||||
|
||||
int port = 8554;
|
||||
|
||||
// rtsp
|
||||
MP3ParserEncoder enc; // mp3 packaging
|
||||
RTSPFormatMP3 mp3format(enc); // RTSP mp3
|
||||
MetaDataFilterEncoder filter(enc);
|
||||
RTSPOutput<RTSPPlatformWiFi> rtsp_out(mp3format, filter);
|
||||
AudioSourceSTD source("/home/pschatzmann/Music/Elvis Costello/Best Of/", ".mp3");
|
||||
CopyDecoder dec; // no decoding, just copy
|
||||
AudioPlayer player(source, rtsp_out, dec);
|
||||
RTSPServer<RTSPPlatformWiFi> rtsp(rtsp_out.streamer(), port);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// delay between mp3 files
|
||||
source.setTimeoutAutoNext(1000);
|
||||
|
||||
// start the player
|
||||
player.begin();
|
||||
|
||||
// Start Output Stream
|
||||
rtsp_out.begin();
|
||||
|
||||
// Start Wifi & rtsp server
|
||||
rtsp.begin();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (rtsp_out && rtsp) {
|
||||
player.copy();
|
||||
}
|
||||
}
|
||||
26
libraries/audio-tools/tests-cmake/url-test/CMakeLists.txt
Normal file
26
libraries/audio-tools/tests-cmake/url-test/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# set the project name
|
||||
project(url-test)
|
||||
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 (url-test url-test.cpp)
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(url-test PUBLIC -DARDUINO -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(url-test arduino_emulator arduino-audio-tools)
|
||||
|
||||
21
libraries/audio-tools/tests-cmake/url-test/url-test.cpp
Normal file
21
libraries/audio-tools/tests-cmake/url-test/url-test.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Communication/AudioHttp.h"
|
||||
|
||||
URLStream url("ssid","password");
|
||||
NullStream null_out; // final output of decoded stream
|
||||
StreamCopy copier(null_out, url); // copy url to decoder
|
||||
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
// mp3 radio
|
||||
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128","audio/mp3");
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (!copier.copy()) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user