Merge pull request #736 from jpcima/sndfile-default-off
Make sndfile off by default
This commit is contained in:
commit
f6505613db
11 changed files with 59 additions and 34 deletions
|
|
@ -3,8 +3,8 @@ configuration: Release
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- job_name: macOS Mojave
|
- job_name: macOS
|
||||||
appveyor_build_worker_image: macos-mojave
|
appveyor_build_worker_image: macos
|
||||||
INSTALL_DIR: sfizz-$(APPVEYOR_REPO_TAG_NAME)-macos
|
INSTALL_DIR: sfizz-$(APPVEYOR_REPO_TAG_NAME)-macos
|
||||||
|
|
||||||
- job_name: Windows x86
|
- job_name: Windows x86
|
||||||
|
|
@ -31,11 +31,12 @@ environment:
|
||||||
for:
|
for:
|
||||||
- matrix:
|
- matrix:
|
||||||
only:
|
only:
|
||||||
- job_name: macOS Mojave
|
- job_name: macOS
|
||||||
init:
|
init:
|
||||||
- system_profiler SPSoftwareDataType
|
- system_profiler SPSoftwareDataType
|
||||||
- cmake --version
|
- cmake --version
|
||||||
- gcc -v
|
- gcc -v
|
||||||
|
- xcodebuild -version
|
||||||
install:
|
install:
|
||||||
- chmod +x ${APPVEYOR_BUILD_FOLDER}/scripts/appveyor/install.sh
|
- chmod +x ${APPVEYOR_BUILD_FOLDER}/scripts/appveyor/install.sh
|
||||||
- ${APPVEYOR_BUILD_FOLDER}/scripts/appveyor/install.sh
|
- ${APPVEYOR_BUILD_FOLDER}/scripts/appveyor/install.sh
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ option_ex (SFIZZ_TESTS "Enable tests build" OFF)
|
||||||
option_ex (SFIZZ_DEMOS "Enable feature demos build" OFF)
|
option_ex (SFIZZ_DEMOS "Enable feature demos build" OFF)
|
||||||
option_ex (SFIZZ_DEVTOOLS "Enable developer tools build" OFF)
|
option_ex (SFIZZ_DEVTOOLS "Enable developer tools build" OFF)
|
||||||
option_ex (SFIZZ_SHARED "Enable shared library build" ON)
|
option_ex (SFIZZ_SHARED "Enable shared library build" ON)
|
||||||
option_ex (SFIZZ_USE_SNDFILE "Enable use of the sndfile library" ON)
|
option_ex (SFIZZ_USE_SNDFILE "Enable use of the sndfile library" OFF)
|
||||||
option_ex (SFIZZ_USE_VCPKG "Assume that sfizz is build using vcpkg" OFF)
|
option_ex (SFIZZ_USE_VCPKG "Assume that sfizz is build using vcpkg" OFF)
|
||||||
option_ex (SFIZZ_USE_SYSTEM_ABSEIL "Use Abseil libraries preinstalled on system" OFF)
|
option_ex (SFIZZ_USE_SYSTEM_ABSEIL "Use Abseil libraries preinstalled on system" OFF)
|
||||||
option_ex (SFIZZ_USE_SYSTEM_SIMDE "Use SIMDe libraries preinstalled on system" OFF)
|
option_ex (SFIZZ_USE_SYSTEM_SIMDE "Use SIMDe libraries preinstalled on system" OFF)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ endif()
|
||||||
|
|
||||||
if(SFIZZ_RENDER)
|
if(SFIZZ_RENDER)
|
||||||
add_executable(sfizz_render MidiHelpers.h sfizz_render.cpp)
|
add_executable(sfizz_render MidiHelpers.h sfizz_render.cpp)
|
||||||
target_link_libraries(sfizz_render PRIVATE sfizz::internal sfizz::fmidi sfizz::sndfile sfizz::cxxopts)
|
target_link_libraries(sfizz_render PRIVATE sfizz::internal sfizz::fmidi sfizz::cxxopts st_audiofile_formats)
|
||||||
sfizz_enable_lto_if_needed(sfizz_render)
|
sfizz_enable_lto_if_needed(sfizz_render)
|
||||||
install(TARGETS sfizz_render DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT "render" OPTIONAL)
|
install(TARGETS sfizz_render DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT "render" OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
#include <sndfile.hh>
|
|
||||||
#include "sfizz/Synth.h"
|
#include "sfizz/Synth.h"
|
||||||
#include "sfizz/MathHelpers.h"
|
#include "sfizz/MathHelpers.h"
|
||||||
#include "sfizz/SfzHelpers.h"
|
#include "sfizz/SfzHelpers.h"
|
||||||
#include "sfizz/SIMDHelpers.h"
|
#include "sfizz/SIMDHelpers.h"
|
||||||
#include "MidiHelpers.h"
|
#include "MidiHelpers.h"
|
||||||
#include "cxxopts.hpp"
|
#include <st_audiofile_libs.h>
|
||||||
|
#include <cxxopts.hpp>
|
||||||
#include <fmidi/fmidi.h>
|
#include <fmidi/fmidi.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
@ -158,14 +158,27 @@ int main(int argc, char** argv)
|
||||||
LOG_INFO("-- Cutting the rendering at the last MIDI End of Track message");
|
LOG_INFO("-- Cutting the rendering at the last MIDI End of Track message");
|
||||||
}
|
}
|
||||||
|
|
||||||
SndfileHandle outputFile (outputPath.u8string(), SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, sampleRate);
|
drwav outputFile;
|
||||||
ERROR_IF(outputFile.error() != 0, "Error writing out the wav file: " << outputFile.strError());
|
drwav_data_format outputFormat {};
|
||||||
|
outputFormat.container = drwav_container_riff;
|
||||||
|
outputFormat.format = DR_WAVE_FORMAT_PCM;
|
||||||
|
outputFormat.channels = 2;
|
||||||
|
outputFormat.sampleRate = sampleRate;
|
||||||
|
outputFormat.bitsPerSample = 16;
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
drwav_bool32 outputFileOk = drwav_init_file_write(&outputFile, outputPath.c_str(), &outputFormat, nullptr);
|
||||||
|
#else
|
||||||
|
drwav_bool32 outputFileOk = drwav_init_file_write_w(&outputFile, outputPath.c_str(), &outputFormat, nullptr);
|
||||||
|
#endif
|
||||||
|
ERROR_IF(!outputFileOk, "Error opening the wav file for writing");
|
||||||
|
|
||||||
auto sampleRateDouble = static_cast<double>(sampleRate);
|
auto sampleRateDouble = static_cast<double>(sampleRate);
|
||||||
const double increment { 1.0 / sampleRateDouble };
|
const double increment { 1.0 / sampleRateDouble };
|
||||||
int numFramesWritten { 0 };
|
uint64_t numFramesWritten { 0 };
|
||||||
sfz::AudioBuffer<float> audioBuffer { 2, blockSize };
|
sfz::AudioBuffer<float> audioBuffer { 2, blockSize };
|
||||||
sfz::Buffer<float> interleavedBuffer { 2 * blockSize };
|
sfz::Buffer<float> interleavedBuffer { 2 * blockSize };
|
||||||
|
sfz::Buffer<int16_t> interleavedPcm { 2 * blockSize };
|
||||||
|
|
||||||
fmidi_player_u midiPlayer { fmidi_player_new(midiFile.get()) };
|
fmidi_player_u midiPlayer { fmidi_player_new(midiFile.get()) };
|
||||||
CallbackData callbackData { synth, 0, false };
|
CallbackData callbackData { synth, 0, false };
|
||||||
|
|
@ -178,7 +191,8 @@ int main(int argc, char** argv)
|
||||||
fmidi_player_tick(midiPlayer.get(), increment);
|
fmidi_player_tick(midiPlayer.get(), increment);
|
||||||
synth.renderBlock(audioBuffer);
|
synth.renderBlock(audioBuffer);
|
||||||
sfz::writeInterleaved(audioBuffer.getConstSpan(0), audioBuffer.getConstSpan(1), absl::MakeSpan(interleavedBuffer));
|
sfz::writeInterleaved(audioBuffer.getConstSpan(0), audioBuffer.getConstSpan(1), absl::MakeSpan(interleavedBuffer));
|
||||||
numFramesWritten += outputFile.writef(interleavedBuffer.data(), blockSize);
|
drwav_f32_to_s16(interleavedPcm.data(), interleavedBuffer.data(), 2 * blockSize);
|
||||||
|
numFramesWritten += drwav_write_pcm_frames(&outputFile, blockSize, interleavedPcm.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useEOT) {
|
if (!useEOT) {
|
||||||
|
|
@ -186,12 +200,13 @@ int main(int argc, char** argv)
|
||||||
while (averagePower > 1e-12f) {
|
while (averagePower > 1e-12f) {
|
||||||
synth.renderBlock(audioBuffer);
|
synth.renderBlock(audioBuffer);
|
||||||
sfz::writeInterleaved(audioBuffer.getConstSpan(0), audioBuffer.getConstSpan(1), absl::MakeSpan(interleavedBuffer));
|
sfz::writeInterleaved(audioBuffer.getConstSpan(0), audioBuffer.getConstSpan(1), absl::MakeSpan(interleavedBuffer));
|
||||||
numFramesWritten += outputFile.writef(interleavedBuffer.data(), blockSize);
|
drwav_f32_to_s16(interleavedPcm.data(), interleavedBuffer.data(), 2 * blockSize);
|
||||||
|
numFramesWritten += drwav_write_pcm_frames(&outputFile, blockSize, interleavedPcm.data());
|
||||||
averagePower = sfz::meanSquared<float>(interleavedBuffer);
|
averagePower = sfz::meanSquared<float>(interleavedBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outputFile.writeSync();
|
drwav_uninit(&outputFile);
|
||||||
LOG_INFO("Wrote " << numFramesWritten << " frames of sound data in" << outputPath.string());
|
LOG_INFO("Wrote " << numFramesWritten << " frames of sound data in" << outputPath.string());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ add_library(sfizz::cxxopts ALIAS sfizz_cxxopts)
|
||||||
target_include_directories(sfizz_cxxopts INTERFACE "external/cxxopts")
|
target_include_directories(sfizz_cxxopts INTERFACE "external/cxxopts")
|
||||||
|
|
||||||
# The sndfile library
|
# The sndfile library
|
||||||
if(SFIZZ_USE_SNDFILE OR SFIZZ_DEMOS OR SFIZZ_DEVTOOLS OR SFIZZ_BENCHMARKS OR SFIZZ_RENDER)
|
if(SFIZZ_USE_SNDFILE OR SFIZZ_DEMOS OR SFIZZ_DEVTOOLS OR SFIZZ_BENCHMARKS)
|
||||||
add_library(sfizz_sndfile INTERFACE)
|
add_library(sfizz_sndfile INTERFACE)
|
||||||
add_library(sfizz::sndfile ALIAS sfizz_sndfile)
|
add_library(sfizz::sndfile ALIAS sfizz_sndfile)
|
||||||
if(SFIZZ_USE_VCPKG OR CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(SFIZZ_USE_VCPKG OR CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ endif
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
SFIZZ_USE_SNDFILE ?= 1
|
SFIZZ_USE_SNDFILE ?= 0
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
@ -154,6 +154,11 @@ SFIZZ_SOURCES += \
|
||||||
external/st_audiofile/src/st_audiofile_libs.c \
|
external/st_audiofile/src/st_audiofile_libs.c \
|
||||||
external/st_audiofile/src/st_audiofile_sndfile.c
|
external/st_audiofile/src/st_audiofile_sndfile.c
|
||||||
|
|
||||||
|
ifneq ($(SFIZZ_USE_SNDFILE),1)
|
||||||
|
SFIZZ_SOURCES += \
|
||||||
|
external/st_audiofile/src/st_audiofile_libs.c
|
||||||
|
endif
|
||||||
|
|
||||||
SFIZZ_C_FLAGS += \
|
SFIZZ_C_FLAGS += \
|
||||||
-I$(SFIZZ_DIR)/external/st_audiofile/src \
|
-I$(SFIZZ_DIR)/external/st_audiofile/src \
|
||||||
-I$(SFIZZ_DIR)/external/st_audiofile/thirdparty/dr_libs
|
-I$(SFIZZ_DIR)/external/st_audiofile/thirdparty/dr_libs
|
||||||
|
|
|
||||||
32
external/st_audiofile/CMakeLists.txt
vendored
32
external/st_audiofile/CMakeLists.txt
vendored
|
|
@ -4,24 +4,27 @@ project(st_audiofile)
|
||||||
option(ST_AUDIO_FILE_USE_SNDFILE "Use sndfile" OFF)
|
option(ST_AUDIO_FILE_USE_SNDFILE "Use sndfile" OFF)
|
||||||
set(ST_AUDIO_FILE_EXTERNAL_SNDFILE "" CACHE STRING "Name of external sndfile target")
|
set(ST_AUDIO_FILE_EXTERNAL_SNDFILE "" CACHE STRING "Name of external sndfile target")
|
||||||
|
|
||||||
add_library(st_audiofile STATIC
|
add_library(st_audiofile STATIC EXCLUDE_FROM_ALL
|
||||||
"src/st_audiofile.c"
|
"src/st_audiofile.c"
|
||||||
"src/st_audiofile_common.c"
|
"src/st_audiofile_common.c"
|
||||||
"src/st_audiofile_libs.c"
|
|
||||||
"src/st_audiofile_sndfile.c")
|
"src/st_audiofile_sndfile.c")
|
||||||
target_include_directories(st_audiofile
|
target_include_directories(st_audiofile
|
||||||
|
PUBLIC "src")
|
||||||
|
|
||||||
|
###
|
||||||
|
add_library(st_audiofile_formats STATIC EXCLUDE_FROM_ALL
|
||||||
|
"src/st_audiofile_libs.c")
|
||||||
|
target_include_directories(st_audiofile_formats
|
||||||
PUBLIC "src"
|
PUBLIC "src"
|
||||||
PUBLIC "thirdparty/dr_libs"
|
PUBLIC "thirdparty/dr_libs"
|
||||||
PUBLIC "thirdparty/stb_vorbis")
|
PUBLIC "thirdparty/stb_vorbis")
|
||||||
|
|
||||||
add_executable(st_info
|
add_subdirectory("thirdparty/libaiff" EXCLUDE_FROM_ALL)
|
||||||
"src/st_info.c")
|
target_link_libraries(st_audiofile_formats PUBLIC aiff::aiff)
|
||||||
target_link_libraries(st_info
|
|
||||||
PRIVATE st_audiofile)
|
|
||||||
|
|
||||||
|
###
|
||||||
if(NOT ST_AUDIO_FILE_USE_SNDFILE)
|
if(NOT ST_AUDIO_FILE_USE_SNDFILE)
|
||||||
add_subdirectory("thirdparty/libaiff" EXCLUDE_FROM_ALL)
|
target_link_libraries(st_audiofile PRIVATE st_audiofile_formats)
|
||||||
target_link_libraries(st_audiofile PRIVATE aiff::aiff)
|
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(st_audiofile
|
target_compile_definitions(st_audiofile
|
||||||
PUBLIC "ST_AUDIO_FILE_USE_SNDFILE=1")
|
PUBLIC "ST_AUDIO_FILE_USE_SNDFILE=1")
|
||||||
|
|
@ -31,11 +34,12 @@ else()
|
||||||
else()
|
else()
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(Sndfile "sndfile" REQUIRED)
|
pkg_check_modules(Sndfile "sndfile" REQUIRED)
|
||||||
target_include_directories(st_audiofile
|
target_include_directories(st_audiofile PUBLIC ${Sndfile_INCLUDE_DIRS})
|
||||||
PUBLIC ${Sndfile_INCLUDE_DIRS})
|
target_link_libraries(st_audiofile PUBLIC ${Sndfile_LIBRARIES})
|
||||||
target_link_libraries(st_audiofile
|
link_directories(${Sndfile_LIBRARY_DIRS})
|
||||||
PUBLIC ${Sndfile_LIBRARIES})
|
|
||||||
link_directories(
|
|
||||||
${Sndfile_LIBRARY_DIRS})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
###
|
||||||
|
add_executable(st_info "src/st_info.c")
|
||||||
|
target_link_libraries(st_info PRIVATE st_audiofile)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
// license. You should have receive a LICENSE.md file along with the code.
|
// license. You should have receive a LICENSE.md file along with the code.
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#if !defined(ST_AUDIO_FILE_USE_SNDFILE)
|
|
||||||
#define DR_WAV_IMPLEMENTATION
|
#define DR_WAV_IMPLEMENTATION
|
||||||
#define DR_FLAC_IMPLEMENTATION
|
#define DR_FLAC_IMPLEMENTATION
|
||||||
#define DR_MP3_IMPLEMENTATION
|
#define DR_MP3_IMPLEMENTATION
|
||||||
|
|
@ -28,5 +27,3 @@ stb_vorbis* stb_vorbis_open_filename_w(const wchar_t* filename, int* error, cons
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !defined(ST_AUDIO_FILE_USE_SNDFILE)
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ set -ex
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
mkdir -p build/${INSTALL_DIR} && cd build
|
mkdir -p build/${INSTALL_DIR} && cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
|
||||||
-DSFIZZ_VST=ON \
|
-DSFIZZ_VST=ON \
|
||||||
-DSFIZZ_AU=ON \
|
-DSFIZZ_AU=ON \
|
||||||
-DSFIZZ_RENDER=OFF \
|
-DSFIZZ_RENDER=OFF \
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
choco install -y innosetup
|
choco install -y innosetup
|
||||||
|
|
||||||
REM Uncomment the next 4 lines to force vcpkg update
|
REM Uncomment the next 4 lines to force vcpkg update
|
||||||
REM cd c:\tools\vcpkg\
|
REM cd c:\tools\vcpkg\
|
||||||
REM git pull
|
REM git pull
|
||||||
REM .\bootstrap-vcpkg.bat
|
REM .\bootstrap-vcpkg.bat
|
||||||
REM cd %APPVEYOR_BUILD_FOLDER%
|
REM cd %APPVEYOR_BUILD_FOLDER%
|
||||||
vcpkg install libsndfile:%VCPKG_TRIPLET%
|
|
||||||
|
REM vcpkg install libsndfile:%VCPKG_TRIPLET%
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
brew install libsndfile dylibbundler
|
brew install dylibbundler
|
||||||
|
|
||||||
cd ~; npm install appdmg; cd -
|
cd ~; npm install appdmg; cd -
|
||||||
~/node_modules/appdmg/bin/appdmg.js --version
|
~/node_modules/appdmg/bin/appdmg.js --version
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue