SMF: add a set_length() method which will place TrkEnd meta-events
This commit is contained in:
parent
769920d337
commit
aa2fb8c1d4
@ -34,6 +34,7 @@
|
||||
#include "libsmf/smf.h"
|
||||
|
||||
#include "temporal/tempo.h"
|
||||
#include "temporal/beats.h"
|
||||
|
||||
#include "evoral/Event.h"
|
||||
#include "evoral/SMF.h"
|
||||
@ -528,6 +529,21 @@ SMF::end_write(string const & path)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void
|
||||
SMF::set_length (Temporal::Beats const & b)
|
||||
{
|
||||
if (!_smf) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint16_t n = 0; n < _smf->number_of_tracks; ++n) {
|
||||
smf_track_t* trk = smf_get_track_by_number (_smf, n+1);
|
||||
if (trk) {
|
||||
smf_track_add_eot_pulses (trk, (int) floor (b.get_ticks() * ((double) ppqn() / Temporal::ticks_per_beat)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
SMF::round_to_file_precision (double val) const
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ typedef smf_tempo_struct smf_tempo_t;
|
||||
|
||||
namespace Temporal {
|
||||
class TempoMap;
|
||||
class Beats;
|
||||
}
|
||||
|
||||
namespace Evoral {
|
||||
@ -89,6 +90,7 @@ public:
|
||||
void end_write(std::string const &);
|
||||
|
||||
void flush() {};
|
||||
void set_length (Temporal::Beats const &);
|
||||
|
||||
double round_to_file_precision (double val) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user