Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated build system #21

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
960283c
converted to cmake type build
astro-friedel Mar 29, 2023
42b2936
added missing include
astro-friedel Apr 14, 2023
74d20a8
moved dependency checking to mail illixr build
astro-friedel Apr 18, 2023
42a96db
better handling of dependencies
astro-friedel Apr 18, 2023
6e1031e
fixed package name
astro-friedel Apr 18, 2023
10981b5
another version update
astro-friedel Apr 18, 2023
ff3c430
fixed scope issue in cmake
astro-friedel Apr 18, 2023
6ee5a23
fixed include paths
astro-friedel Apr 18, 2023
f5ae993
added ILLIXR root variable for headers
astro-friedel Apr 18, 2023
d08ee89
added missing dependency
astro-friedel Apr 18, 2023
4839681
fixed include paths
astro-friedel Apr 18, 2023
40c51b4
fixed typo in dirs
astro-friedel Apr 18, 2023
a6f419c
fixed scope issue and variable name
astro-friedel Apr 19, 2023
61032ab
added install tagets
astro-friedel Apr 20, 2023
bcdd8bf
updates for centos
astro-friedel May 1, 2023
147989c
check
astro-friedel May 2, 2023
604c6ec
added build suffix to library name
astro-friedel May 4, 2023
ca8f56f
fixed incorrect naming
astro-friedel May 5, 2023
f76ccfb
removed un-needed code, added install of sample files
astro-friedel May 11, 2023
bb3e4a7
updated compile definitions
astro-friedel May 11, 2023
714c354
updated ILLIXR code structure
astro-friedel May 17, 2023
0aad861
removed un-needed openCV dependency
astro-friedel Aug 23, 2023
ebc2f04
added spdlog dependency
astro-friedel Sep 14, 2023
ec108fc
added sqlite3 library to link
astro-friedel Mar 27, 2024
c6ee970
converted to switchboard interface for env vars
astro-friedel Nov 22, 2024
a152baa
fixed unclosed endif
astro-friedel Nov 22, 2024
e1302d1
added missing namespace
astro-friedel Nov 22, 2024
b22643c
another namespace issue
astro-friedel Nov 22, 2024
42bb6ef
fixed signature issue
astro-friedel Nov 22, 2024
89b2c8c
fixed up some errors
astro-friedel Nov 22, 2024
b832dc0
bug fixes
astro-friedel Nov 22, 2024
5aaf2e7
remove submodules and removed ifdef
astro-friedel Jan 31, 2025
e83f242
updated for changes in switchboard
astro-friedel Feb 4, 2025
d7ffea3
fix for updates from ILLIXR
astro-friedel Feb 5, 2025
b8a91f4
updated to match guidelines
astro-friedel Feb 17, 2025
0e0630f
removed abort calls
astro-friedel Feb 17, 2025
d05996d
Merge branch 'pre_meerge_fixes' into updatedBuildSystem
astro-friedel Feb 19, 2025
801a572
fix typos
astro-friedel Feb 19, 2025
f2603d8
updated for changes in ILLIXR
astro-friedel Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
audio
solo.dbg
solo.opt

cmake-*
.idea

build/
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_VERBOSE_MAKEFILE True)

project(audio_pipeline VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FindPkgConfig)

set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -Wall -fPIC -Wno-overloaded-virtual")
set(CMAKE_CXX_FLAGE_RELEASE "-O3 -DNDEBUG -Wall -fPIC -Wno-overloaded-virtual")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-ggdb -O3 -Wall -fPIC -Wno-overloaded-virtual")
set(ILLIXR_INTEGRATION ON)
add_definitions(-DILLIXR_INTEGRATION)
set(ILLIXR_ROOT "" CACHE PATH "Path to ILLIXR headers")

pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0>=19)
pkg_check_modules(SPATIALAUDIO REQUIRED spatialaudio)
find_package(spdlog REQUIRED)
find_package(SQLite3 REQUIRED)

if (CMAKE_VERSION VERSION_LESS "3.30.0")
find_package(Boost REQUIRED COMPONENTS filesystem serialization iostreams)
else()
find_package(Boost REQUIRED COMPONENTS filesystem serialization iostreams CONFIG)
endif()

add_executable(solo${ILLIXR_BUILD_SUFFIX}.exe src/main.cpp)
add_library(plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} SHARED
src/audio.cpp
include/audio.hpp
src/plugin.cpp
include/plugin.hpp
src/sound.cpp
include/sound.hpp
src/realtime.cpp
include/realtime.hpp
)
include_directories(${CMAKE_INSTALL_PREFIX}/include ${PROJECT_SOURCE_DIR}/include ${ILLIXR_ROOT})

if(ILLIXR_INTEGRATION)
target_compile_definitions(plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} PUBLIC -DAUDIO_SAMPLES=\"${CMAKE_INSTALL_PREFIX}/etc/audio_pipeline\")
endif()

target_include_directories(plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} PUBLIC ${PORTAUDIO_INCLUDE_DIRS} ${SPATIALAUDIO_INCLUDE_DIRS})
target_link_libraries(plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} PUBLIC ${PORTAUDIO_LIBRARIES} ${SPATIALAUDIO_LIBRARIES} spdlog::spdlog sqlite3)

target_link_libraries(solo${ILLIXR_BUILD_SUFFIX}.exe PUBLIC plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} pthread spdlog::spdlog Boost::serialization)

install(TARGETS plugin.audio_pipeline${ILLIXR_BUILD_SUFFIX} DESTINATION lib)
install(TARGETS solo${ILLIXR_BUILD_SUFFIX}.exe DESTINATION bin)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/samples
DESTINATION etc/audio_pipeline)
64 changes: 0 additions & 64 deletions include/audio.h

This file was deleted.

75 changes: 75 additions & 0 deletions include/audio.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once

#ifdef ILLIXR_INTEGRATION

#include "illixr/switchboard.hpp"

#endif

#include "sound.hpp"

#include <optional>
#include <pthread.h>
#include <string>
#include <string_view>
#include <vector>

namespace ILLIXR::audio {
class ab_audio {
public:
// Process types
enum class process_type {
FULL, // FULL for output wav file
ENCODE, // For profiling, do file reading and encoding without file output
DECODE // For profiling, do ambisonics decoding without file output
};

ab_audio(std::string output_file_path, process_type proc_type_in);

// Process a block (1024) samples of sound
void process_block();

// Load sound source files (predefined)
#ifdef ILLIXR_INTEGRATION
void load_source(const std::shared_ptr<ILLIXR::switchboard> &sb);
#else
void load_source();
#endif

// Buffer of most recent processed block for fast copying to audio buffer
short most_recent_block_L[BLOCK_SIZE];
short most_recent_block_R[BLOCK_SIZE];
bool buffer_ready;

// Number of blocks left to process before this stream is complete
unsigned long num_blocks_left;

private:
// Generate dummy WAV output file header
void generate_wav_header();

// Read in data from WAV files and encode into ambisonics
void read_and_encode(CBFormat &sum_bf);

// Apply rotation and zoom effects to the ambisonics sound field
void rotate_and_zoom(CBFormat &sum_bf);

// Write out a block of samples to the output file
void write_file(float **result_sample);

// Abort failed configuration
void config_abort(const std::string_view &comp_name) const;

void update_rotation();

void update_zoom();

process_type process_type_;
std::vector<sound> sound_srcs_; //!< a list of sound sources in this audio
std::optional<std::ofstream> output_file_; //!< target output file
CAmbisonicBinauralizer decoder_; //!< decoder associated with this audio
CAmbisonicProcessor rotator_; //!< ambisonics rotator associated with this audio
CAmbisonicZoomer zoomer_; //!< ambisonics zoomer associated with this audio
int frame_ = 0;
};
}
1 change: 0 additions & 1 deletion include/common

This file was deleted.

47 changes: 47 additions & 0 deletions include/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once
#include "audio.hpp"

#include "illixr/data_format/pose.hpp"
#include "illixr/phonebook.hpp"
#include "illixr/relative_clock.hpp"
#include "illixr/switchboard.hpp"
#include "illixr/threadloop.hpp"


namespace ILLIXR {

class audio_xcoding : public threadloop {
public:
audio_xcoding(phonebook *pb_, bool encoding);

void _p_thread_setup() override;

skip_option _p_should_skip() override;

void _p_one_iteration() override;

private:
const std::shared_ptr<switchboard> switchboard_;
const std::shared_ptr<relative_clock> clock_;
switchboard::reader<data_format::pose_type> pose_;
ILLIXR::audio::ab_audio xcoder_;
time_point last_time_;
static constexpr duration audio_period_{
freq_to_period(static_cast<double>(SAMPLERATE) / static_cast<double>(BLOCK_SIZE))};
bool encoding_;
};

class audio_pipeline : public plugin {
public:
[[maybe_unused]] audio_pipeline(const std::string &name_, phonebook *pb_)
: plugin{name_, pb_}, audio_encoding{pb_, true}, audio_decoding{pb_, false} {}

void start() override;

void stop() override;

private:
audio_xcoding audio_encoding;
audio_xcoding audio_decoding;
};
}
9 changes: 2 additions & 7 deletions include/realtime.h → include/realtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
*
* The realtime audio support requires the PortAudio library.
*/

#ifndef REALTIME_H
#define REALTIME_H

#pragma once
/*
* illixr_rt_init
*
Expand All @@ -23,6 +20,4 @@
* This function is blocking and will not return until the audio source is exhausted.
* Launch this in an independent thread!
*/
void *illixr_rt_init(void *audioObj);

#endif // REALTIME_H
void *illixr_rt_init(void *audio_obj);
42 changes: 0 additions & 42 deletions include/sound.h

This file was deleted.

39 changes: 39 additions & 0 deletions include/sound.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <fstream>
#include <memory>
#include <spatialaudio/Ambisonics.h>
#include <string>

constexpr std::size_t SAMPLERATE {48000U};
constexpr std::size_t BLOCK_SIZE {512U};
constexpr std::size_t NORDER {3U};
constexpr std::size_t NUM_SRCS {16U};

#define NUM_CHANNELS (OrderToComponents(NORDER, true))

namespace ILLIXR::audio{
class sound{
public:
sound(std::string src_filename, unsigned n_order, bool b3D);

// set sound src position
void set_src_pos(const PolarPoint& pos);

// set sound amplitude scale
[[maybe_unused]] void set_src_amp(float amp_scale);

// read sound samples from mono 16bit WAV file and encode into ambisonics format
std::weak_ptr<CBFormat> read_in_b_format();
private:
// Abort failed configuration
void config_abort(const std::string_view& comp_name) const;

std::fstream src_file_; //!< corresponding sound src file
float sample_[BLOCK_SIZE]; //!< sample buffer HARDCODE
std::shared_ptr<CBFormat> b_format_; //!< ambisonics format sound buffer
CAmbisonicEncoderDist b_encoder_; //!< ambisonics encoder, containing format info, position info, etc.
PolarPoint src_pos_; //!< ambisonics position
float amp_; //!< amplitude scale to avoid clipping
};
}
1 change: 0 additions & 1 deletion libspatialaudio
Submodule libspatialaudio deleted from 77a901
1 change: 0 additions & 1 deletion portaudio
Submodule portaudio deleted from 7e2a33
Loading