Skip to content

Commit 95c6b91

Browse files
committed
cmake cleanup
1 parent 820359e commit 95c6b91

File tree

29 files changed

+269
-155
lines changed

29 files changed

+269
-155
lines changed

CMakeLists.txt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ cmake_minimum_required(VERSION 3.0)
33
# set the project name
44
project(arduino-audio-tools)
55

6+
include(FetchContent)
7+
68
add_library(arduino-audio-tools INTERFACE)
79

8-
option(BUILD_TESTS "Build all tests automatically" OFF)
10+
#option(BUILD_TESTS "Build all tests automatically" OFF)
11+
option(ADD_STD_LIB "Add Standard Desktop Libraries" ON)
912

1013

1114
# make include directory available to calling projects
@@ -18,8 +21,22 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" # source directory
1821
PATTERN "*.h" # select header files
1922
)
2023

21-
if (BUILD_TESTS)
22-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
23-
else()
24-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests EXCLUDE_FROM_ALL)
24+
# Add basic libraries necessary for desktop build
25+
if (ADD_STD_LIB)
26+
27+
FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG v19.7.0 )
28+
FetchContent_GetProperties(portaudio)
29+
if(NOT portaudio_POPULATED)
30+
FetchContent_Populate(portaudio)
31+
add_subdirectory(${portaudio_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/portaudio)
32+
endif()
33+
34+
# Build with Linux Arduino Emulator
35+
FetchContent_Declare(arduino_emulator GIT_REPOSITORY "https://github.com/pschatzmann/Arduino-Emulator.git" GIT_TAG main )
36+
FetchContent_GetProperties(arduino_emulator)
37+
if(NOT arduino_emulator_POPULATED)
38+
FetchContent_Populate(arduino_emulator)
39+
add_subdirectory(${arduino_emulator_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/emulator)
40+
endif()
41+
2542
endif()

examples/examples-desktop/generator/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
2525
# endif()
2626

2727
# Build with arduino-audio-tools
28-
FetchContent_Declare(arduino_audio_tools GIT_REPOSITORY "https://github.com/pschatzmann/arduino-audio-tools.git" GIT_TAG main )
29-
FetchContent_GetProperties(arduino_audio_tools)
30-
if(NOT arduino_audio_tools_POPULATED)
31-
FetchContent_Populate(arduino_audio_tools)
32-
add_subdirectory(${arduino_audio_tools_SOURCE_DIR})
28+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
29+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../.. ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools )
3330
endif()
3431

3532
# build sketch as executable

examples/examples-desktop/mp3/CMakeLists.txt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,8 @@ set (DCMAKE_CXX_FLAGS "-Werror")
88
include(FetchContent)
99
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
1010

11-
# # Build with Portaudio
12-
# FetchContent_Declare(portaudio GIT_REPOSITORY "https://github.com/PortAudio/portaudio.git" GIT_TAG master )
13-
# FetchContent_GetProperties(portaudio)
14-
# if(NOT portaudio_POPULATED)
15-
# FetchContent_Populate(portaudio)
16-
# add_subdirectory(${portaudio_SOURCE_DIR})
17-
# endif()
18-
19-
# # Build with Linux Arduino Emulator
20-
# FetchContent_Declare(arduino_emulator GIT_REPOSITORY "https://github.com/pschatzmann/Arduino-Emulator.git" GIT_TAG main )
21-
# FetchContent_GetProperties(arduino_emulator)
22-
# if(NOT arduino_emulator_POPULATED)
23-
# FetchContent_Populate(arduino_emulator)
24-
# add_subdirectory(${arduino_emulator_SOURCE_DIR})
25-
# endif()
26-
27-
# Build with arduino-audio-tools
28-
FetchContent_Declare(arduino_audio_tools GIT_REPOSITORY "https://github.com/pschatzmann/arduino-audio-tools.git" GIT_TAG main )
29-
FetchContent_GetProperties(arduino_audio_tools)
30-
if(NOT arduino_audio_tools_POPULATED)
31-
FetchContent_Populate(arduino_audio_tools)
32-
add_subdirectory(${arduino_audio_tools_SOURCE_DIR})
11+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
12+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../.. ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools )
3313
endif()
3414

3515
# Build with libhelix

examples/examples-desktop/ogg/CMakeLists.txt

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/examples-desktop/ogg/README.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/AudioCodecs/CodecOpus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct OpusEncoderSettings : public OpusSettings {
9595
/// 0, 1
9696
int use_dtx = -1;
9797
/// 5, 10, 20, 40, 80, 120, 160, 200, 240
98-
int frame_sizes_ms_x2 = 10; /* x2 to avoid 2.5 ms */
98+
int frame_sizes_ms_x2 = -1; /* x2 to avoid 2.5 ms */
9999
};
100100

101101
/**

src/AudioCodecs/ContainerOgg.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class OggContainerEncoder : public AudioEncoder {
257257
/// Writes Ogg Packet
258258
virtual size_t write(const void *in_ptr, size_t in_size) override {
259259
if (!is_open || p_print == nullptr) return 0;
260-
LOGD("write: %u", in_size);
260+
LOGD("write: %d", (int) in_size);
261261

262262
op.packet = (uint8_t *)in_ptr;
263263
op.bytes = in_size;
@@ -294,10 +294,10 @@ class OggContainerEncoder : public AudioEncoder {
294294
AudioBaseInfo cfg;
295295

296296
virtual bool writePacket(ogg_packet &op, int flag = 0) {
297-
LOGD("writePacket: %u", op.bytes);
297+
LOGD("writePacket: %d", (int) op.bytes);
298298
long result = oggz_write_feed(p_oggz, &op, serialno, flag, NULL);
299299
if (result < 0) {
300-
LOGE("oggz_write_feed: %d", result);
300+
LOGE("oggz_write_feed: %d", (int) result);
301301
return false;
302302
}
303303
return true;
@@ -327,7 +327,7 @@ class OggContainerEncoder : public AudioEncoder {
327327

328328
// Final Stream Callback
329329
static size_t ogg_io_write(void *user_handle, void *buf, size_t n) {
330-
LOGD("ogg_io_write: %u", n);
330+
LOGD("ogg_io_write: %d", (int) n);
331331
OggContainerEncoder *self = (OggContainerEncoder *)user_handle;
332332
if (self == nullptr) {
333333
LOGE("self is null");

src/AudioLibs/PortAudioStream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class PortAudioStream : public AudioStreamX {
4040
public:
4141
PortAudioStream() {
4242
LOGD(LOG_METHOD);
43-
this->buffer_size = buffer_size;
4443
}
4544

4645
~PortAudioStream(){

src/AudioTools/AudioStreams.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ class DynamicMemoryStream : public AudioStreamX {
349349
}
350350

351351
/// Intializes the processing
352-
virtual bool begin(){
352+
virtual bool begin() override {
353353
clear();
354354
temp_audio.resize(default_buffer_size);
355355
return true;
356356
}
357357

358-
virtual void end() {
358+
virtual void end() override {
359359
clear();
360360
}
361361

@@ -648,7 +648,7 @@ class NullStream : public BufferedStream {
648648
}
649649

650650
/// Define object which need to be notified if the basinfo is changing
651-
void setNotifyAudioChange(AudioBaseInfoDependent &bi) {}
651+
void setNotifyAudioChange(AudioBaseInfoDependent &bi) override {}
652652

653653
void setAudioInfo(AudioBaseInfo info) override {}
654654

@@ -933,7 +933,7 @@ class VolumeStream : public AudioStreamX {
933933
return c;
934934
}
935935

936-
bool begin(AudioBaseInfo cfg){
936+
bool begin(AudioBaseInfo cfg) {
937937
VolumeStreamConfig cfg1;
938938
cfg1.channels = cfg.channels;
939939
cfg1.sample_rate = cfg.sample_rate;
@@ -943,7 +943,7 @@ class VolumeStream : public AudioStreamX {
943943
return begin(cfg1);
944944
}
945945

946-
void end() {
946+
void end() override {
947947
is_active = false;
948948
}
949949

src/AudioTools/AudioStreamsConverter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ChannelFormatConverterStreamT : public AudioStreamX {
8484
buffer.resize(result_samples);
8585
result = converter.convert((uint8_t*)buffer.data(),(uint8_t*) in_data, size);
8686
if (result!=result_samples*sizeof(T)){
87-
LOGE("size %d -> result: %d - expeced: %d", size, result, result_samples*sizeof(T));
87+
LOGE("size %d -> result: %d - expeced: %d", (int) size, (int) result, (int) result_samples*sizeof(T));
8888
}
8989
return result;
9090
}

0 commit comments

Comments
 (0)