Skip to content

Commit

Permalink
Export symbols so we can actually link other Windows projects to libr…
Browse files Browse the repository at this point in the history
…ade.dll.
  • Loading branch information
tmiw committed Oct 2, 2024
1 parent 2810ace commit 00f4e3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ project(RADAE
LANGUAGES C
)

option(BUILD_SHARED_LIBS
"Build shared library. Set to OFF for static library." ON)
option(AVX "Enable AVX CPU optimizations." ON)

if(NOT CODEC2_DEV_BUILD_DIR)
Expand Down
18 changes: 11 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(lpcnet_demo lpcnet_demo.c)
target_link_libraries(lpcnet_demo opus m)

add_executable(radae_tx radae_tx.c rade_api.c)
#set_source_files_properties(rade_api.c PROPERTIES COMPILE_FLAGS "${PYTHON_C_FLAGS}")
target_link_libraries(radae_tx Python3::Python Python3::NumPy)
add_library(rade rade_api.c)
target_link_libraries(rade Python3::Python Python3::NumPy)
set_target_properties(rade PROPERTIES
SOVERSION "0.1"
PUBLIC_HEADER "rade_api.h"
)

add_executable(radae_rx radae_rx.c rade_api.c)
target_link_libraries(radae_rx Python3::Python Python3::NumPy)
add_executable(radae_tx radae_tx.c)
target_link_libraries(radae_tx rade Python3::Python Python3::NumPy)

add_executable(radae_rx radae_rx.c)
target_link_libraries(radae_rx rade Python3::Python Python3::NumPy)

add_library(rade SHARED rade_api.c)
target_link_libraries(rade Python3::Python Python3::NumPy)
32 changes: 19 additions & 13 deletions src/rade_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

#include <sys/types.h>

#if _WIN32
#define RADE_EXPORT __declspec(dllexport) __stdcall
#else
#define RADE_EXPORT

#endif // _WIN32
// This declares a single-precision (float) complex number

#ifndef __RADE_COMP__
Expand All @@ -58,38 +64,38 @@ extern "C" {
#define RADE_SPEECH_SAMPLE_RATE 16000 // speech sample rate

// note single context only in this version, one context has one Tx, and one Rx
struct rade *rade_open(char model_file[]);
void rade_close(struct rade *r);
RADE_EXPORT struct rade *rade_open(char model_file[]);
RADE_EXPORT void rade_close(struct rade *r);

// Allows API users to determine if the API has changed
int rade_version(void);
RADE_EXPORT int rade_version(void);

// helpers to set up arrays
int rade_n_tx_out(struct rade *r);
int rade_n_tx_eoo_out(struct rade *r);
int rade_nin_max(struct rade *r);
int rade_n_features_in_out(struct rade *r);
RADE_EXPORT int rade_n_tx_out(struct rade *r);
RADE_EXPORT int rade_n_tx_eoo_out(struct rade *r);
RADE_EXPORT int rade_nin_max(struct rade *r);
RADE_EXPORT int rade_n_features_in_out(struct rade *r);

// note vocoder is not encapsulated in API in this version
// returns number of RADE_COMP samples written to tx_out[]
int rade_tx(struct rade *r, RADE_COMP tx_out[], float features_in[]);
RADE_EXPORT int rade_tx(struct rade *r, RADE_COMP tx_out[], float features_in[]);

// call this for the final frame at the end of over
// returns the number of RADE_COMP samples written to tx_eoo_out[]
int rade_tx_eoo(struct rade *r, RADE_COMP tx_eoo_out[]);
RADE_EXPORT int rade_tx_eoo(struct rade *r, RADE_COMP tx_eoo_out[]);

// call me before each call to rade_rx(), provide nin samples to rx_in[]
int rade_nin(struct rade *r);
RADE_EXPORT int rade_nin(struct rade *r);

// returns non-zero if features_out[] contains valid output. The number
// returned is the number of samples written to features_out[]
int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]);
RADE_EXPORT int rade_rx(struct rade *r, float features_out[], RADE_COMP rx_in[]);

// returns non-zero if Rx is currently in sync
int rade_sync(struct rade *r);
RADE_EXPORT int rade_sync(struct rade *r);

// returns the current frequency offset of the Rx signal ( when rade_sync()!=0 )
float rade_freq_offset(struct rade *r);
RADE_EXPORT float rade_freq_offset(struct rade *r);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 00f4e3f

Please sign in to comment.