Merge branch 'master' into ms-static-portaudio

pull/304/head
Mooneer Salem 2022-11-22 09:30:44 -08:00
commit caaa11fbb2
19 changed files with 220 additions and 220 deletions

View File

@ -6,13 +6,31 @@
# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
#
cmake_minimum_required(VERSION 3.13)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version")
project(FreeDV
VERSION 1.8.4
DESCRIPTION "HF Digital Voice for Radio Amateurs"
HOMEPAGE_URL "https://freedv.org"
set(PROJECT_NAME FreeDV)
set(PROJECT_VERSION 1.8.4)
set(PROJECT_DESCRIPTION "HF Digital Voice for Radio Amateurs")
set(PROJECT_HOMEPAGE_URL "https://freedv.org")
if(APPLE)
project(
${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
DESCRIPTION ${PROJECT_DESCRIPTION}
HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL}
LANGUAGES C CXX OBJCXX
)
else(APPLE)
project(
${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
DESCRIPTION ${PROJECT_DESCRIPTION}
HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL}
LANGUAGES C CXX
)
)
endif(APPLE)
# Adds a tag to the end of the version string. Leave empty
# for official release builds.
@ -125,18 +143,6 @@ if(BOOTSTRAP_WXWIDGETS)
include(cmake/BuildWxWidgets.cmake)
endif(BOOTSTRAP_WXWIDGETS)
#
# Perform bootstrap build of wxWidgets
#
if(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG})
message(STATUS "Will perform bootstrap build of wxWidgets.
After make step completes, re-run cmake and make again to perform FreeDV build.")
#
# Continue normal build if not bootstrapping wxWidgets or is already built.
#
else(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG})
#
# Various hacks and work arounds for building under MinGW.
#
@ -393,13 +399,6 @@ endif(NOT USE_STATIC_SNDFILE)
# Find wxWidgets
#
if(NOT BOOTSTRAP_WXWIDGETS)
set(WXCONFIG "" CACHE FILEPATH "Location of wx-config binary.")
set(WXRC "" CACHE FILEPATH "Location of wxrc binary.")
else(NOT BOOTSTRAP_WXWIDGETS)
# set(WXCONFIG "${CMAKE_BINARY_DIR}/external/dist/bin/wx-config")
# set(WXRC "${CMAKE_BINARY_DIR}/external/dist/bin/wxrc")
# list(APPEND FREEDV_STATIC_DEPS wxWidgets)
endif(NOT BOOTSTRAP_WXWIDGETS)
message(STATUS "Looking for wxWidgets...")
if(WXCONFIG)
message(STATUS "wx-config: ${WXCONFIG}")
@ -440,6 +439,9 @@ if(wxWidgets_FOUND)
include("${wxWidgets_USE_FILE}")
list(APPEND FREEDV_LINK_LIBS ${wxWidgets_LIBRARIES})
endif(wxWidgets_FOUND)
else(NOT BOOTSTRAP_WXWIDGETS)
set(DARK_MODE_DISABLE "false")
endif(NOT BOOTSTRAP_WXWIDGETS)
#
# Find speex library
@ -586,5 +588,3 @@ elseif(UNIX AND NOT APPLE)
include(CPack)
endif(WIN32)
endif(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG})

View File

@ -786,6 +786,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
1. Build system:
* Add checks for .git folder to prevent errors when building from official release tarballs. (PR #294)
* Simplify PortAudio static build to fix multi-core build issue on macOS. (PR #304)
* Upgrade bootstrapped wxWidgets to v3.2.1. (PR #302)
2. Enhancements:
* Update FreeDV configuration defaults to improve first-time usability. (PR #293)
3. Bugfixes:

View File

@ -62,10 +62,5 @@ if [ -d .git ]; then
git pull
fi
mkdir -p build_osx && cd build_osx && rm -Rf *
cmake -DBUILD_OSX_UNIVERSAL=1 -DCMAKE_BUILD_TYPE=Debug -DBOOTSTRAP_WXWIDGETS=1 -DUSE_STATIC_SPEEXDSP=1 -DUSE_STATIC_PORTAUDIO=1 -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a -DCODEC2_BUILD_DIR=$CODEC2DIR/build_osx -DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx ..
make VERBOSE=1
# Rebuild now that wxWidgets is bootstrapped
cmake -DBUILD_OSX_UNIVERSAL=1 -DCMAKE_BUILD_TYPE=Debug -DBOOTSTRAP_WXWIDGETS=1 -DUSE_STATIC_SPEEXDSP=1 -DUSE_STATIC_PORTAUDIO=1 -DUSE_STATIC_SAMPLERATE=1 -DUSE_STATIC_SNDFILE=1 -DUNITTEST=$UT_ENABLE -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a -DCODEC2_BUILD_DIR=$CODEC2DIR/build_osx -DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx ..
make VERBOSE=1
cmake -DBUILD_OSX_UNIVERSAL=1 -DCMAKE_BUILD_TYPE=Debug -DBOOTSTRAP_WXWIDGETS=1 -DUSE_STATIC_SPEEXDSP=1 -DUSE_STATIC_PORTAUDIO=1 -DUSE_STATIC_SAMPLERATE=1 -DUSE_STATIC_SNDFILE=1 -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a -DCODEC2_BUILD_DIR=$CODEC2DIR/build_osx -DLPCNET_BUILD_DIR=$LPCNETDIR/build_osx ..
make VERBOSE=1 -j8

View File

@ -62,15 +62,11 @@ mkdir -p $BUILD_DIR && cd $BUILD_DIR
if [ $CLEAN -eq 1 ]; then rm -Rf *; fi
if [ $BOOTSTRAP_WX -eq 1 ]; then
# build wxWidgets
$CMAKE -DBOOTSTRAP_WXWIDGETS=1 -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a ..
make VERBOSE=1
# build freedv-gui
$CMAKE -DBOOTSTRAP_WXWIDGETS=1 -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a ..
make VERBOSE=1
$CMAKE -DBOOTSTRAP_WXWIDGETS=1 -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a ..
make VERBOSE=1 -j4
else
# build freedv-gui
$CMAKE -DCMAKE_BUILD_TYPE=Debug -DUNITTEST=$UT_ENABLE -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR -DHAMLIB_INCLUDE_DIR=${HAMLIBDIR}/include -DHAMLIB_LIBRARY=${HAMLIBDIR}/lib/libhamlib.a ..
make VERBOSE=1
make VERBOSE=1 -j4
fi

View File

@ -1,52 +1,46 @@
set(WXWIDGETS_VERSION "3.1.5")
set(WXWIDGETS_TARBALL "wxWidgets-${WXWIDGETS_VERSION}")
set(WXWIDGETS_VERSION "3.2.1")
if(MINGW AND CMAKE_CROSSCOMPILING)
# If we're cross-compiling then we need to set the target host manually.
include(cmake/MinGW.cmake)
# Ensure that the wxWidgets library is staticly built.
set(wxBUILD_SHARED OFF CACHE BOOL "Build wx libraries as shared libs")
set(wxBUILD_PRECOMP OFF CACHE BOOL "Use precompiled headers")
set(wxBUILD_MONOLITHIC OFF CACHE BOOL "Build a single library")
# Fedora MinGW defines this to the system MinGW root which will prevent
# finding libraries in the build tree. Add / so that it also looks in the
# build tree. This is specifically for bootstrapping wxWidgets.
list(APPEND CMAKE_FIND_ROOT_PATH "/")
# wxWidgets features to enable/disable.
set(wxUSE_STL OFF CACHE STRING "use C++ STL classes")
set(wxUSE_REGEX "builtin" CACHE STRING "enable support for wxRegEx class")
set(wxUSE_ZLIB "builtin" CACHE STRING "Use built-in zlib")
set(wxUSE_EXPAT "builtin" CACHE STRING "Use built-in expat")
set(wxUSE_LIBJPEG "builtin" CACHE STRING "use libjpeg (JPEG file format)")
set(wxUSE_LIBPNG "builtin" CACHE STRING "use libpng (PNG image format)")
set(wxUSE_LIBTIFF "builtin" CACHE STRING "use libtiff (TIFF file format)")
set(wxUSE_NANOSVG OFF CACHE STRING "use NanoSVG for rasterizing SVG")
set(wxUSE_LIBLZMA OFF CACHE STRING "use liblzma for LZMA compression")
set(wxUSE_LIBSDL OFF CACHE STRING "use SDL for audio on Unix")
set(wxUSE_LIBMSPACK OFF CACHE STRING "use libmspack (CHM help files loading)")
set(wxUSE_LIBICONV OFF CACHE STRING "disable use of libiconv")
# If not cross-compiling then use the built-in makefile, otherwise use standard configure.
set(CONFIGURE_COMMAND ./configure --build=${BUILD} --host=${HOST} --target=${HOST} --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
elseif(APPLE)
if(BUILD_OSX_UNIVERSAL)
set(CONFIGURE_COMMAND ./configure --disable-shared --with-osx_cocoa --enable-universal_binary=x86_64,arm64 --with-macosx-version-min=10.11 --prefix=${CMAKE_BINARY_DIR}/external/dist --with-libjpeg=builtin --with-libpng=builtin --with-regex=builtin --with-libtiff=builtin --with-expat=builtin --with-libcurl=builtin --with-zlib=builtin CXXFLAGS=-stdlib=libc++\ -std=c++11\ -DWX_PRECOMP\ -O2\ -fno-strict-aliasing\ -fno-common)
else()
set(CONFIGURE_COMMAND ./configure --disable-shared --with-macosx-version-min=10.10 --prefix=${CMAKE_BINARY_DIR}/external/dist --with-libjpeg=builtin --with-libpng=builtin --with-regex=builtin --with-libtiff=builtin --with-libcurl=builtin --with-zlib=builtin --with-expat=builtin CXXFLAGS=-stdlib=libc++\ -std=c++11\ -DWX_PRECOMP\ -O2\ -fno-strict-aliasing\ -fno-common)
endif(BUILD_OSX_UNIVERSAL)
else()
# set(CONFIGURE_COMMAND "true")
# set(MAKE_COMMAND $(MAKE) -C build/msw -f makefile.gcc SHARED=0 UNICODE=1 BUILD=release PREFIX=${CMAKE_BINARY_DIR}/external/dist)
set(CONFIGURE_COMMAND ./configure --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
endif()
# I don't see why we need this...
#if(NOT MINGW)
# set(CONFIGURE_COMMAND ./configure --host=${HOST} --target=${HOST} --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
#endif()
include(ExternalProject)
ExternalProject_Add(wxWidgets
URL https://github.com/wxWidgets/wxWidgets/releases/download/v${WXWIDGETS_VERSION}/${WXWIDGETS_TARBALL}.tar.bz2
BUILD_IN_SOURCE 1
INSTALL_DIR external/dist
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) install
include(FetchContent)
FetchContent_Declare(
wxWidgets
GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
GIT_TAG v${WXWIDGETS_VERSION}
)
ExternalProject_Get_Property(wxWidgets install_dir)
message(STATUS "wxWidgets install dir: ${install_dir}")
if(NOT WXCONFIG)
set(WXCONFIG "${install_dir}/bin/wx-config")
endif()
if(EXISTS ${WXCONFIG})
set(BS_WX_DONE TRUE)
FetchContent_GetProperties(wxWidgets)
if(NOT wxwidgets_POPULATED)
FetchContent_Populate(wxWidgets)
add_subdirectory(${wxwidgets_SOURCE_DIR} ${wxwidgets_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
# Override some CXX flags to prevent wxWidgets build failures
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
endif(APPLE)
# Get required wxWidgets include paths and build definitions.
# target_link_libraries() will actually do the linking.
get_target_property(WXBUILD_BUILD_DEFS wx::core COMPILE_DEFINITIONS)
get_target_property(WXBUILD_INCLUDES wx::core INTERFACE_INCLUDE_DIRECTORIES)
list(REMOVE_ITEM WXBUILD_BUILD_DEFS "WXBUILDING")

View File

@ -106,6 +106,22 @@ else()
target_link_libraries(freedv ${FREEDV_LINK_LIBS})
endif(APPLE)
if(BOOTSTRAP_WXWIDGETS)
if(APPLE)
target_compile_definitions(FreeDV PRIVATE ${WXBUILD_BUILD_DEFS})
target_include_directories(FreeDV PRIVATE ${WXBUILD_INCLUDES})
add_dependencies(FreeDV wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid wx::xrc)
target_link_libraries(FreeDV wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid)
else(APPLE)
target_compile_definitions(freedv PRIVATE ${WXBUILD_BUILD_DEFS})
target_include_directories(freedv PRIVATE ${WXBUILD_INCLUDES})
add_dependencies(freedv wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid wx::xrc)
target_link_libraries(freedv wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid)
endif(APPLE)
endif(BOOTSTRAP_WXWIDGETS)
# For older Xcode (< 9.0), bypass usage of @available.
if(APPLE)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0.0.900037)

View File

@ -19,3 +19,9 @@ add_library(fdv_audio STATIC
IAudioEngine.cpp
${AUDIO_ENGINE_LIBRARY_SPECIFIC_FILES}
)
if(BOOTSTRAP_WXWIDGETS)
add_dependencies(fdv_audio wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid wx::xrc)
target_compile_definitions(fdv_audio PRIVATE ${WXBUILD_BUILD_DEFS})
target_include_directories(fdv_audio PRIVATE ${WXBUILD_INCLUDES})
endif(BOOTSTRAP_WXWIDGETS)

View File

@ -857,11 +857,13 @@ void FilterDlg::adjRunTimeSpkOutFilter(void) {
void FilterDlg::plotFilterSpectrum(EQ *eqBass, EQ *eqMid, EQ *eqTreble, EQ* eqVol, PlotSpectrum* freqRespPlot, float *magdB) {
const int MAX_ARG_STORAGE_LEN = 80;
char *argBass[10];
char *argTreble[10];
char *argMid[10];
char *argVol[10];
char argstorage[10][80];
char argstorage[10][MAX_ARG_STORAGE_LEN];
float magBass[F_MAG_N];
float magTreble[F_MAG_N];
float magMid[F_MAG_N];
@ -874,29 +876,29 @@ void FilterDlg::plotFilterSpectrum(EQ *eqBass, EQ *eqMid, EQ *eqTreble, EQ* eqVo
argMid[i] = &argstorage[i][0];
argVol[i] = &argstorage[i][0];
}
sprintf(argBass[0], "bass");
sprintf(argBass[1], "%f", eqBass->gaindB+1E-6);
sprintf(argBass[2], "%f", eqBass->freqHz);
snprintf(argBass[0], MAX_ARG_STORAGE_LEN, "bass");
snprintf(argBass[1], MAX_ARG_STORAGE_LEN, "%f", eqBass->gaindB+1E-6);
snprintf(argBass[2], MAX_ARG_STORAGE_LEN, "%f", eqBass->freqHz);
calcFilterSpectrum(magBass, 2, argBass);
sprintf(argTreble[0], "treble");
sprintf(argTreble[1], "%f", eqTreble->gaindB+1E-6);
sprintf(argTreble[2], "%f", eqTreble->freqHz);
snprintf(argTreble[0], MAX_ARG_STORAGE_LEN, "treble");
snprintf(argTreble[1], MAX_ARG_STORAGE_LEN, "%f", eqTreble->gaindB+1E-6);
snprintf(argTreble[2], MAX_ARG_STORAGE_LEN, "%f", eqTreble->freqHz);
calcFilterSpectrum(magTreble, 2, argTreble);
sprintf(argMid[0], "equalizer");
sprintf(argMid[1], "%f", eqMid->freqHz);
sprintf(argMid[2], "%f", eqMid->Q);
sprintf(argMid[3], "%f", eqMid->gaindB+1E-6);
snprintf(argMid[0], MAX_ARG_STORAGE_LEN, "equalizer");
snprintf(argMid[1], MAX_ARG_STORAGE_LEN, "%f", eqMid->freqHz);
snprintf(argMid[2], MAX_ARG_STORAGE_LEN, "%f", eqMid->Q);
snprintf(argMid[3], MAX_ARG_STORAGE_LEN, "%f", eqMid->gaindB+1E-6);
calcFilterSpectrum(magMid, 3, argMid);
sprintf(argVol[0], "vol");
sprintf(argVol[1], "%f", eqVol->gaindB);
sprintf(argVol[2], "%s", "dB");
sprintf(argVol[3], "%f", 0.05);
snprintf(argVol[0], MAX_ARG_STORAGE_LEN, "vol");
snprintf(argVol[1], MAX_ARG_STORAGE_LEN, "%f", eqVol->gaindB);
snprintf(argVol[2], MAX_ARG_STORAGE_LEN, "%s", "dB");
snprintf(argVol[3], MAX_ARG_STORAGE_LEN, "%f", 0.05);
calcFilterSpectrum(magVol, 3, argVol);

View File

@ -885,7 +885,7 @@ void OptionsDlg::OnFifoReset(wxCommandEvent& event)
void OptionsDlg::OnUDPTest(wxCommandEvent& event)
{
char s[80];
sprintf(s, "hello from FreeDV!");
snprintf(s, 80, "hello from FreeDV!");
UDPSend(wxGetApp().m_udp_port, s, strlen(s)+1);
}
@ -975,22 +975,24 @@ void OptionsDlg::OnMultipleRxEnable(wxCommandEvent& event)
}
void OptionsDlg::DisplayFifoPACounters() {
char fifo_counters[256];
const int STR_LENGTH = 256;
sprintf(fifo_counters, "Fifos: infull1: %d outempty1: %d infull2: %d outempty2: %d", g_infifo1_full, g_outfifo1_empty, g_infifo2_full, g_outfifo2_empty);
char fifo_counters[STR_LENGTH];
snprintf(fifo_counters, STR_LENGTH, "Fifos: infull1: %d outempty1: %d infull2: %d outempty2: %d", g_infifo1_full, g_outfifo1_empty, g_infifo2_full, g_outfifo2_empty);
wxString fifo_counters_string(fifo_counters);
m_textFifos->SetLabel(fifo_counters_string);
char pa_counters1[256];
char pa_counters1[STR_LENGTH];
// input: underflow overflow output: underflow overflow
sprintf(pa_counters1, "Audio1: inUnderflow: %d inOverflow: %d outUnderflow %d outOverflow %d", g_AEstatus1[0], g_AEstatus1[1], g_AEstatus1[2], g_AEstatus1[3]);
snprintf(pa_counters1, STR_LENGTH, "Audio1: inUnderflow: %d inOverflow: %d outUnderflow %d outOverflow %d", g_AEstatus1[0], g_AEstatus1[1], g_AEstatus1[2], g_AEstatus1[3]);
wxString pa_counters1_string(pa_counters1); m_textPA1->SetLabel(pa_counters1_string);
char pa_counters2[256];
char pa_counters2[STR_LENGTH];
// input: underflow overflow output: underflow overflow
sprintf(pa_counters2, "Audio2: inUnderflow: %d inOverflow: %d outUnderflow %d outOverflow %d", g_AEstatus2[0], g_AEstatus2[1], g_AEstatus2[2], g_AEstatus2[3]);
snprintf(pa_counters2, STR_LENGTH, "Audio2: inUnderflow: %d inOverflow: %d outUnderflow %d outOverflow %d", g_AEstatus2[0], g_AEstatus2[1], g_AEstatus2[2], g_AEstatus2[3]);
wxString pa_counters2_string(pa_counters2);
m_textPA2->SetLabel(pa_counters2_string);
}

View File

@ -10,8 +10,10 @@
void *MainFrame::designAnEQFilter(const char filterType[], float freqHz, float gaindB, float Q, int sampleRate)
{
const int STR_LENGTH = 80;
char *arg[SBQ_MAX_ARGS];
char argstorage[SBQ_MAX_ARGS][80];
char argstorage[SBQ_MAX_ARGS][STR_LENGTH];
int i, argc;
assert((strcmp(filterType, "bass") == 0) ||
@ -26,27 +28,27 @@ void *MainFrame::designAnEQFilter(const char filterType[], float freqHz, float g
argc = 0;
if ((strcmp(filterType, "bass") == 0) || (strcmp(filterType, "treble") == 0)) {
sprintf(arg[argc++], "%s", filterType);
sprintf(arg[argc++], "%f", gaindB+1E-6);
sprintf(arg[argc++], "%f", freqHz);
sprintf(arg[argc++], "%d", sampleRate);
snprintf(arg[argc++], STR_LENGTH, "%s", filterType);
snprintf(arg[argc++], STR_LENGTH, "%f", gaindB+1E-6);
snprintf(arg[argc++], STR_LENGTH, "%f", freqHz);
snprintf(arg[argc++], STR_LENGTH, "%d", sampleRate);
}
if (strcmp(filterType, "equalizer") == 0) {
sprintf(arg[argc++], "%s", filterType);
sprintf(arg[argc++], "%f", freqHz);
sprintf(arg[argc++], "%f", Q);
sprintf(arg[argc++], "%f", gaindB+1E-6);
sprintf(arg[argc++], "%d", sampleRate);
snprintf(arg[argc++], STR_LENGTH, "%s", filterType);
snprintf(arg[argc++], STR_LENGTH, "%f", freqHz);
snprintf(arg[argc++], STR_LENGTH, "%f", Q);
snprintf(arg[argc++], STR_LENGTH, "%f", gaindB+1E-6);
snprintf(arg[argc++], STR_LENGTH, "%d", sampleRate);
}
if (strcmp(filterType, "vol") == 0)
{
sprintf(arg[argc++], "%s", filterType);
sprintf(arg[argc++], "%f", gaindB);
sprintf(arg[argc++], "%s", "dB");
sprintf(arg[argc++], "%f", 0.05); // to prevent clipping
sprintf(arg[argc++], "%d", sampleRate);
snprintf(arg[argc++], STR_LENGTH, "%s", filterType);
snprintf(arg[argc++], STR_LENGTH, "%f", gaindB);
snprintf(arg[argc++], STR_LENGTH, "%s", "dB");
snprintf(arg[argc++], STR_LENGTH, "%f", 0.05); // to prevent clipping
snprintf(arg[argc++], STR_LENGTH, "%d", sampleRate);
}
assert(argc <= SBQ_MAX_ARGS);

View File

@ -406,7 +406,7 @@ void MainFrame::loadConfiguration_()
g_txLevel = pConfig->Read(wxT("/Audio/transmitLevel"), (int)0);
char fmt[15];
m_sliderTxLevel->SetValue(g_txLevel);
sprintf(fmt, "%0.1f dB", (double)g_txLevel / 10.0);
snprintf(fmt, 15, "%0.1f dB", (double)g_txLevel / 10.0);
wxString fmtString(fmt);
m_txtTxLevelNum->SetLabel(fmtString);
@ -589,7 +589,7 @@ setDefaultMode:
// squelch settings
char sqsnr[15];
m_sliderSQ->SetValue((int)((g_SquelchLevel+5.0)*2.0));
sprintf(sqsnr, "%4.1f dB", g_SquelchLevel);
snprintf(sqsnr, 15, "%4.1f dB", g_SquelchLevel);
wxString sqsnr_string(sqsnr);
m_textSQ->SetLabel(sqsnr_string);
m_ckboxSQ->SetValue(g_SquelchActive);
@ -1197,7 +1197,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
if (snr_limited < -5.0) snr_limited = -5.0;
if (snr_limited > 20.0) snr_limited = 20.0;
char snr[15];
sprintf(snr, "%4.1f", g_snr);
snprintf(snr, 15, "%4.1f", g_snr);
//fprintf(stderr, "g_mode: %d snr_est: %f m_snrBeta: %f g_snr: %f snr_limited: %f\n", g_mode, g_stats.snr_est, m_snrBeta, g_snr, snr_limited);
@ -1444,27 +1444,30 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
// update stats on main page
char mode[80], bits[80], errors[80], ber[80], resyncs[80], clockoffset[80], freqoffset[80], syncmetric[80];
sprintf(mode, "Mode: %s", freedvInterface.getCurrentModeStr()); wxString modeString(mode); m_textCurrentDecodeMode->SetLabel(modeString);
sprintf(bits, "Bits: %d", freedvInterface.getTotalBits()); wxString bits_string(bits); m_textBits->SetLabel(bits_string);
sprintf(errors, "Errs: %d", freedvInterface.getTotalBitErrors()); wxString errors_string(errors); m_textErrors->SetLabel(errors_string);
const int STR_LENGTH = 80;
char
mode[STR_LENGTH], bits[STR_LENGTH], errors[STR_LENGTH], ber[STR_LENGTH],
resyncs[STR_LENGTH], clockoffset[STR_LENGTH], freqoffset[STR_LENGTH], syncmetric[STR_LENGTH];
snprintf(mode, STR_LENGTH, "Mode: %s", freedvInterface.getCurrentModeStr()); wxString modeString(mode); m_textCurrentDecodeMode->SetLabel(modeString);
snprintf(bits, STR_LENGTH, "Bits: %d", freedvInterface.getTotalBits()); wxString bits_string(bits); m_textBits->SetLabel(bits_string);
snprintf(errors, STR_LENGTH, "Errs: %d", freedvInterface.getTotalBitErrors()); wxString errors_string(errors); m_textErrors->SetLabel(errors_string);
float b = (float)freedvInterface.getTotalBitErrors()/(1E-6+freedvInterface.getTotalBits());
sprintf(ber, "BER: %4.3f", b); wxString ber_string(ber); m_textBER->SetLabel(ber_string);
sprintf(resyncs, "Resyncs: %d", g_resyncs); wxString resyncs_string(resyncs); m_textResyncs->SetLabel(resyncs_string);
snprintf(ber, STR_LENGTH, "BER: %4.3f", b); wxString ber_string(ber); m_textBER->SetLabel(ber_string);
snprintf(resyncs, STR_LENGTH, "Resyncs: %d", g_resyncs); wxString resyncs_string(resyncs); m_textResyncs->SetLabel(resyncs_string);
sprintf(freqoffset, "FrqOff: %3.1f", freedvInterface.getCurrentRxModemStats()->foff);
snprintf(freqoffset, STR_LENGTH, "FrqOff: %3.1f", freedvInterface.getCurrentRxModemStats()->foff);
wxString freqoffset_string(freqoffset); m_textFreqOffset->SetLabel(freqoffset_string);
sprintf(syncmetric, "Sync: %3.2f", freedvInterface.getCurrentRxModemStats()->sync_metric);
snprintf(syncmetric, STR_LENGTH, "Sync: %3.2f", freedvInterface.getCurrentRxModemStats()->sync_metric);
wxString syncmetric_string(syncmetric); m_textSyncMetric->SetLabel(syncmetric_string);
// Codec 2 700C/D/E & 800XA VQ "auto EQ" equaliser variance
auto var = freedvInterface.getVariance();
char var_str[80]; sprintf(var_str, "Var: %4.1f", var);
char var_str[STR_LENGTH]; snprintf(var_str, STR_LENGTH, "Var: %4.1f", var);
wxString var_string(var_str); m_textCodec2Var->SetLabel(var_string);
if (g_State) {
sprintf(clockoffset, "ClkOff: %+-d", (int)round(freedvInterface.getCurrentRxModemStats()->clock_offset*1E6) % 10000);
snprintf(clockoffset, STR_LENGTH, "ClkOff: %+-d", (int)round(freedvInterface.getCurrentRxModemStats()->clock_offset*1E6) % 10000);
wxString clockoffset_string(clockoffset); m_textClockOffset->SetLabel(clockoffset_string);
// update error pattern plots if supported
@ -2672,9 +2675,9 @@ bool MainFrame::validateSoundCardSetup()
int MainFrame::PollUDP(void)
{
// this will block until message received, so we put it in it's own thread
const int STR_LENGTH = 80;
char buf[1024];
char reply[80];
char reply[STR_LENGTH];
size_t n = m_udp_sock->RecvFrom(m_udp_addr, buf, sizeof(buf)).LastCount();
if (n) {
@ -2687,14 +2690,14 @@ int MainFrame::PollUDP(void)
// for security only accept commands from local host
sprintf(reply,"nope\n");
snprintf(reply, STR_LENGTH, "nope\n");
if (ipaddr.Cmp(_("127.0.0.1")) == 0) {
// process commands
if (bufstr.Cmp(_("restore")) == 0) {
m_schedule_restore = true; // Make Restore happen in main thread to avoid crashing
sprintf(reply,"ok\n");
snprintf(reply, STR_LENGTH, "ok\n");
}
wxString itemToSet, val;
@ -2703,19 +2706,19 @@ int MainFrame::PollUDP(void)
// note: if options dialog is open this will get overwritten
wxGetApp().m_callSign = val;
}
sprintf(reply,"ok\n");
snprintf(reply, STR_LENGTH, "ok\n");
}
if (bufstr.StartsWith(_("ptton"), &itemToSet)) {
// note: if options dialog is open this will get overwritten
m_btnTogPTT->SetValue(true);
togglePTT();
sprintf(reply,"ok\n");
snprintf(reply, STR_LENGTH, "ok\n");
}
if (bufstr.StartsWith(_("pttoff"), &itemToSet)) {
// note: if options dialog is open this will get overwritten
m_btnTogPTT->SetValue(false);
togglePTT();
sprintf(reply,"ok\n");
snprintf(reply, STR_LENGTH, "ok\n");
}
}

View File

@ -283,7 +283,7 @@ void MainFrame::OnCmdSliderScroll(wxScrollEvent& event)
{
char sqsnr[15];
g_SquelchLevel = (float)m_sliderSQ->GetValue()/2.0 - 5.0;
sprintf(sqsnr, "%4.1f dB", g_SquelchLevel); // 0.5 dB steps
snprintf(sqsnr, 15, "%4.1f dB", g_SquelchLevel); // 0.5 dB steps
wxString sqsnr_string(sqsnr);
m_textSQ->SetLabel(sqsnr_string);
@ -297,7 +297,7 @@ void MainFrame::OnChangeTxLevel( wxScrollEvent& event )
{
char fmt[15];
g_txLevel = m_sliderTxLevel->GetValue();
sprintf(fmt, "%0.1f dB", (double)(g_txLevel)/10.0);
snprintf(fmt, 15, "%0.1f dB", (double)(g_txLevel)/10.0);
wxString fmtString(fmt);
m_txtTxLevelNum->SetLabel(fmtString);

View File

@ -39,6 +39,12 @@ add_library(fdv_audio_pipeline STATIC
target_include_directories(fdv_audio_pipeline PRIVATE ${CODEC2_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/..)
if(BOOTSTRAP_WXWIDGETS)
add_dependencies(fdv_audio_pipeline wx::core wx::base wx::aui wx::html wx::net wx::adv wx::propgrid wx::xrc)
target_compile_definitions(fdv_audio_pipeline PRIVATE ${WXBUILD_BUILD_DEFS})
target_include_directories(fdv_audio_pipeline PRIVATE ${WXBUILD_INCLUDES})
endif(BOOTSTRAP_WXWIDGETS)
if(UNITTEST)
macro(DefineUnitTest utName)
add_executable(${utName} test/${utName}.cpp)

View File

@ -165,8 +165,10 @@ double PlotPanel::GetZoomFactor(double zf)
//-------------------------------------------------------------------------
void PlotPanel::drawGraticule(wxGraphicsContext* ctx)
{
const int STR_LENGTH = 15;
int p;
char buf[15];
char buf[STR_LENGTH];
wxString s;
wxGraphicsFont tmpFont = ctx->CreateFont(GetFont(), GetForegroundColour());
@ -188,14 +190,14 @@ void PlotPanel::drawGraticule(wxGraphicsContext* ctx)
ctx->SetPen(wxPen(GREY_COLOR, 1));
for(p = GRID_INCREMENT; p < (m_rGrid.GetWidth() - YBOTTOM_OFFSET); p += GRID_INCREMENT)
{
sprintf(buf, "%1.1f Hz",(double)(p / 10));
snprintf(buf, STR_LENGTH, "%1.1f Hz",(double)(p / 10));
ctx->DrawText(buf, p - PLOT_BORDER + XLEFT_OFFSET, m_rGrid.GetHeight() + YBOTTOM_OFFSET/2);
}
// Label the Y-Axis
//for(p = GRID_INCREMENT; p < (h - YBOTTOM_OFFSET); p += GRID_INCREMENT)
for(p = (m_rGrid.GetHeight() - GRID_INCREMENT); p > PLOT_BORDER; p -= GRID_INCREMENT)
{
sprintf(buf, "%1.0f", (double)((m_rGrid.GetHeight() - p) * -10));
snprintf(buf, STR_LENGTH, "%1.0f", (double)((m_rGrid.GetHeight() - p) * -10));
ctx->DrawText(buf, XLEFT_TEXT_OFFSET, p);
}
}

View File

@ -254,9 +254,11 @@ void PlotScalar::draw(wxGraphicsContext* ctx)
//-------------------------------------------------------------------------
void PlotScalar::drawGraticule(wxGraphicsContext* ctx)
{
const int STR_LENGTH = 15;
float t, a;
int x, y, text_w, text_h;
char buf[15];
char buf[STR_LENGTH];
wxString s;
float sec_to_px;
float a_to_py;
@ -293,7 +295,7 @@ void PlotScalar::drawGraticule(wxGraphicsContext* ctx)
ctx->StrokeLine(x, plotHeight + PLOT_BORDER, x, PLOT_BORDER);
}
if (!m_mini) {
sprintf(buf, "%2.1fs", t);
snprintf(buf, STR_LENGTH, "%2.1fs", t);
GetTextExtent(buf, &text_w, &text_h);
ctx->DrawText(buf, x - text_w/2, plotHeight + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
}
@ -319,7 +321,7 @@ void PlotScalar::drawGraticule(wxGraphicsContext* ctx)
(plotWidth + PLOT_BORDER + XLEFT_OFFSET), y);
}
if (!m_mini) {
sprintf(buf, m_a_fmt, a);
snprintf(buf, STR_LENGTH, m_a_fmt, a);
GetTextExtent(buf, &text_w, &text_h);
ctx->DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
}

View File

@ -150,8 +150,10 @@ void PlotSpectrum::draw(wxGraphicsContext* ctx)
//-------------------------------------------------------------------------
void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
{
const int STR_LENGTH = 15;
int x, y, text_w, text_h;
char buf[15];
char buf[STR_LENGTH];
wxString s;
float f, mag, freq_hz_to_px, mag_dB_to_py;
@ -175,7 +177,7 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
int textXStep = STEP_F_HZ*freq_hz_to_px;
int textYStep = STEP_MAG_DB*mag_dB_to_py;
sprintf(buf, "%4.0fHz", (float)MAX_F_HZ - STEP_F_HZ);
snprintf(buf, STR_LENGTH, "%4.0fHz", (float)MAX_F_HZ - STEP_F_HZ);
GetTextExtent(buf, &text_w, &text_h);
int overlappedText = (text_w > textXStep) || (text_h > textYStep);
//printf("text_w: %d textXStep: %d text_h: %d textYStep: %d overlappedText: %d\n", text_w, textXStep,
@ -192,7 +194,7 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
ctx->SetPen(wxPen(BLACK_COLOR, 1));
ctx->StrokeLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
sprintf(buf, "%4.0fHz", f);
snprintf(buf, STR_LENGTH, "%4.0fHz", f);
GetTextExtent(buf, &text_w, &text_h);
if (!overlappedText)
ctx->DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
@ -214,7 +216,7 @@ void PlotSpectrum::drawGraticule(wxGraphicsContext* ctx)
y += PLOT_BORDER;
ctx->StrokeLine(PLOT_BORDER + XLEFT_OFFSET, y,
(m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
sprintf(buf, "%3.0fdB", mag);
snprintf(buf, STR_LENGTH, "%3.0fdB", mag);
GetTextExtent(buf, &text_w, &text_h);
if (!overlappedText)
ctx->DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);

View File

@ -231,8 +231,10 @@ void PlotWaterfall::draw(wxGraphicsContext* gc)
//-------------------------------------------------------------------------
void PlotWaterfall::drawGraticule(wxGraphicsContext* ctx)
{
const int STR_LENGTH = 15;
int x, y, text_w, text_h;
char buf[15];
char buf[STR_LENGTH];
wxString s;
float f, time, freq_hz_to_px, time_s_to_py;
@ -256,7 +258,7 @@ void PlotWaterfall::drawGraticule(wxGraphicsContext* ctx)
int textXStep = STEP_F_HZ*freq_hz_to_px;
int textYStep = WATERFALL_SECS_STEP*time_s_to_py;
sprintf(buf, "%4.0fHz", (float)MAX_F_HZ - STEP_F_HZ);
snprintf(buf, STR_LENGTH, "%4.0fHz", (float)MAX_F_HZ - STEP_F_HZ);
GetTextExtent(buf, &text_w, &text_h);
int overlappedText = (text_w > textXStep) || (text_h > textYStep);
@ -272,7 +274,7 @@ void PlotWaterfall::drawGraticule(wxGraphicsContext* ctx)
else
ctx->StrokeLine(x, PLOT_BORDER, x, PLOT_BORDER + YBOTTOM_TEXT_OFFSET + 5);
sprintf(buf, "%4.0fHz", f);
snprintf(buf, STR_LENGTH, "%4.0fHz", f);
GetTextExtent(buf, &text_w, &text_h);
if (!overlappedText)
ctx->DrawText(buf, x - text_w/2, (YBOTTOM_TEXT_OFFSET/2));
@ -294,7 +296,7 @@ void PlotWaterfall::drawGraticule(wxGraphicsContext* ctx)
if (m_graticule)
ctx->StrokeLine(PLOT_BORDER + XLEFT_OFFSET, y,
(m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
sprintf(buf, "%3.0fs", time);
snprintf(buf, STR_LENGTH, "%3.0fs", time);
GetTextExtent(buf, &text_w, &text_h);
if (!overlappedText)
ctx->DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);

View File

@ -62,42 +62,10 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD
*/
TCHAR nameWithStrangePrefix[100];
StringCchPrintf(nameWithStrangePrefix, 100, "\\\\.\\%s", name);
fputs("nameWithStrangePrefix: ", stderr);
fputs(nameWithStrangePrefix, stderr);
if (g_verbose) fprintf(stderr,"\n");
StringCchPrintf(nameWithStrangePrefix, 100, TEXT("\\\\.\\%hs"), name);
if (g_verbose) _tprintf(_T("nameWithStrangePrefix: %s\r\n"), nameWithStrangePrefix);
#ifdef NOT_USED
COMMCONFIG CC;
DWORD CCsize=sizeof(CC);
memset(&CC, 0, CCsize);
CC.dwSize = CCsize;
/* Commented out by David May 13 2018, as it was failing after
"name" changed to "nameWithStrangePrefix" that is reqd for
support of COM ports above 9. I am not sure if this is
needed as I can't see anything similar in Hamlib */
if(GetDefaultCommConfigA(nameWithStrangePrefix, &CC, &CCsize)) {
if (g_verbose) fprintf(stderr, "GetDefaultCommConfigA OK\n");
CC.dcb.fOutxCtsFlow = FALSE;
CC.dcb.fOutxDsrFlow = FALSE;
CC.dcb.fDtrControl = DTR_CONTROL_DISABLE;
CC.dcb.fDsrSensitivity = FALSE;
CC.dcb.fRtsControl = RTS_CONTROL_DISABLE;
if (!SetDefaultCommConfigA(nameWithStrangePrefix, &CC, CCsize)) {
StringCchPrintf(lpszFunction, 100, "%s", "SetDefaultCommConfigA");
goto error;
}
if (g_verbose) fprintf(stderr, "SetDefaultCommConfigA OK\n");
} else {
StringCchPrintf(lpszFunction, 100, "%s", "GetDefaultCommConfigA");
goto error;
}
#endif
if((com_handle=CreateFileA(nameWithStrangePrefix
if((com_handle=CreateFile(nameWithStrangePrefix
,GENERIC_READ | GENERIC_WRITE/* Access */
,0 /* Share mode */
,NULL /* Security attributes */
@ -105,25 +73,26 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD
,0 /* File attributes */
,NULL /* Template */
))==INVALID_HANDLE_VALUE) {
StringCchPrintf(lpszFunction, 100, "%s", "CreateFileA");
StringCchPrintf(lpszFunction, 100, TEXT("%s"), TEXT("CreateFile"));
goto error;
}
if (g_verbose) fprintf(stderr, "CreateFileA OK\n");
if(GetCommTimeouts(com_handle, &timeouts)) {
if (g_verbose) fprintf(stderr, "GetCommTimeouts OK\n");
timeouts.ReadIntervalTimeout=MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier=0;
timeouts.ReadTotalTimeoutConstant=0; // No-wait read timeout
timeouts.WriteTotalTimeoutMultiplier=0;
timeouts.WriteTotalTimeoutConstant=5000; // 5 seconds
if (!SetCommTimeouts(com_handle,&timeouts)) {
StringCchPrintf(lpszFunction, 100, "%s", "SetCommTimeouts");
StringCchPrintf(lpszFunction, 100, TEXT("%s"), TEXT("SetCommTimeouts"));
goto error;
}
if (g_verbose) fprintf(stderr, "SetCommTimeouts OK\n");
} else {
StringCchPrintf(lpszFunction, 100, "%s", "GetCommTimeouts");
StringCchPrintf(lpszFunction, 100, TEXT("%s"), TEXT("GetCommTimeouts"));
goto error;
}
@ -146,18 +115,18 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fAbortOnError = FALSE;
if (!SetCommState(com_handle, &dcb)) {
StringCchPrintf(lpszFunction, 100, "%s", "SetCommState");
StringCchPrintf(lpszFunction, 100, TEXT("%s"), TEXT("SetCommState"));
goto error;
}
if (g_verbose) fprintf(stderr, "SetCommState OK\n");
} else {
StringCchPrintf(lpszFunction, 100, "%s", "GetCommState");
StringCchPrintf(lpszFunction, 100, TEXT("%s"), TEXT("GetCommState"));
goto error;
}
return true;
error:
error:
if (g_verbose) fprintf(stderr, "%s failed\n", lpszFunction);
// Retrieve the system error message for the last-error code

View File

@ -256,7 +256,7 @@ void MainFrame::DetectSyncProcessEvent(void) {
}
if (ds_rx_time >= DS_SYNC_WAIT_TIME) {
char s[100]; sprintf(s, "rx sync");
char s[100]; snprintf(s, 100, "rx sync");
if (wxGetApp().m_udp_enable) {
UDPSend(wxGetApp().m_udp_port, s, strlen(s)+1);
}