Merge pull request #839 from paulfd/deprecate-some-apis

Update channel aftertouch API
This commit is contained in:
Paul Ferrand 2021-04-15 23:50:57 +02:00 committed by GitHub
commit fb0600c94f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 112 additions and 76 deletions

View file

@ -95,7 +95,7 @@ int process(jack_nframes_t numFrames, void* arg)
// Not implemented
break;
case midi::channelPressure:
synth->aftertouch(event.time, event.buffer[1]);
synth->channelAftertouch(event.time, event.buffer[1]);
break;
case midi::pitchBend:
synth->pitchWheel(event.time, midi::buildAndCenterPitch(event.buffer[1], event.buffer[2]));

View file

@ -695,7 +695,7 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
break;
#endif
case LV2_MIDI_MSG_CHANNEL_PRESSURE:
sfizz_send_aftertouch(self->synth,
sfizz_send_channel_aftertouch(self->synth,
(int)ev->time.frames,
msg[1]);
break;

View file

@ -383,7 +383,7 @@ void SfizzVstProcessor::playOrderedParameter(int32 sampleOffset, Vst::ParamID id
_state.oscillatorQuality = static_cast<int32>(range.denormalize(value));
break;
case kPidAftertouch:
synth.hdAftertouch(sampleOffset, value);
synth.hdChannelAftertouch(sampleOffset, value);
break;
case kPidPitchBend:
synth.hdPitchWheel(sampleOffset, range.denormalize(value));

View file

@ -99,7 +99,7 @@ SFIZZ_EXPORTED_API void sfizz_free(sfizz_synth_t* synth);
/**
* @brief Adds a reference to an existing sfizz synth.
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth to reference.
*/
@ -349,7 +349,7 @@ SFIZZ_EXPORTED_API void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int
/**
* @brief Send a high-precision on event to the synth.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -388,7 +388,7 @@ SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int
/**
* @brief Send a high-precision note off event to the synth.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -445,7 +445,7 @@ SFIZZ_EXPORTED_API void sfizz_send_hdcc(sfizz_synth_t* synth, int delay, int cc_
/**
* @brief Send a high precision CC automation to the synth.
* @since 0.6.0
* @since 1.0.0
*
* This updates the CC value known to the synth, but without performing
* additional MIDI-specific interpretations. (eg. the CC 120 and up)
@ -483,7 +483,7 @@ SFIZZ_EXPORTED_API void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay,
/**
* @brief Send a high-precision pitch wheel event.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -514,11 +514,29 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_pitch_wheel(sfizz_synth_t* synth, int dela
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
SFIZZ_EXPORTED_API void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch);
SFIZZ_EXPORTED_API SFIZZ_DEPRECATED_API void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch);
/**
* @brief Send a channel aftertouch (channel pressure) event.
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @param synth 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 aftertouch The aftertouch value, in domain 0 to 127.
*
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
SFIZZ_EXPORTED_API void sfizz_send_channel_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch);
/**
* @brief Send a high-precision aftertouch event.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -532,12 +550,12 @@ SFIZZ_EXPORTED_API void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, i
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
SFIZZ_EXPORTED_API void sfizz_send_hd_aftertouch(sfizz_synth_t* synth, int delay, float aftertouch);
SFIZZ_EXPORTED_API void sfizz_send_hd_channel_aftertouch(sfizz_synth_t* synth, int delay, float aftertouch);
/**
* @brief Send a polyphonic aftertouch event.
* This feature is experimental and needs more testing in the internal engine.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -557,7 +575,7 @@ SFIZZ_EXPORTED_API void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int del
/**
* @brief Send a high-precision polyphonic aftertouch event.
* This feature is experimental and needs more testing in the internal engine.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -599,7 +617,7 @@ SFIZZ_EXPORTED_API SFIZZ_DEPRECATED_API void sfizz_send_tempo(sfizz_synth_t* syn
* tempo(), timeSignature(), timePosition(), and playbackState(), otherwise the behavior
* of the synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth.
* @param delay The delay.
@ -785,7 +803,7 @@ SFIZZ_EXPORTED_API void sfizz_set_sample_quality(sfizz_synth_t* synth, sfizz_pro
* does not use the opcode `oscillator_quality`. The engine uses distinct
* default quality settings for live mode and freewheeling mode,
* which both can be accessed by the means of this function.
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth.
* @param[in] mode The processing mode.
@ -801,7 +819,7 @@ SFIZZ_EXPORTED_API int sfizz_get_oscillator_quality(sfizz_synth_t* synth, sfizz_
* does not use the opcode `oscillator_quality`. The engine uses distinct
* default quality settings for live mode and freewheeling mode,
* which both can be accessed by the means of this function.
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth.
* @param[in] mode The processing mode.
@ -948,7 +966,7 @@ SFIZZ_EXPORTED_API bool sfizz_should_reload_scala(sfizz_synth_t* synth);
* @par Thread-safety constraints
* - TBD ?
*/
SFIZZ_EXPORTED_API void sfizz_enable_logging(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API void sfizz_enable_logging(sfizz_synth_t* synth, const char* prefix);
/**
* @brief Disable logging.
@ -973,7 +991,7 @@ SFIZZ_EXPORTED_API void sfizz_disable_logging(sfizz_synth_t* synth);
* @par Thread-safety constraints
* - TBD ?
*/
SFIZZ_EXPORTED_API void sfizz_set_logging_prefix(sfizz_synth_t* synth, const char* prefix);
SFIZZ_EXPORTED_API SFIZZ_DEPRECATED_API void sfizz_set_logging_prefix(sfizz_synth_t* synth, const char* prefix);
/**
* @brief Shuts down the current processing, clear buffers and reset the voices.
@ -1086,13 +1104,13 @@ SFIZZ_EXPORTED_API const char * sfizz_get_cc_label_text(sfizz_synth_t* synth, in
/**
* @brief Client for communicating with the synth engine in either direction
* @since 0.6.0
* @since 1.0.0
*/
typedef struct sfizz_client_t sfizz_client_t;
/**
* @brief Create a new messaging client
* @since 0.6.0
* @since 1.0.0
*
* @param data The opaque data pointer which is passed to the receiver.
* @return The new client.
@ -1101,7 +1119,7 @@ SFIZZ_EXPORTED_API sfizz_client_t* sfizz_create_client(void* data);
/**
* @brief Destroy a messaging client
* @since 0.6.0
* @since 1.0.0
*
* @param client The client.
*/
@ -1109,7 +1127,7 @@ SFIZZ_EXPORTED_API void sfizz_delete_client(sfizz_client_t* client);
/**
* @brief Get the client data
* @since 0.6.0
* @since 1.0.0
*
* @param client The client.
* @return The client data.
@ -1118,7 +1136,7 @@ SFIZZ_EXPORTED_API void* sfizz_get_client_data(sfizz_client_t* client);
/**
* @brief Set the function which receives reply messages from the synth engine.
* @since 0.6.0
* @since 1.0.0
*
* @param client The client.
* @param receive The pointer to the receiving function.
@ -1127,7 +1145,7 @@ SFIZZ_EXPORTED_API void sfizz_set_receive_callback(sfizz_client_t* client, sfizz
/**
* @brief Send a message to the synth engine
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth.
* @param client The client sending the message.
@ -1143,7 +1161,7 @@ SFIZZ_EXPORTED_API void sfizz_send_message(sfizz_synth_t* synth, sfizz_client_t*
/**
* @brief Set the function which receives broadcast messages from the synth engine.
* @since 0.6.0
* @since 1.0.0
*
* @param synth The synth.
* @param broadcast The pointer to the receiving function.

View file

@ -325,7 +325,7 @@ public:
* does not use the opcode `oscillator_quality`. The engine uses distinct
* default quality settings for live mode and freewheeling mode,
* which both can be accessed by the means of this function.
* @since 0.6.0
* @since 1.0.0
*
* @param[in] mode The processing mode.
*
@ -341,7 +341,7 @@ public:
* default quality settings for live mode and freewheeling mode,
* which both can be accessed by the means of this function.
*
* @since 0.6.0
* @since 1.0.0
*
* @param[in] mode The processing mode.
* @param[in] quality The desired oscillator quality, in the range 0 to 3.
@ -391,7 +391,7 @@ public:
/**
* @brief Send a high-precision note on event to the synth.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -427,7 +427,7 @@ public:
/**
* @brief Send a note off event to the synth.
* @since 0.6.0
* @since 1.0.0
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
@ -489,7 +489,7 @@ public:
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -526,7 +526,7 @@ public:
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -553,7 +553,25 @@ public:
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
void aftertouch(int delay, int aftertouch) noexcept;
SFIZZ_DEPRECATED_API void aftertouch(int delay, int aftertouch) noexcept;
/**
* @brief Send a channel aftertouch (channel pressure) event to the synth.
*
* This command should be delay-ordered with all other midi-type events
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.2.0
*
* @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 aftertouch the aftertouch value, in domain 0 to 127.
*
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
void channelAftertouch(int delay, int aftertouch) noexcept;
/**
* @brief Send a high-precision aftertouch event to the synth.
@ -562,7 +580,7 @@ public:
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -571,7 +589,7 @@ public:
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
void hdAftertouch(int delay, float aftertouch) noexcept;
void hdChannelAftertouch(int delay, float aftertouch) noexcept;
/**
* @brief Send a polyphonic aftertouch event to the synth.
@ -581,7 +599,7 @@ public:
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -601,7 +619,7 @@ public:
* (notes, CCs, aftertouch and pitch-wheel), otherwise the behavior of the
* synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -638,7 +656,7 @@ public:
* tempo(), timeSignature(), timePosition(), and playbackState(), otherwise the behavior
* of the synth is undefined.
*
* @since 0.6.0
* @since 1.0.0
*
* @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().
@ -868,7 +886,7 @@ public:
* @par Thread-safety constraints
* - TBD ?
*/
void enableLogging() noexcept;
SFIZZ_DEPRECATED_API void enableLogging() noexcept;
/**
* @brief Enable logging of timings to sidecar CSV files.
@ -894,7 +912,7 @@ public:
* @par Thread-safety constraints
* - TBD ?
*/
void setLoggingPrefix(const std::string& prefix) noexcept;
SFIZZ_DEPRECATED_API void setLoggingPrefix(const std::string& prefix) noexcept;
/**
* @brief Disable logging of timings to sidecar CSV files.
@ -956,7 +974,7 @@ public:
/**
* @brief Export a MIDI Name document describing the currently loaded SFZ file.
* @since 0.6.0
* @since 1.0.0
*
* @param model The model name used if a non-empty string, otherwise generated.
*
@ -979,7 +997,7 @@ public:
/**
* @brief Create a new messaging client
* @since 0.6.0
* @since 1.0.0
*
* @param data The opaque data pointer which is passed to the receiver.
* @return The new client.
@ -988,7 +1006,7 @@ public:
/**
* @brief Get the client data
* @since 0.6.0
* @since 1.0.0
*
* @param client The client.
* @return The client data.
@ -997,7 +1015,7 @@ public:
/**
* @brief Set the function which receives reply messages from the synth engine.
* @since 0.6.0
* @since 1.0.0
*
* @param client The client.
* @param receive The pointer to the receiving function.
@ -1007,7 +1025,7 @@ public:
/**
* @brief Send a message to the synth engine
*
* @since 0.6.0
* @since 1.0.0
*
* @param client The client sending the message.
* @param delay The delay of the message in the block, in samples.
@ -1023,7 +1041,7 @@ public:
/**
* @brief Set the function which receives broadcast messages from the synth engine.
*
* @since 0.6.0
* @since 1.0.0
*
* @param broadcast The pointer to the receiving function.
* @param data The opaque data pointer which is passed to the receiver.

View file

@ -1345,13 +1345,13 @@ void Synth::hdPitchWheel(int delay, float normalizedPitch) noexcept
impl.performHdcc(delay, ExtendedCCs::pitchBend, normalizedPitch, false);
}
void Synth::aftertouch(int delay, int aftertouch) noexcept
void Synth::channelAftertouch(int delay, int aftertouch) noexcept
{
const float normalizedAftertouch = normalize7Bits(aftertouch);
hdAftertouch(delay, normalizedAftertouch);
hdChannelAftertouch(delay, normalizedAftertouch);
}
void Synth::hdAftertouch(int delay, float normAftertouch) noexcept
void Synth::hdChannelAftertouch(int delay, float normAftertouch) noexcept
{
Impl& impl = *impl_;
ScopedTiming logger { impl.dispatchDuration_, ScopedTiming::Operation::addToDuration };
@ -1941,12 +1941,6 @@ void Synth::enableLogging(absl::string_view prefix) noexcept
impl.resources_.logger.enableLogging(prefix);
}
void Synth::setLoggingPrefix(absl::string_view prefix) noexcept
{
Impl& impl = *impl_;
impl.resources_.logger.setPrefix(prefix);
}
void Synth::disableLogging() noexcept
{
Impl& impl = *impl_;

View file

@ -446,7 +446,7 @@ public:
* the block in the next call to renderBlock().
* @param aftertouch the aftertouch value
*/
void aftertouch(int delay, int aftertouch) noexcept;
void channelAftertouch(int delay, int aftertouch) noexcept;
/**
* @brief Send a high precision aftertouch event to the synth
*
@ -454,7 +454,7 @@ public:
* the block in the next call to renderBlock().
* @param normAftertouch the normalized aftertouch value, in domain 0 to 1
*/
void hdAftertouch(int delay, float normAftertouch) noexcept;
void hdChannelAftertouch(int delay, float normAftertouch) noexcept;
/**
* @brief Send a tempo event to the synth
*
@ -630,12 +630,6 @@ public:
*
*/
void enableLogging(absl::string_view prefix = "") noexcept;
/**
* @brief Enable logging of timings to sidecar CSV files. This can produce
* many outputs so use with caution.
*
*/
void setLoggingPrefix(absl::string_view prefix) noexcept;
/**
* @brief Disable logging;
*

View file

@ -207,12 +207,17 @@ void sfz::Sfizz::hdPitchWheel(int delay, float pitch) noexcept
void sfz::Sfizz::aftertouch(int delay, int aftertouch) noexcept
{
synth->synth.aftertouch(delay, aftertouch);
synth->synth.channelAftertouch(delay, aftertouch);
}
void sfz::Sfizz::hdAftertouch(int delay, float aftertouch) noexcept
void sfz::Sfizz::channelAftertouch(int delay, int aftertouch) noexcept
{
synth->synth.hdAftertouch(delay, aftertouch);
synth->synth.channelAftertouch(delay, aftertouch);
}
void sfz::Sfizz::hdChannelAftertouch(int delay, float aftertouch) noexcept
{
synth->synth.hdChannelAftertouch(delay, aftertouch);
}
void sfz::Sfizz::polyAftertouch(int delay, int noteNumber, int aftertouch) noexcept
@ -333,7 +338,7 @@ void sfz::Sfizz::enableLogging(const std::string& prefix) noexcept
void sfz::Sfizz::setLoggingPrefix(const std::string& prefix) noexcept
{
synth->synth.setLoggingPrefix(prefix);
}
void sfz::Sfizz::disableLogging() noexcept

View file

@ -152,11 +152,15 @@ void sfizz_send_hd_pitch_wheel(sfizz_synth_t* synth, int delay, float pitch)
}
void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch)
{
synth->synth.aftertouch(delay, aftertouch);
synth->synth.channelAftertouch(delay, aftertouch);
}
void sfizz_send_hd_aftertouch(sfizz_synth_t* synth, int delay, float aftertouch)
void sfizz_send_channel_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch)
{
synth->synth.hdAftertouch(delay, aftertouch);
synth->synth.channelAftertouch(delay, aftertouch);
}
void sfizz_send_hd_channel_aftertouch(sfizz_synth_t* synth, int delay, float aftertouch)
{
synth->synth.hdChannelAftertouch(delay, aftertouch);
}
void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int delay, int note_number, int aftertouch)
{
@ -305,19 +309,22 @@ bool sfizz_should_reload_scala(sfizz_synth_t* synth)
return synth->synth.shouldReloadScala();
}
void sfizz_enable_logging(sfizz_synth_t* synth)
void sfizz_enable_logging(sfizz_synth_t* synth, const char* prefix)
{
return synth->synth.enableLogging();
if (prefix)
synth->synth.enableLogging(prefix);
else
synth->synth.enableLogging();
}
void sfizz_set_logging_prefix(sfizz_synth_t* synth, const char* prefix)
{
return synth->synth.setLoggingPrefix(prefix);
}
void sfizz_disable_logging(sfizz_synth_t* synth)
{
return synth->synth.disableLogging();
synth->synth.disableLogging();
}
void sfizz_all_sound_off(sfizz_synth_t* synth)

View file

@ -1801,13 +1801,13 @@ TEST_CASE("[Keyswitches] Trigger from aftertouch extended CC")
)");
synth.renderBlock(buffer);
REQUIRE(synth.getNumActiveVoices() == 0);
synth.aftertouch(0, 90);
synth.channelAftertouch(0, 90);
synth.renderBlock(buffer);
REQUIRE(synth.getNumActiveVoices() == 0);
synth.aftertouch(0, 110);
synth.channelAftertouch(0, 110);
synth.renderBlock(buffer);
REQUIRE(synth.getNumActiveVoices() == 1);
synth.aftertouch(0, 120);
synth.channelAftertouch(0, 120);
synth.renderBlock(buffer);
REQUIRE(synth.getNumActiveVoices() == 2);
}