diff --git a/clients/jack_client.cpp b/clients/jack_client.cpp index 23975aa3..cd5f8fd7 100644 --- a/clients/jack_client.cpp +++ b/clients/jack_client.cpp @@ -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])); diff --git a/plugins/lv2/sfizz.cpp b/plugins/lv2/sfizz.cpp index d5ec2613..912c04b1 100644 --- a/plugins/lv2/sfizz.cpp +++ b/plugins/lv2/sfizz.cpp @@ -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; diff --git a/plugins/vst/SfizzVstProcessor.cpp b/plugins/vst/SfizzVstProcessor.cpp index 552d21a7..7ae97bc3 100644 --- a/plugins/vst/SfizzVstProcessor.cpp +++ b/plugins/vst/SfizzVstProcessor.cpp @@ -383,7 +383,7 @@ void SfizzVstProcessor::playOrderedParameter(int32 sampleOffset, Vst::ParamID id _state.oscillatorQuality = static_cast(range.denormalize(value)); break; case kPidAftertouch: - synth.hdAftertouch(sampleOffset, value); + synth.hdChannelAftertouch(sampleOffset, value); break; case kPidPitchBend: synth.hdPitchWheel(sampleOffset, range.denormalize(value)); diff --git a/src/sfizz.h b/src/sfizz.h index ea00fef4..d79a10e3 100644 --- a/src/sfizz.h +++ b/src/sfizz.h @@ -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. @@ -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. diff --git a/src/sfizz.hpp b/src/sfizz.hpp index b519ad92..9c36743e 100644 --- a/src/sfizz.hpp +++ b/src/sfizz.hpp @@ -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(). @@ -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. diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 1ecba09a..9ac490d1 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -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 }; diff --git a/src/sfizz/Synth.h b/src/sfizz/Synth.h index 1dbb9405..709833d4 100644 --- a/src/sfizz/Synth.h +++ b/src/sfizz/Synth.h @@ -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 * diff --git a/src/sfizz/sfizz.cpp b/src/sfizz/sfizz.cpp index 370e5201..c3a98ee0 100644 --- a/src/sfizz/sfizz.cpp +++ b/src/sfizz/sfizz.cpp @@ -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 diff --git a/src/sfizz/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp index 9f584435..8a720d03 100644 --- a/src/sfizz/sfizz_wrapper.cpp +++ b/src/sfizz/sfizz_wrapper.cpp @@ -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) { diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index d9f6a2da..2e71c21f 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -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); }