Merge pull request #836 from jpcima/api-updates

Api updates
This commit is contained in:
JP Cimalando 2021-04-15 22:37:29 +02:00 committed by GitHub
commit e307e7b282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 150 additions and 63 deletions

View file

@ -313,7 +313,7 @@ sfizz_lv2_update_timeinfo(sfizz_plugin_t *self, int delay, int updates)
if (updates & SFIZZ_TIMEINFO_SIGNATURE) if (updates & SFIZZ_TIMEINFO_SIGNATURE)
sfizz_send_time_signature(self->synth, delay, self->beats_per_bar, self->beat_unit); sfizz_send_time_signature(self->synth, delay, self->beats_per_bar, self->beat_unit);
if (updates & SFIZZ_TIMEINFO_TEMPO) if (updates & SFIZZ_TIMEINFO_TEMPO)
sfizz_send_tempo(self->synth, delay, 60.0f / self->bpm_tempo); sfizz_send_bpm_tempo(self->synth, delay, self->bpm_tempo);
if (updates & SFIZZ_TIMEINFO_SPEED) if (updates & SFIZZ_TIMEINFO_SPEED)
sfizz_send_playback_state(self->synth, delay, self->speed > 0); sfizz_send_playback_state(self->synth, delay, self->speed > 0);
} }

View file

@ -97,7 +97,7 @@ tresult PLUGIN_API SfizzVstProcessor::initialize(FUnknown* context)
_currentStretchedTuning = 0.0; _currentStretchedTuning = 0.0;
loadSfzFileOrDefault({}, false); loadSfzFileOrDefault({}, false);
_synth->tempo(0, 0.5); _synth->bpmTempo(0, 120);
_timeSigNumerator = 4; _timeSigNumerator = 4;
_timeSigDenominator = 4; _timeSigDenominator = 4;
_synth->timeSignature(0, _timeSigNumerator, _timeSigDenominator); _synth->timeSignature(0, _timeSigNumerator, _timeSigDenominator);
@ -313,7 +313,7 @@ void SfizzVstProcessor::updateTimeInfo(const Vst::ProcessContext& context)
sfz::Sfizz& synth = *_synth; sfz::Sfizz& synth = *_synth;
if (context.state & context.kTempoValid) if (context.state & context.kTempoValid)
synth.tempo(0, float(60.0 / context.tempo)); synth.bpmTempo(0, static_cast<float>(context.tempo));
if (context.state & context.kTimeSigValid) { if (context.state & context.kTimeSigValid) {
_timeSigNumerator = context.timeSigNumerator; _timeSigNumerator = context.timeSigNumerator;

View file

@ -43,6 +43,12 @@
#define SFIZZ_EXPORTED_API #define SFIZZ_EXPORTED_API
#endif #endif
#if defined _WIN32
#define SFIZZ_DEPRECATED_API __declspec(deprecated)
#else
#define SFIZZ_DEPRECATED_API __attribute__ ((deprecated))
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -333,13 +339,13 @@ SFIZZ_EXPORTED_API void sfizz_set_sample_rate(sfizz_synth_t* synth, float sample
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param note_number The MIDI note number. * @param note_number The MIDI note number, in domain 0 to 127.
* @param velocity The MIDI velocity. * @param velocity The MIDI velocity, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
SFIZZ_EXPORTED_API void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, char velocity); SFIZZ_EXPORTED_API void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, int velocity);
/** /**
* @brief Send a high-precision on event to the synth. * @brief Send a high-precision on event to the synth.
@ -351,7 +357,7 @@ SFIZZ_EXPORTED_API void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param note_number The MIDI note number. * @param note_number The MIDI note number, in domain 0 to 127.
* @param velocity The normalized MIDI velocity, in domain 0 to 1. * @param velocity The normalized MIDI velocity, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -372,13 +378,13 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_note_on(sfizz_synth_t* synth, int delay, i
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param note_number The MIDI note number. * @param note_number The MIDI note number, in domain 0 to 127.
* @param velocity The MIDI velocity. * @param velocity The MIDI velocity, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, char velocity); SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, int velocity);
/** /**
* @brief Send a high-precision note off event to the synth. * @brief Send a high-precision note off event to the synth.
@ -393,7 +399,7 @@ SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param note_number The MIDI note number. * @param note_number The MIDI note number, in domain 0 to 127.
* @param velocity The normalized MIDI velocity, in domain 0 to 1. * @param velocity The normalized MIDI velocity, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -411,13 +417,13 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_note_off(sfizz_synth_t* synth, int delay,
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param cc_number The MIDI CC number. * @param cc_number The MIDI CC number, in domain 0 to 127.
* @param cc_value The MIDI CC value. * @param cc_value The MIDI CC value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
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, int cc_value);
/** /**
* @brief Send a high precision CC event to the synth. * @brief Send a high precision CC event to the synth.
@ -429,7 +435,7 @@ SFIZZ_EXPORTED_API void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_nu
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param cc_number The MIDI CC number. * @param cc_number The MIDI CC number, in domain 0 to 127.
* @param norm_value The normalized CC value, in domain 0 to 1. * @param norm_value The normalized CC value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -450,7 +456,7 @@ SFIZZ_EXPORTED_API void sfizz_send_hdcc(sfizz_synth_t* synth, int delay, int cc_
* *
* @param synth The synth. * @param synth The synth.
* @param delay The delay of the event in the block, in samples. * @param delay The delay of the event in the block, in samples.
* @param cc_number The MIDI CC number. * @param cc_number The MIDI CC number, in domain 0 to 127.
* @param norm_value The normalized CC value, in domain 0 to 1. * @param norm_value The normalized CC value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -503,12 +509,12 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_pitch_wheel(sfizz_synth_t* synth, int dela
* @param synth The synth. * @param synth The synth.
* @param delay The delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param aftertouch The aftertouch value. * @param aftertouch The aftertouch value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @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, char aftertouch); SFIZZ_EXPORTED_API void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch);
/** /**
* @brief Send a high-precision aftertouch event. * @brief Send a high-precision aftertouch event.
@ -540,13 +546,13 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_aftertouch(sfizz_synth_t* synth, int delay
* @param synth The synth. * @param synth The synth.
* @param delay The delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param note_number The note number. * @param note_number The note number, in domain 0 to 127.
* @param aftertouch The aftertouch value. * @param aftertouch The aftertouch value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
SFIZZ_EXPORTED_API void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int delay, int note_number, char aftertouch); SFIZZ_EXPORTED_API void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int delay, int note_number, int aftertouch);
/** /**
* @brief Send a high-precision polyphonic aftertouch event. * @brief Send a high-precision polyphonic aftertouch event.
@ -560,7 +566,7 @@ SFIZZ_EXPORTED_API void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int del
* @param synth The synth. * @param synth The synth.
* @param delay The delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param note_number The note number. * @param note_number The note number, in domain 0 to 127.
* @param aftertouch The normalized aftertouch value, in domain 0 to 1. * @param aftertouch The normalized aftertouch value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -584,7 +590,25 @@ SFIZZ_EXPORTED_API void sfizz_send_hd_poly_aftertouch(sfizz_synth_t* synth, int
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
SFIZZ_EXPORTED_API void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_beat); SFIZZ_EXPORTED_API SFIZZ_DEPRECATED_API void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_beat);
/**
* @brief Send a tempo event.
*
* This command should be delay-ordered with all other time/signature commands, namely
* tempo(), timeSignature(), timePosition(), and playbackState(), otherwise the behavior
* of the synth is undefined.
*
* @since 0.6.0
*
* @param synth The synth.
* @param delay The delay.
* @param beats_per_minute The new tempo, in beats per minute.
*
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
SFIZZ_EXPORTED_API void sfizz_send_bpm_tempo(sfizz_synth_t* synth, int delay, float beats_per_minute);
/** /**
* @brief Send the time signature. * @brief Send the time signature.

View file

@ -26,6 +26,12 @@
#define SFIZZ_EXPORTED_API #define SFIZZ_EXPORTED_API
#endif #endif
#if defined _WIN32
#define SFIZZ_DEPRECATED_API __declspec(deprecated)
#else
#define SFIZZ_DEPRECATED_API __attribute__ ((deprecated))
#endif
struct sfizz_synth_t; struct sfizz_synth_t;
namespace sfz namespace sfz
@ -375,13 +381,13 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the midi note number. * @param noteNumber the midi note number, in domain 0 to 127.
* @param velocity the midi note velocity. * @param velocity the midi note velocity, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void noteOn(int delay, int noteNumber, uint8_t velocity) noexcept; void noteOn(int delay, int noteNumber, int velocity) noexcept;
/** /**
* @brief Send a high-precision note on event to the synth. * @brief Send a high-precision note on event to the synth.
@ -393,7 +399,7 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the midi note number. * @param noteNumber the midi note number, in domain 0 to 127.
* @param velocity the normalized midi note velocity, in domain 0 to 1. * @param velocity the normalized midi note velocity, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -411,13 +417,13 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the midi note number. * @param noteNumber the midi note number, in domain 0 to 127.
* @param velocity the midi note velocity. * @param velocity the midi note velocity, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void noteOff(int delay, int noteNumber, uint8_t velocity) noexcept; void noteOff(int delay, int noteNumber, int velocity) noexcept;
/** /**
* @brief Send a note off event to the synth. * @brief Send a note off event to the synth.
@ -429,7 +435,7 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the midi note number. * @param noteNumber the midi note number, in domain 0 to 127.
* @param velocity the normalized midi note velocity, in domain 0 to 1. * @param velocity the normalized midi note velocity, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -447,13 +453,13 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param ccNumber the cc number. * @param ccNumber the cc number, in domain 0 to 127.
* @param ccValue the cc value. * @param ccValue the cc value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void cc(int delay, int ccNumber, uint8_t ccValue) noexcept; void cc(int delay, int ccNumber, int ccValue) noexcept;
/** /**
* @brief Send a high precision CC event to the synth * @brief Send a high precision CC event to the synth
@ -465,7 +471,7 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param ccNumber the cc number. * @param ccNumber the cc number, in domain 0 to 127.
* @param normValue the normalized cc value, in domain 0 to 1. * @param normValue the normalized cc value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -487,7 +493,7 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param ccNumber the cc number. * @param ccNumber the cc number, in domain 0 to 127.
* @param normValue the normalized cc value, in domain 0 to 1. * @param normValue the normalized cc value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -542,12 +548,12 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param aftertouch the aftertouch value. * @param aftertouch the aftertouch value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void aftertouch(int delay, uint8_t aftertouch) noexcept; void aftertouch(int delay, int aftertouch) noexcept;
/** /**
* @brief Send a high-precision aftertouch event to the synth. * @brief Send a high-precision aftertouch event to the synth.
@ -579,13 +585,13 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the note number. * @param noteNumber the note number, in domain 0 to 127.
* @param aftertouch the aftertouch value. * @param aftertouch the aftertouch value, in domain 0 to 127.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void polyAftertouch(int delay, int noteNumber, uint8_t aftertouch) noexcept; void polyAftertouch(int delay, int noteNumber, int aftertouch) noexcept;
/** /**
* @brief Send a high-precision polyphonic aftertouch event to the synth. * @brief Send a high-precision polyphonic aftertouch event to the synth.
@ -599,7 +605,7 @@ public:
* *
* @param delay the delay at which the event occurs; this should be lower * @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(). * than the size of the block in the next call to renderBlock().
* @param noteNumber the note number. * @param noteNumber the note number, in domain 0 to 127.
* @param aftertouch the normalized aftertouch value, in domain 0 to 1. * @param aftertouch the normalized aftertouch value, in domain 0 to 1.
* *
* @par Thread-safety constraints * @par Thread-safety constraints
@ -623,7 +629,25 @@ public:
* @par Thread-safety constraints * @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread * - @b RT: the function must be invoked from the Real-time thread
*/ */
void tempo(int delay, float secondsPerBeat) noexcept; SFIZZ_DEPRECATED_API void tempo(int delay, float secondsPerBeat) noexcept;
/**
* @brief Send a tempo event to the synth.
*
* This command should be delay-ordered with all other time/signature commands, namely
* tempo(), timeSignature(), timePosition(), and playbackState(), otherwise the behavior
* of the synth is undefined.
*
* @since 0.6.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 beatsPerMinute the new tempo, in beats per minute.
*
* @par Thread-safety constraints
* - @b RT: the function must be invoked from the Real-time thread
*/
void bpmTempo(int delay, float beatsPerMinute) noexcept;
/** /**
* @brief Send the time signature. * @brief Send the time signature.
@ -930,6 +954,16 @@ public:
*/ */
const std::vector<std::pair<uint16_t, std::string>>& getCCLabels() const noexcept; const std::vector<std::pair<uint16_t, std::string>>& getCCLabels() const noexcept;
/**
* @brief Export a MIDI Name document describing the currently loaded SFZ file.
* @since 0.6.0
*
* @param model The model name used if a non-empty string, otherwise generated.
*
* @return A XML string.
*/
std::string exportMidnam(const char* model);
/** /**
* @addtogroup Messaging * @addtogroup Messaging
* @{ * @{

View file

@ -1061,7 +1061,7 @@ void Synth::renderBlock(AudioSpan<float> buffer) noexcept
SFIZZ_CHECK(isReasonableAudio(buffer.getConstSpan(1))); SFIZZ_CHECK(isReasonableAudio(buffer.getConstSpan(1)));
} }
void Synth::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept void Synth::noteOn(int delay, int noteNumber, int velocity) noexcept
{ {
const float normalizedVelocity = normalizeVelocity(velocity); const float normalizedVelocity = normalizeVelocity(velocity);
hdNoteOn(delay, noteNumber, normalizedVelocity); hdNoteOn(delay, noteNumber, normalizedVelocity);
@ -1077,7 +1077,7 @@ void Synth::hdNoteOn(int delay, int noteNumber, float normalizedVelocity) noexce
impl.resources_.midiState.noteOnEvent(delay, noteNumber, normalizedVelocity); impl.resources_.midiState.noteOnEvent(delay, noteNumber, normalizedVelocity);
} }
void Synth::noteOff(int delay, int noteNumber, uint8_t velocity) noexcept void Synth::noteOff(int delay, int noteNumber, int velocity) noexcept
{ {
const float normalizedVelocity = normalizeVelocity(velocity); const float normalizedVelocity = normalizeVelocity(velocity);
hdNoteOff(delay, noteNumber, normalizedVelocity); hdNoteOff(delay, noteNumber, normalizedVelocity);
@ -1221,7 +1221,7 @@ void Synth::Impl::startDelayedSostenutoReleases(Layer* layer, int delay, SisterV
layer->delayedSostenutoReleases_.clear(); layer->delayedSostenutoReleases_.clear();
} }
void Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept void Synth::cc(int delay, int ccNumber, int ccValue) noexcept
{ {
const auto normalizedCC = normalizeCC(ccValue); const auto normalizedCC = normalizeCC(ccValue);
hdcc(delay, ccNumber, normalizedCC); hdcc(delay, ccNumber, normalizedCC);
@ -1345,7 +1345,7 @@ void Synth::hdPitchWheel(int delay, float normalizedPitch) noexcept
impl.performHdcc(delay, ExtendedCCs::pitchBend, normalizedPitch, false); impl.performHdcc(delay, ExtendedCCs::pitchBend, normalizedPitch, false);
} }
void Synth::aftertouch(int delay, uint8_t aftertouch) noexcept void Synth::aftertouch(int delay, int aftertouch) noexcept
{ {
const float normalizedAftertouch = normalize7Bits(aftertouch); const float normalizedAftertouch = normalize7Bits(aftertouch);
hdAftertouch(delay, normalizedAftertouch); hdAftertouch(delay, normalizedAftertouch);
@ -1369,7 +1369,7 @@ void Synth::hdAftertouch(int delay, float normAftertouch) noexcept
impl.performHdcc(delay, ExtendedCCs::channelAftertouch, normAftertouch, false); impl.performHdcc(delay, ExtendedCCs::channelAftertouch, normAftertouch, false);
} }
void Synth::polyAftertouch(int delay, int noteNumber, uint8_t aftertouch) noexcept void Synth::polyAftertouch(int delay, int noteNumber, int aftertouch) noexcept
{ {
const float normalizedAftertouch = normalize7Bits(aftertouch); const float normalizedAftertouch = normalize7Bits(aftertouch);
hdPolyAftertouch(delay, noteNumber, normalizedAftertouch); hdPolyAftertouch(delay, noteNumber, normalizedAftertouch);
@ -1397,6 +1397,12 @@ void Synth::tempo(int delay, float secondsPerBeat) noexcept
impl.resources_.beatClock.setTempo(delay, secondsPerBeat); impl.resources_.beatClock.setTempo(delay, secondsPerBeat);
} }
void Synth::bpmTempo(int delay, float beatsPerMinute) noexcept
{
// TODO make this the main tempo function and remove the deprecated other one
return tempo(delay, 60 / beatsPerMinute);
}
void Synth::timeSignature(int delay, int beatsPerBar, int beatUnit) void Synth::timeSignature(int delay, int beatsPerBar, int beatUnit)
{ {
Impl& impl = *impl_; Impl& impl = *impl_;

View file

@ -352,7 +352,7 @@ public:
* @param noteNumber the midi note number * @param noteNumber the midi note number
* @param velocity the midi note velocity * @param velocity the midi note velocity
*/ */
void noteOn(int delay, int noteNumber, uint8_t velocity) noexcept; void noteOn(int delay, int noteNumber, int velocity) noexcept;
/** /**
* @brief Send a high-precision note on event to the synth * @brief Send a high-precision note on event to the synth
* *
@ -370,7 +370,7 @@ public:
* @param noteNumber the midi note number * @param noteNumber the midi note number
* @param velocity the midi note velocity * @param velocity the midi note velocity
*/ */
void noteOff(int delay, int noteNumber, uint8_t velocity) noexcept; void noteOff(int delay, int noteNumber, int velocity) noexcept;
/** /**
* @brief Send a high-precision note off event to the synth * @brief Send a high-precision note off event to the synth
* *
@ -388,7 +388,7 @@ public:
* @param ccNumber the cc number * @param ccNumber the cc number
* @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, int ccValue) noexcept;
/** /**
* @brief Send a high precision CC event to the synth * @brief Send a high precision CC event to the synth
* *
@ -446,7 +446,7 @@ public:
* the block in the next call to renderBlock(). * the block in the next call to renderBlock().
* @param aftertouch the aftertouch value * @param aftertouch the aftertouch value
*/ */
void aftertouch(int delay, uint8_t aftertouch) noexcept; void aftertouch(int delay, int aftertouch) noexcept;
/** /**
* @brief Send a high precision aftertouch event to the synth * @brief Send a high precision aftertouch event to the synth
* *
@ -464,6 +464,15 @@ public:
* @param secondsPerQuarter the new period of the quarter note * @param secondsPerQuarter the new period of the quarter note
*/ */
void tempo(int delay, float secondsPerQuarter) noexcept; void tempo(int delay, float secondsPerQuarter) noexcept;
/**
* @brief Send a tempo 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(), and ordered with respect to
* calls to tempo(), timeSignature(), timePosition(), and playbackState().
* @param beatsPerMinute the new tempo, in beats per minute
*/
void bpmTempo(int delay, float beatsPerMinute) noexcept;
/** /**
* @brief Send a polyphonic aftertouch event to the synth * @brief Send a polyphonic aftertouch event to the synth
* *
@ -471,7 +480,7 @@ public:
* @param noteNumber * @param noteNumber
* @param normAftertouch * @param normAftertouch
*/ */
void polyAftertouch(int delay, int noteNumber, uint8_t aftertouch) noexcept; void polyAftertouch(int delay, int noteNumber, int aftertouch) noexcept;
/** /**
* @brief Send a polyphonic aftertouch event to the synth * @brief Send a polyphonic aftertouch event to the synth
* *

View file

@ -160,7 +160,7 @@ void sfz::Sfizz::setVolume(float volume) noexcept
synth->synth.setVolume(volume); synth->synth.setVolume(volume);
} }
void sfz::Sfizz::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept void sfz::Sfizz::noteOn(int delay, int noteNumber, int velocity) noexcept
{ {
synth->synth.noteOn(delay, noteNumber, velocity); synth->synth.noteOn(delay, noteNumber, velocity);
} }
@ -170,7 +170,7 @@ void sfz::Sfizz::hdNoteOn(int delay, int noteNumber, float velocity) noexcept
synth->synth.hdNoteOn(delay, noteNumber, velocity); synth->synth.hdNoteOn(delay, noteNumber, velocity);
} }
void sfz::Sfizz::noteOff(int delay, int noteNumber, uint8_t velocity) noexcept void sfz::Sfizz::noteOff(int delay, int noteNumber, int velocity) noexcept
{ {
synth->synth.noteOff(delay, noteNumber, velocity); synth->synth.noteOff(delay, noteNumber, velocity);
} }
@ -180,7 +180,7 @@ void sfz::Sfizz::hdNoteOff(int delay, int noteNumber, float velocity) noexcept
synth->synth.hdNoteOff(delay, noteNumber, velocity); synth->synth.hdNoteOff(delay, noteNumber, velocity);
} }
void sfz::Sfizz::cc(int delay, int ccNumber, uint8_t ccValue) noexcept void sfz::Sfizz::cc(int delay, int ccNumber, int ccValue) noexcept
{ {
synth->synth.cc(delay, ccNumber, ccValue); synth->synth.cc(delay, ccNumber, ccValue);
} }
@ -205,7 +205,7 @@ void sfz::Sfizz::hdPitchWheel(int delay, float pitch) noexcept
synth->synth.hdPitchWheel(delay, pitch); synth->synth.hdPitchWheel(delay, pitch);
} }
void sfz::Sfizz::aftertouch(int delay, uint8_t aftertouch) noexcept void sfz::Sfizz::aftertouch(int delay, int aftertouch) noexcept
{ {
synth->synth.aftertouch(delay, aftertouch); synth->synth.aftertouch(delay, aftertouch);
} }
@ -215,7 +215,7 @@ void sfz::Sfizz::hdAftertouch(int delay, float aftertouch) noexcept
synth->synth.hdAftertouch(delay, aftertouch); synth->synth.hdAftertouch(delay, aftertouch);
} }
void sfz::Sfizz::polyAftertouch(int delay, int noteNumber, uint8_t aftertouch) noexcept void sfz::Sfizz::polyAftertouch(int delay, int noteNumber, int aftertouch) noexcept
{ {
synth->synth.polyAftertouch(delay, noteNumber, aftertouch); synth->synth.polyAftertouch(delay, noteNumber, aftertouch);
} }
@ -230,6 +230,11 @@ void sfz::Sfizz::tempo(int delay, float secondsPerBeat) noexcept
synth->synth.tempo(delay, secondsPerBeat); synth->synth.tempo(delay, secondsPerBeat);
} }
void sfz::Sfizz::bpmTempo(int delay, float beatsPerMinute) noexcept
{
synth->synth.bpmTempo(delay, beatsPerMinute);
}
void sfz::Sfizz::timeSignature(int delay, int beatsPerBar, int beatUnit) void sfz::Sfizz::timeSignature(int delay, int beatsPerBar, int beatUnit)
{ {
synth->synth.timeSignature(delay, beatsPerBar, beatUnit); synth->synth.timeSignature(delay, beatsPerBar, beatUnit);
@ -351,6 +356,11 @@ void sfz::Sfizz::clearExternalDefinitions()
synth->synth.getParser().clearExternalDefinitions(); synth->synth.getParser().clearExternalDefinitions();
} }
std::string sfz::Sfizz::exportMidnam(const char* model)
{
return synth->synth.exportMidnam(model);
}
const std::vector<std::pair<uint8_t, std::string>>& sfz::Sfizz::getKeyLabels() const noexcept const std::vector<std::pair<uint8_t, std::string>>& sfz::Sfizz::getKeyLabels() const noexcept
{ {
return synth->synth.getKeyLabels(); return synth->synth.getKeyLabels();

View file

@ -114,7 +114,7 @@ void sfizz_set_sample_rate(sfizz_synth_t* synth, float sample_rate)
synth->synth.setSampleRate(sample_rate); synth->synth.setSampleRate(sample_rate);
} }
void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, char velocity) void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, int velocity)
{ {
synth->synth.noteOn(delay, note_number, velocity); synth->synth.noteOn(delay, note_number, velocity);
} }
@ -122,7 +122,7 @@ void sfizz_send_hd_note_on(sfizz_synth_t* synth, int delay, int note_number, flo
{ {
synth->synth.hdNoteOn(delay, note_number, velocity); synth->synth.hdNoteOn(delay, note_number, velocity);
} }
void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, char velocity) void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, int velocity)
{ {
synth->synth.noteOff(delay, note_number, velocity); synth->synth.noteOff(delay, note_number, velocity);
} }
@ -130,7 +130,7 @@ void sfizz_send_hd_note_off(sfizz_synth_t* synth, int delay, int note_number, fl
{ {
synth->synth.hdNoteOff(delay, note_number, velocity); synth->synth.hdNoteOff(delay, note_number, velocity);
} }
void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value) void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, int cc_value)
{ {
synth->synth.cc(delay, cc_number, cc_value); synth->synth.cc(delay, cc_number, cc_value);
} }
@ -150,7 +150,7 @@ void sfizz_send_hd_pitch_wheel(sfizz_synth_t* synth, int delay, float pitch)
{ {
synth->synth.hdPitchWheel(delay, pitch); synth->synth.hdPitchWheel(delay, pitch);
} }
void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, char aftertouch) void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, int aftertouch)
{ {
synth->synth.aftertouch(delay, aftertouch); synth->synth.aftertouch(delay, aftertouch);
} }
@ -158,7 +158,7 @@ void sfizz_send_hd_aftertouch(sfizz_synth_t* synth, int delay, float aftertouch)
{ {
synth->synth.hdAftertouch(delay, aftertouch); synth->synth.hdAftertouch(delay, aftertouch);
} }
void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int delay, int note_number, char aftertouch) void sfizz_send_poly_aftertouch(sfizz_synth_t* synth, int delay, int note_number, int aftertouch)
{ {
synth->synth.polyAftertouch(delay, note_number, aftertouch); synth->synth.polyAftertouch(delay, note_number, aftertouch);
} }
@ -170,6 +170,10 @@ void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_quarter
{ {
synth->synth.tempo(delay, seconds_per_quarter); synth->synth.tempo(delay, seconds_per_quarter);
} }
void sfizz_send_bpm_tempo(sfizz_synth_t* synth, int delay, float beats_per_minute)
{
synth->synth.bpmTempo(delay, beats_per_minute);
}
void sfizz_send_time_signature(sfizz_synth_t* synth, int delay, int beats_per_bar, int beat_unit) void sfizz_send_time_signature(sfizz_synth_t* synth, int delay, int beats_per_bar, int beat_unit)
{ {
synth->synth.timeSignature(delay, beats_per_bar, beat_unit); synth->synth.timeSignature(delay, beats_per_bar, beat_unit);