Added a freewheeling option to the synth
This commit is contained in:
parent
f1653a499d
commit
a5b8bfb6ac
4 changed files with 21 additions and 1 deletions
|
|
@ -324,7 +324,8 @@ int sfizz_get_num_buffers(sfizz_synth_t* synth);
|
|||
*/
|
||||
int sfizz_get_num_bytes(sfizz_synth_t* synth);
|
||||
|
||||
|
||||
void sfizz_enable_freewheeling(sfizz_synth_t* synth);
|
||||
void sfizz_disable_freewheeling(sfizz_synth_t* synth);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
|
||||
resources.filePool.cleanupPromises();
|
||||
|
||||
if (freeWheeling)
|
||||
resources.filePool.waitForBackgroundLoading();
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -324,6 +324,9 @@ public:
|
|||
* @return The allocated bytes.
|
||||
*/
|
||||
int getAllocatedBytes() const noexcept { return Buffer<float>::counter().getTotalBytes(); }
|
||||
|
||||
void enableFreeWheeling() { freeWheeling = true; }
|
||||
void disableFreeWheeling() { freeWheeling = true; }
|
||||
protected:
|
||||
/**
|
||||
* @brief The parser callback; this is called by the parent object each time
|
||||
|
|
@ -419,6 +422,7 @@ private:
|
|||
// Atomic guards; must be used with AtomicGuard and AtomicDisabler
|
||||
std::atomic<bool> canEnterCallback { true };
|
||||
std::atomic<bool> inCallback { false };
|
||||
bool freeWheeling { false };
|
||||
|
||||
// Singletons passed as references to the voices
|
||||
Resources resources;
|
||||
|
|
|
|||
|
|
@ -204,6 +204,18 @@ int sfizz_get_num_bytes(sfizz_synth_t* synth)
|
|||
return self->getAllocatedBytes();
|
||||
}
|
||||
|
||||
void sfizz_enable_freewheeling(sfizz_synth_t* synth)
|
||||
{
|
||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||
self->enableFreeWheeling();
|
||||
}
|
||||
|
||||
void sfizz_disable_freewheeling(sfizz_synth_t* synth)
|
||||
{
|
||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||
self->enableFreeWheeling();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue