diff --git a/src/sfizz/FilePool.h b/src/sfizz/FilePool.h index 9e238953..9d54fd6d 100644 --- a/src/sfizz/FilePool.h +++ b/src/sfizz/FilePool.h @@ -134,14 +134,57 @@ public: * */ void clear(); - + /** + * @brief Moves the filled promises to a linear storage, and checks + * said linear storage for promises that are not used anymore. + * + * This function has to be called on the audio thread. + */ void cleanupPromises() noexcept; + /** + * @brief Get a file promise + * + * @param filename the file to preload + * @return FilePromisePtr a file promise + */ FilePromisePtr getFilePromise(const std::string& filename) noexcept; + /** + * @brief Change the preloading size. This will trigger a full + * reload of all samples, so don't call it on the audio thread. + * + * @param preloadSize + */ void setPreloadSize(uint32_t preloadSize) noexcept; + /** + * @brief Get the current preload size. + * + * @return uint32_t + */ uint32_t getPreloadSize() const noexcept; + /** + * @brief Set the oversampling factor. This will trigger a full + * reload of all samples so don't call it on the audio thread. + * + * @param factor + */ void setOversamplingFactor(Oversampling factor) noexcept; + /** + * @brief Get the current oversampling factor + * + * @return Oversampling + */ Oversampling getOversamplingFactor() const noexcept; + /** + * @brief Empty the file loading queues without actually loading + * the files. All promises will be unfulfilled. Don't call this + * method on the audio thread as it will spinlock. + * + */ void emptyFileLoadingQueues() noexcept; + /** + * @brief Wait for the background loading to finish for all promises + * in the queue. + */ void waitForBackgroundLoading() noexcept; private: fs::path rootDirectory; diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 3ad7a76c..c579ff31 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -576,8 +576,8 @@ uint32_t sfz::Synth::getPreloadSize() const noexcept void sfz::Synth::enableFreeWheeling() noexcept { if (!freeWheeling) { - freeWheeling = true; - DBG("Enabling freewheeling"); + freeWheeling = true; + DBG("Enabling freewheeling"); } } void sfz::Synth::disableFreeWheeling() noexcept diff --git a/src/sfizz/Synth.h b/src/sfizz/Synth.h index 99da4fac..70397b2d 100644 --- a/src/sfizz/Synth.h +++ b/src/sfizz/Synth.h @@ -189,8 +189,8 @@ public: /** * @brief Send a note on event to the synth * - * @param delay the delay at which the event occurs; this should be lower than the size of - * the block in the next call to renderBlock(). + * @param delay the delay at which the event occurs; this should be lower + * than the size of the block in the next call to renderBlock(). * @param channel the midi channel for the event * @param noteNumber the midi note number * @param velocity the midi note velocity @@ -199,8 +199,8 @@ public: /** * @brief Send a note off event to the synth * - * @param delay the delay at which the event occurs; this should be lower than the size of - * the block in the next call to renderBlock(). + * @param delay the delay at which the event occurs; this should be lower + * than the size of the block in the next call to renderBlock(). * @param channel the midi channel for the event * @param noteNumber the midi note number * @param velocity the midi note velocity @@ -219,8 +219,9 @@ public: /** * @brief Send a pitch bend event to the synth * - * @param delay the delay at which the event occurs; this should be lower than the size of - * the block in the next call to renderBlock(). + * @param delay the delay at which the event occurs; this should be lower + * than the size of the block in the next call to + * renderBlock(). * @param channel the midi channel for the event * @param pitch the pitch value */ @@ -244,12 +245,14 @@ public: */ void tempo(int delay, float secondsPerQuarter) noexcept; /** - * @brief Render an block of audio data in the buffer. This call will reset the synth - * in its waiting state for the next batch of events. The size of the block is integrated - * in the AudioSpan object. You can build an AudioSpan implicitely from a large number - * of source objects; check the AudioSpan reference for more precision. + * @brief Render an block of audio data in the buffer. This call will reset + * the synth in its waiting state for the next batch of events. The size of + * the block is integrated in the AudioSpan object. You can build an + * AudioSpan implicitely from a large number of source objects; check the + * AudioSpan reference for more precision. * - * @param buffer the buffer to write the next block into; this should be a stereo buffer. + * @param buffer the buffer to write the next block into; this should be a + * stereo buffer. */ void renderBlock(AudioSpan buffer) noexcept; @@ -325,7 +328,18 @@ public: */ int getAllocatedBytes() const noexcept { return Buffer::counter().getTotalBytes(); } + /** + * @brief Enable freewheeling on the synth. This will wait for background + * loaded files to finish loading before each render callback to ensure that + * there will be no dropouts. + * + */ void enableFreeWheeling() noexcept; + /** + * @brief Disable freewheeling on the synth. You should disable freewheeling + * before live use of the plugin otherwise the audio thread will lock. + * + */ void disableFreeWheeling() noexcept; protected: /**