Merge remote-tracking branch 'origin/cpp14' into cpp14
This commit is contained in:
commit
a6c5e1af5d
7 changed files with 22 additions and 17 deletions
|
|
@ -4,11 +4,15 @@ project(sfizz VERSION 1.0.0 LANGUAGES CXX)
|
||||||
# Set the highest possible standard
|
# Set the highest possible standard
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
|
# Enable LTO
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # To override the policy in abseil and benchmark
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||||
add_compile_options(-stdlib=libc++)
|
add_compile_options(-stdlib=libc++)
|
||||||
# Presumably need the above for linking too, maybe other options missing as well
|
# Presumably need the above for linking too, maybe other options missing as well
|
||||||
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
|
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
|
||||||
else()
|
else()
|
||||||
add_link_options(-lstdc++fs)
|
add_link_options(-lstdc++fs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,19 +37,22 @@ endif()
|
||||||
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
||||||
|
|
||||||
add_library(sfizz_parser STATIC)
|
add_library(sfizz_parser STATIC)
|
||||||
target_sources(sfizz_parser PUBLIC Parser.cpp Opcode.cpp)
|
target_sources(sfizz_parser PRIVATE Parser.cpp Opcode.cpp)
|
||||||
target_include_directories(sfizz_parser PUBLIC .)
|
target_include_directories(sfizz_parser PUBLIC .)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(sfizz_parser PUBLIC stdc++fs)
|
target_link_libraries(sfizz_parser PUBLIC stdc++fs)
|
||||||
|
# target_compile_options(sfizz_parser PUBLIC -fno-rtti -fno-exceptions)
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
target_link_libraries(sfizz_parser PRIVATE absl::strings)
|
target_link_libraries(sfizz_parser PRIVATE absl::strings)
|
||||||
|
|
||||||
add_library(sfizz STATIC ${SFIZZ_SOURCES})
|
add_library(sfizz STATIC ${SFIZZ_SOURCES})
|
||||||
target_link_libraries(sfizz PRIVATE sfizz_parser)
|
target_link_libraries(sfizz PRIVATE sfizz_parser)
|
||||||
target_include_directories(sfizz PUBLIC .)
|
target_include_directories(sfizz PUBLIC .)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
target_link_libraries(sfizz PRIVATE Threads::Threads)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(sfizz PUBLIC stdc++fs atomic)
|
target_link_libraries(sfizz PUBLIC stdc++fs atomic)
|
||||||
target_compile_options(sfizz PRIVATE -fno-rtti -fno-exceptions)
|
# target_compile_options(sfizz PUBLIC -fno-rtti -fno-exceptions)
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
target_link_libraries(sfizz PUBLIC absl::strings)
|
target_link_libraries(sfizz PUBLIC absl::strings)
|
||||||
target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map)
|
target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ std::unique_ptr<AudioBuffer<T>> readFromFile(SndfileHandle& sndFile, int numFram
|
||||||
sndFile.readf(tempReadBuffer->channelWriter(0), numFrames);
|
sndFile.readf(tempReadBuffer->channelWriter(0), numFrames);
|
||||||
::readInterleaved<float>(tempReadBuffer->getSpan(0), returnedBuffer->getSpan(0), returnedBuffer->getSpan(1));
|
::readInterleaved<float>(tempReadBuffer->getSpan(0), returnedBuffer->getSpan(0), returnedBuffer->getSpan(1));
|
||||||
}
|
}
|
||||||
return std::move(returnedBuffer);
|
return returnedBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation(const std::string& filename, uint32_t offset) noexcept
|
absl::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation(const std::string& filename, uint32_t offset) noexcept
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,7 @@
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
class FilePool {
|
class FilePool {
|
||||||
public:
|
public:
|
||||||
FilePool()
|
FilePool() { }
|
||||||
: fileLoadingThread(std::thread(&FilePool::loadingThread, this))
|
|
||||||
, garbageCollectionThread(std::thread(&FilePool::garbageThread, this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~FilePool()
|
~FilePool()
|
||||||
{
|
{
|
||||||
|
|
@ -75,11 +71,11 @@ private:
|
||||||
moodycamel::BlockingReaderWriterQueue<FileLoadingInformation> loadingQueue { config::numVoices };
|
moodycamel::BlockingReaderWriterQueue<FileLoadingInformation> loadingQueue { config::numVoices };
|
||||||
void loadingThread() noexcept;
|
void loadingThread() noexcept;
|
||||||
void garbageThread() noexcept;
|
void garbageThread() noexcept;
|
||||||
std::thread fileLoadingThread;
|
bool quitThread { false };
|
||||||
std::thread garbageCollectionThread;
|
std::thread fileLoadingThread { &FilePool::loadingThread, this };
|
||||||
|
std::thread garbageCollectionThread { &FilePool::garbageThread, this };
|
||||||
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
||||||
std::mutex fileHandleMutex;
|
std::mutex fileHandleMutex;
|
||||||
bool quitThread { false };
|
|
||||||
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
||||||
LEAK_DETECTOR(FilePool);
|
LEAK_DETECTOR(FilePool);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -356,12 +356,14 @@ void sfz::Synth::noteOn(int delay, int channel, int noteNumber, uint8_t velocity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Synth::noteOff(int delay, int channel, int noteNumber, uint8_t velocity) noexcept
|
|
||||||
{
|
{
|
||||||
ASSERT(noteNumber < 128);
|
ASSERT(noteNumber < 128);
|
||||||
ASSERT(noteNumber >= 0);
|
ASSERT(noteNumber >= 0);
|
||||||
|
|
||||||
auto replacedVelocity = velocity == 0 ? midiState.getNoteVelocity(noteNumber) : velocity;
|
// FIXME: Some keyboards (e.g. Casio PX5S) can send a real note-off velocity. In this case, do we have a
|
||||||
|
// way in sfz to specify that a release trigger should NOT use the note-on velocity?
|
||||||
|
// auto replacedVelocity = (velocity == 0 ? sfz::getNoteVelocity(noteNumber) : velocity);
|
||||||
|
auto replacedVelocity = midiState.getNoteVelocity(noteNumber);
|
||||||
auto randValue = randNoteDistribution(Random::randomGenerator);
|
auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||||
for (auto& voice : voices)
|
for (auto& voice : voices)
|
||||||
voice->registerNoteOff(delay, channel, noteNumber, replacedVelocity);
|
voice->registerNoteOff(delay, channel, noteNumber, replacedVelocity);
|
||||||
|
|
|
||||||
|
|
@ -365,8 +365,8 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
|
||||||
::add<int>(sourcePosition, indices);
|
::add<int>(sourcePosition, indices);
|
||||||
|
|
||||||
//FIXME : all this casting is driving me crazy
|
//FIXME : all this casting is driving me crazy
|
||||||
const auto sampleEnd = static_cast<int>(region->trueSampleEnd()) - 1;
|
const auto sampleEnd = min(static_cast<int>(region->trueSampleEnd()), static_cast<int>(source.getNumFrames())) - 1;
|
||||||
if (region->shouldLoop() && static_cast<size_t>(sampleEnd) <= source.getNumFrames()) {
|
if (region->shouldLoop() && region->loopRange.getEnd() <= source.getNumFrames()) {
|
||||||
const auto offset = sampleEnd - static_cast<int>(region->loopRange.getStart());
|
const auto offset = sampleEnd - static_cast<int>(region->loopRange.getStart());
|
||||||
for (auto* index = indices.begin(); index < indices.end(); ++index) {
|
for (auto* index = indices.begin(); index < indices.end(); ++index) {
|
||||||
if (*index > sampleEnd) {
|
if (*index > sampleEnd) {
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,7 @@ TEST_CASE("[Helpers] Linear Ramp (SIMD)")
|
||||||
std::array<float, 6> output;
|
std::array<float, 6> output;
|
||||||
std::array<float, 6> expected { v, v + v, v + v + v, v + v + v + v, v + v + v + v + v, v + v + v + v + v + v };
|
std::array<float, 6> expected { v, v + v, v + v + v, v + v + v + v, v + v + v + v + v, v + v + v + v + v + v };
|
||||||
linearRamp<float, true>(absl::MakeSpan(output), start, v);
|
linearRamp<float, true>(absl::MakeSpan(output), start, v);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[Helpers] Linear Ramp (SIMD vs scalar)")
|
TEST_CASE("[Helpers] Linear Ramp (SIMD vs scalar)")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue