Fix the sndfile conditional not well handled in demo programs
The conditional ST_AUDIO_FILE_USE_SNDFILE appears in private headers, which are used by some demo programs. Linking to sfizz does not inherit this flag, and FileInstrument gets wrong values for loop constants.
This commit is contained in:
parent
af7ee06a81
commit
cda079eef8
4 changed files with 16 additions and 7 deletions
|
|
@ -134,6 +134,9 @@ ifeq ($(SFIZZ_USE_SNDFILE),1)
|
|||
SFIZZ_SNDFILE_C_FLAGS ?= $(shell $(SFIZZ_PKG_CONFIG) --cflags sndfile)
|
||||
SFIZZ_SNDFILE_CXX_FLAGS ?= $(SFIZZ_SNDFILE_C_FLAGS)
|
||||
SFIZZ_SNDFILE_LINK_FLAGS ?= $(shell $(SFIZZ_PKG_CONFIG) --libs sndfile)
|
||||
|
||||
SFIZZ_C_FLAGS += -DSFIZZ_USE_SNDFILE=1
|
||||
SFIZZ_CXX_FLAGS += -DSFIZZ_USE_SNDFILE=1
|
||||
endif
|
||||
|
||||
# st_audiofile dependency
|
||||
|
|
|
|||
|
|
@ -222,6 +222,9 @@ target_include_directories (sfizz_static PUBLIC external)
|
|||
target_link_libraries (sfizz_static PUBLIC absl::strings absl::span)
|
||||
target_link_libraries (sfizz_static PRIVATE sfizz_parser absl::flat_hash_map Threads::Threads st_audiofile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-jsl sfizz-atomic)
|
||||
set_target_properties (sfizz_static PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp")
|
||||
if(SFIZZ_USE_SNDFILE)
|
||||
target_compile_definitions (sfizz_static PUBLIC SFIZZ_USE_SNDFILE=1)
|
||||
endif()
|
||||
if (WIN32)
|
||||
target_compile_definitions (sfizz_static PRIVATE _USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
|
@ -248,6 +251,9 @@ if (SFIZZ_SHARED)
|
|||
target_include_directories (sfizz_shared PRIVATE .)
|
||||
target_include_directories (sfizz_shared PRIVATE external)
|
||||
target_link_libraries (sfizz_shared PRIVATE absl::strings absl::span sfizz_parser absl::flat_hash_map Threads::Threads st_audiofile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-jsl sfizz-atomic)
|
||||
if(SFIZZ_USE_SNDFILE)
|
||||
target_compile_definitions (sfizz_shared PUBLIC SFIZZ_USE_SNDFILE=1)
|
||||
endif()
|
||||
if (WIN32)
|
||||
target_compile_definitions (sfizz_shared PRIVATE _USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "AudioReader.h"
|
||||
#include "FileMetadata.h"
|
||||
#include <st_audiofile.hpp>
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
#include <sndfile.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
|
@ -51,7 +51,7 @@ unsigned BasicSndfileReader::sampleRate() const
|
|||
|
||||
bool BasicSndfileReader::getInstrument(InstrumentInfo* instrument)
|
||||
{
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
SNDFILE* sndfile = reinterpret_cast<SNDFILE*>(handle_.get_sndfile_handle());
|
||||
if (sf_command(sndfile, SFC_GET_INSTRUMENT, &instrument, sizeof(instrument)) == SF_TRUE)
|
||||
return true;
|
||||
|
|
@ -238,7 +238,7 @@ void NoSeekReverseReader::readWholeFile()
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
const std::error_category& sndfile_category()
|
||||
{
|
||||
class sndfile_category : public std::error_category {
|
||||
|
|
@ -298,7 +298,7 @@ private:
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
static bool formatHasFastSeeking(int format)
|
||||
{
|
||||
bool fast;
|
||||
|
|
@ -348,7 +348,7 @@ static AudioReaderPtr createAudioReaderWithHandle(ST_AudioFile handle, bool reve
|
|||
else if (!reverse)
|
||||
reader.reset(new ForwardReader(std::move(handle)));
|
||||
else {
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
bool hasFastSeeking = formatHasFastSeeking(handle.get_sndfile_format());
|
||||
#else
|
||||
bool hasFastSeeking = true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if defined(SFIZZ_USE_SNDFILE)
|
||||
#include <sndfile.h>
|
||||
#endif
|
||||
#include "ghc/fs_std.hpp"
|
||||
|
|
@ -24,7 +24,7 @@ struct RiffChunkInfo {
|
|||
uint32_t length;
|
||||
};
|
||||
|
||||
#if !defined(ST_AUDIO_FILE_USE_SNDFILE)
|
||||
#if !defined(SFIZZ_USE_SNDFILE)
|
||||
/**
|
||||
@brief Loop mode, like SF_LOOP_*
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue