Merge pull request #244 from jpcima/hdcc-api
Add the API to receive hdcc values
This commit is contained in:
commit
db27cb0376
6 changed files with 52 additions and 5 deletions
13
src/sfizz.h
13
src/sfizz.h
|
|
@ -243,6 +243,19 @@ SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int
|
||||||
*/
|
*/
|
||||||
SFIZZ_EXPORTED_API void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value);
|
SFIZZ_EXPORTED_API void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send a high precision CC event to the synth. As with all MIDI
|
||||||
|
* events, this needs to happen before the call to
|
||||||
|
* sfizz_render_block in each block and should appear in order of
|
||||||
|
* the delays.
|
||||||
|
*
|
||||||
|
* @param synth The synth.
|
||||||
|
* @param delay The delay of the event in the block, in samples.
|
||||||
|
* @param cc_number The MIDI CC number.
|
||||||
|
* @param norm_value The normalized CC value, in domain 0 to 1.
|
||||||
|
*/
|
||||||
|
SFIZZ_EXPORTED_API void sfizz_send_hdcc(sfizz_synth_t* synth, int delay, int cc_number, float norm_value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a pitch wheel event. As with all MIDI events, this needs
|
* @brief Send a pitch wheel event. As with all MIDI events, this needs
|
||||||
* to happen before the call to sfizz_render_block in each block and
|
* to happen before the call to sfizz_render_block in each block and
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void cc(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
void cc(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send a high precision CC 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 ccNumber the cc number.
|
||||||
|
* @param normValue the normalized cc value, in domain 0 to 1.
|
||||||
|
*/
|
||||||
|
void hdcc(int delay, int ccNumber, float normValue) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a pitch bend event to the synth
|
* @brief Send a pitch bend event to the synth
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -854,13 +854,18 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
||||||
|
{
|
||||||
|
const auto normalizedCC = normalizeCC(ccValue);
|
||||||
|
hdcc(delay, ccNumber, normalizedCC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sfz::Synth::hdcc(int delay, int ccNumber, float normValue) noexcept
|
||||||
{
|
{
|
||||||
ASSERT(ccNumber < config::numCCs);
|
ASSERT(ccNumber < config::numCCs);
|
||||||
ASSERT(ccNumber >= 0);
|
ASSERT(ccNumber >= 0);
|
||||||
const auto normalizedCC = normalizeCC(ccValue);
|
|
||||||
|
|
||||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||||
resources.midiState.ccEvent(delay, ccNumber, normalizedCC);
|
resources.midiState.ccEvent(delay, ccNumber, normValue);
|
||||||
|
|
||||||
const std::unique_lock<std::mutex> lock { callbackGuard, std::try_to_lock };
|
const std::unique_lock<std::mutex> lock { callbackGuard, std::try_to_lock };
|
||||||
if (!lock.owns_lock())
|
if (!lock.owns_lock())
|
||||||
|
|
@ -872,15 +877,15 @@ void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& voice : voices)
|
for (auto& voice : voices)
|
||||||
voice->registerCC(delay, ccNumber, normalizedCC);
|
voice->registerCC(delay, ccNumber, normValue);
|
||||||
|
|
||||||
for (auto& region : ccActivationLists[ccNumber]) {
|
for (auto& region : ccActivationLists[ccNumber]) {
|
||||||
if (region->registerCC(ccNumber, normalizedCC)) {
|
if (region->registerCC(ccNumber, normValue)) {
|
||||||
auto voice = findFreeVoice();
|
auto voice = findFreeVoice();
|
||||||
if (voice == nullptr)
|
if (voice == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
voice->startVoice(region, delay, ccNumber, normalizedCC, Voice::TriggerType::CC);
|
voice->startVoice(region, delay, ccNumber, normValue, Voice::TriggerType::CC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,15 @@ public:
|
||||||
* @param ccValue the cc value
|
* @param ccValue the cc value
|
||||||
*/
|
*/
|
||||||
void cc(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
void cc(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
||||||
|
/**
|
||||||
|
* @brief Send a high precision CC 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 ccNumber the cc number
|
||||||
|
* @param normValue the normalized cc value, in domain 0 to 1
|
||||||
|
*/
|
||||||
|
void hdcc(int delay, int ccNumber, float normValue) noexcept;
|
||||||
/**
|
/**
|
||||||
* @brief Send a pitch bend event to the synth
|
* @brief Send a pitch bend event to the synth
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,11 @@ void sfz::Sfizz::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
||||||
synth->cc(delay, ccNumber, ccValue);
|
synth->cc(delay, ccNumber, ccValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sfz::Sfizz::hdcc(int delay, int ccNumber, float normValue) noexcept
|
||||||
|
{
|
||||||
|
synth->hdcc(delay, ccNumber, normValue);
|
||||||
|
}
|
||||||
|
|
||||||
void sfz::Sfizz::pitchWheel(int delay, int pitch) noexcept
|
void sfz::Sfizz::pitchWheel(int delay, int pitch) noexcept
|
||||||
{
|
{
|
||||||
synth->pitchWheel(delay, pitch);
|
synth->pitchWheel(delay, pitch);
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,11 @@ void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
self->cc(delay, cc_number, cc_value);
|
self->cc(delay, cc_number, cc_value);
|
||||||
}
|
}
|
||||||
|
void sfizz_send_hdcc(sfizz_synth_t* synth, int delay, int cc_number, float norm_value)
|
||||||
|
{
|
||||||
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
|
self->hdcc(delay, cc_number, norm_value);
|
||||||
|
}
|
||||||
void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay, int pitch)
|
void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay, int pitch)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue