Tempo API in BPM
This commit is contained in:
parent
38ada285f0
commit
ce1894ccf4
8 changed files with 77 additions and 5 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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, context.tempo);
|
||||||
|
|
||||||
if (context.state & context.kTimeSigValid) {
|
if (context.state & context.kTimeSigValid) {
|
||||||
_timeSigNumerator = context.timeSigNumerator;
|
_timeSigNumerator = context.timeSigNumerator;
|
||||||
|
|
|
||||||
26
src/sfizz.h
26
src/sfizz.h
|
|
@ -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
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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_;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue