Merge pull request #542 from jpcima/fix-with-sndfile

Fix with sndfile
This commit is contained in:
JP Cimalando 2020-11-04 09:42:41 +01:00 committed by GitHub
commit 38ac7cf66f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View file

@ -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

View file

@ -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()

View file

@ -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,9 +51,10 @@ 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)
SF_INSTRUMENT* sfins = instrument;
if (sf_command(sndfile, SFC_GET_INSTRUMENT, sfins, sizeof(SF_INSTRUMENT)) == SF_TRUE)
return true;
#else
(void)instrument;
@ -238,7 +239,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 +299,7 @@ private:
//------------------------------------------------------------------------------
#if defined(ST_AUDIO_FILE_USE_SNDFILE)
#if defined(SFIZZ_USE_SNDFILE)
static bool formatHasFastSeeking(int format)
{
bool fast;
@ -348,7 +349,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;

View file

@ -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_*
*/