snapshot
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user