summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-01-07 00:12:07 -0500
committerDavid Robillard <d@drobilla.net>2015-01-07 00:12:07 -0500
commit2a251b457069ffb4b744fbd0dd7aca7acb31f381 (patch)
tree4311e63fe7ef1b5d7a5b841a4dd0eb7b26b324a7 /libs
parent4d202d9157bef5b6325fe54b7874080952f86a37 (diff)
MusicalTime => Beats.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/beats_frames_converter.h8
-rw-r--r--libs/ardour/ardour/legatize.h4
-rw-r--r--libs/ardour/ardour/midi_model.h8
-rw-r--r--libs/ardour/ardour/midi_operator.h4
-rw-r--r--libs/ardour/ardour/midi_playlist_source.h2
-rw-r--r--libs/ardour/ardour/midi_region.h8
-rw-r--r--libs/ardour/ardour/midi_source.h24
-rw-r--r--libs/ardour/ardour/midi_state_tracker.h2
-rw-r--r--libs/ardour/ardour/quantize.h4
-rw-r--r--libs/ardour/ardour/smf_source.h8
-rw-r--r--libs/ardour/ardour/tempo.h6
-rw-r--r--libs/ardour/ardour/transform.h8
-rw-r--r--libs/ardour/ardour/variant.h16
-rw-r--r--libs/ardour/beats_frames_converter.cc8
-rw-r--r--libs/ardour/import.cc10
-rw-r--r--libs/ardour/legatize.cc6
-rw-r--r--libs/ardour/midi_diskstream.cc4
-rw-r--r--libs/ardour/midi_model.cc18
-rw-r--r--libs/ardour/midi_playlist_source.cc2
-rw-r--r--libs/ardour/midi_region.cc24
-rw-r--r--libs/ardour/midi_source.cc16
-rw-r--r--libs/ardour/midi_state_tracker.cc6
-rw-r--r--libs/ardour/midi_stretch.cc2
-rw-r--r--libs/ardour/quantize.cc10
-rw-r--r--libs/ardour/smf_source.cc56
-rw-r--r--libs/ardour/tempo.cc20
-rw-r--r--libs/ardour/test/framepos_minus_beats_test.cc16
-rw-r--r--libs/ardour/test/framepos_plus_beats_test.cc16
-rw-r--r--libs/ardour/transform.cc2
-rw-r--r--libs/evoral/evoral/Beats.hpp247
-rw-r--r--libs/evoral/evoral/types.hpp208
-rw-r--r--libs/evoral/src/Event.cpp2
-rw-r--r--libs/evoral/src/MIDIEvent.cpp2
-rw-r--r--libs/evoral/src/Note.cpp2
-rw-r--r--libs/evoral/src/OldSMF.cpp2
-rw-r--r--libs/evoral/src/Sequence.cpp2
-rw-r--r--libs/evoral/src/TimeConverter.cpp2
-rw-r--r--libs/evoral/src/types.cpp6
-rw-r--r--libs/evoral/test/SMFTest.cpp8
-rw-r--r--libs/evoral/test/SMFTest.hpp2
-rw-r--r--libs/evoral/test/SequenceTest.cpp2
-rw-r--r--libs/evoral/test/SequenceTest.hpp4
-rw-r--r--libs/midi++2/midnam_patch.cc2
43 files changed, 425 insertions, 384 deletions
diff --git a/libs/ardour/ardour/beats_frames_converter.h b/libs/ardour/ardour/beats_frames_converter.h
index ada09b1179..908dd1909e 100644
--- a/libs/ardour/ardour/beats_frames_converter.h
+++ b/libs/ardour/ardour/beats_frames_converter.h
@@ -37,15 +37,15 @@ class TempoMap;
* them to the opposite unit, taking tempo changes into account.
*/
class LIBARDOUR_API BeatsFramesConverter
- : public Evoral::TimeConverter<Evoral::MusicalTime,framepos_t> {
+ : public Evoral::TimeConverter<Evoral::Beats,framepos_t> {
public:
BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
- : Evoral::TimeConverter<Evoral::MusicalTime, framepos_t> (origin)
+ : Evoral::TimeConverter<Evoral::Beats, framepos_t> (origin)
, _tempo_map(tempo_map)
{}
- framepos_t to (Evoral::MusicalTime beats) const;
- Evoral::MusicalTime from (framepos_t frames) const;
+ framepos_t to (Evoral::Beats beats) const;
+ Evoral::Beats from (framepos_t frames) const;
private:
TempoMap& _tempo_map;
diff --git a/libs/ardour/ardour/legatize.h b/libs/ardour/ardour/legatize.h
index 4a170e1a1c..78b384e1c7 100644
--- a/libs/ardour/ardour/legatize.h
+++ b/libs/ardour/ardour/legatize.h
@@ -39,10 +39,10 @@ public:
Legatize(bool shrink_only);
~Legatize();
- typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes;
+ typedef Evoral::Sequence<Evoral::Beats>::Notes Notes;
Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
- Evoral::MusicalTime position,
+ Evoral::Beats position,
std::vector<Notes>& seqs);
std::string name() const { return std::string ("legatize"); }
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h
index b86a7436bb..4214431280 100644
--- a/libs/ardour/ardour/midi_model.h
+++ b/libs/ardour/ardour/midi_model.h
@@ -52,9 +52,9 @@ class MidiSource;
* Because of this MIDI controllers and automatable controllers/widgets/etc
* are easily interchangeable.
*/
-class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::MusicalTime> {
+class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::Beats> {
public:
- typedef Evoral::MusicalTime TimeType;
+ typedef Evoral::Beats TimeType;
MidiModel (boost::shared_ptr<MidiSource>);
@@ -259,8 +259,8 @@ public:
bool write_section_to(boost::shared_ptr<MidiSource> source,
const Glib::Threads::Mutex::Lock& source_lock,
- Evoral::MusicalTime begin = Evoral::MinMusicalTime,
- Evoral::MusicalTime end = Evoral::MaxMusicalTime);
+ Evoral::Beats begin = Evoral::MinBeats,
+ Evoral::Beats end = Evoral::MaxBeats);
// MidiModel doesn't use the normal AutomationList serialisation code
// since controller data is stored in the .mid
diff --git a/libs/ardour/ardour/midi_operator.h b/libs/ardour/ardour/midi_operator.h
index 36e87b714b..b79544ed61 100644
--- a/libs/ardour/ardour/midi_operator.h
+++ b/libs/ardour/ardour/midi_operator.h
@@ -38,8 +38,8 @@ class LIBARDOUR_API MidiOperator {
virtual ~MidiOperator() {}
virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
- Evoral::MusicalTime,
- std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&) = 0;
+ Evoral::Beats,
+ std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&) = 0;
virtual std::string name() const = 0;
};
diff --git a/libs/ardour/ardour/midi_playlist_source.h b/libs/ardour/ardour/midi_playlist_source.h
index f064553342..6633be3c9e 100644
--- a/libs/ardour/ardour/midi_playlist_source.h
+++ b/libs/ardour/ardour/midi_playlist_source.h
@@ -45,7 +45,7 @@ public:
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
- void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev);
+ void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::Beats>& ev);
void append_event_frames(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start);
void load_model(const Glib::Threads::Mutex::Lock& lock, bool force_reload=false);
void destroy_model(const Glib::Threads::Mutex::Lock& lock);
diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h
index 2a4e3a6190..ece23b65f0 100644
--- a/libs/ardour/ardour/midi_region.h
+++ b/libs/ardour/ardour/midi_region.h
@@ -37,8 +37,8 @@ namespace ARDOUR {
MidiModel used by the MidiRegion
*/
LIBARDOUR_API extern PBD::PropertyDescriptor<void*> midi_data;
- LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats;
- LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats;
+ LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> start_beats;
+ LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> length_beats;
}
}
@@ -114,8 +114,8 @@ class LIBARDOUR_API MidiRegion : public Region
private:
friend class RegionFactory;
- PBD::Property<Evoral::MusicalTime> _start_beats;
- PBD::Property<Evoral::MusicalTime> _length_beats;
+ PBD::Property<Evoral::Beats> _start_beats;
+ PBD::Property<Evoral::Beats> _length_beats;
MidiRegion (const SourceList&);
MidiRegion (boost::shared_ptr<const MidiRegion>);
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index 2b78230a00..8a0c13681d 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -43,7 +43,7 @@ template<typename T> class MidiRingBuffer;
class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_shared_from_this<MidiSource>
{
public:
- typedef Evoral::MusicalTime TimeType;
+ typedef Evoral::Beats TimeType;
MidiSource (Session& session, std::string name, Source::Flag flags = Source::Flag(0));
MidiSource (Session& session, const XMLNode&);
@@ -59,8 +59,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
*/
int write_to (const Lock& lock,
boost::shared_ptr<MidiSource> newsrc,
- Evoral::MusicalTime begin = Evoral::MinMusicalTime,
- Evoral::MusicalTime end = Evoral::MaxMusicalTime);
+ Evoral::Beats begin = Evoral::MinBeats,
+ Evoral::Beats end = Evoral::MaxBeats);
/** Read the data in a given time range from the MIDI source.
* All time stamps in parameters are in audio frames (even if the source has tempo time).
@@ -93,8 +93,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
*
* Caller must ensure that the event is later than the last written event.
*/
- virtual void append_event_beats(const Lock& lock,
- const Evoral::Event<Evoral::MusicalTime>& ev) = 0;
+ virtual void append_event_beats(const Lock& lock,
+ const Evoral::Event<Evoral::Beats>& ev) = 0;
/** Append a single event with a timestamp in frames.
*
@@ -132,9 +132,9 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
* etc.
*/
virtual void mark_midi_streaming_write_completed (
- const Lock& lock,
- Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_option,
- Evoral::MusicalTime when = Evoral::MusicalTime());
+ const Lock& lock,
+ Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_option,
+ Evoral::Beats when = Evoral::Beats());
virtual void session_saved();
@@ -205,11 +205,11 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha
boost::shared_ptr<MidiModel> _model;
bool _writing;
- mutable Evoral::Sequence<Evoral::MusicalTime>::const_iterator _model_iter;
- mutable bool _model_iter_valid;
+ mutable Evoral::Sequence<Evoral::Beats>::const_iterator _model_iter;
+ mutable bool _model_iter_valid;
- mutable Evoral::MusicalTime _length_beats;
- mutable framepos_t _last_read_end;
+ mutable Evoral::Beats _length_beats;
+ mutable framepos_t _last_read_end;
/** The total duration of the current capture. */
framepos_t _capture_length;
diff --git a/libs/ardour/ardour/midi_state_tracker.h b/libs/ardour/ardour/midi_state_tracker.h
index 98611bc722..6690931422 100644
--- a/libs/ardour/ardour/midi_state_tracker.h
+++ b/libs/ardour/ardour/midi_state_tracker.h
@@ -46,7 +46,7 @@ public:
void remove (uint8_t note, uint8_t chn);
void resolve_notes (MidiBuffer& buffer, framepos_t time);
void resolve_notes (Evoral::EventSink<framepos_t>& buffer, framepos_t time);
- void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::MusicalTime time);
+ void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::Beats time);
void dump (std::ostream&);
void reset ();
bool empty() const { return _on == 0; }
diff --git a/libs/ardour/ardour/quantize.h b/libs/ardour/ardour/quantize.h
index 09ba5f2aa2..639736b174 100644
--- a/libs/ardour/ardour/quantize.h
+++ b/libs/ardour/ardour/quantize.h
@@ -35,8 +35,8 @@ public:
~Quantize ();
Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
- Evoral::MusicalTime position,
- std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&);
+ Evoral::Beats position,
+ std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&);
std::string name() const { return std::string ("quantize"); }
private:
diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h
index d93fdb8506..29c6403694 100644
--- a/libs/ardour/ardour/smf_source.h
+++ b/libs/ardour/ardour/smf_source.h
@@ -51,14 +51,14 @@ public:
return safe_midi_file_extension(path);
}
- void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev);
+ void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::Beats>& ev);
void append_event_frames (const Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start);
void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode);
void mark_streaming_write_completed (const Lock& lock);
void mark_midi_streaming_write_completed (const Lock& lock,
- Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption,
- Evoral::MusicalTime when = Evoral::MusicalTime());
+ Evoral::Sequence<Evoral::Beats>::StuckNoteOption,
+ Evoral::Beats when = Evoral::Beats());
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
@@ -77,7 +77,7 @@ public:
private:
bool _open;
- Evoral::MusicalTime _last_ev_time_beats;
+ Evoral::Beats _last_ev_time_beats;
framepos_t _last_ev_time_frames;
/** end time (start + duration) of last call to read_unlocked */
mutable framepos_t _smf_last_read_end;
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index 19fe5b0b12..f2d314651d 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -276,9 +276,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
*/
framepos_t framepos_plus_bbt (framepos_t pos, Timecode::BBT_Time b) const;
- framepos_t framepos_plus_beats (framepos_t, Evoral::MusicalTime) const;
- framepos_t framepos_minus_beats (framepos_t, Evoral::MusicalTime) const;
- Evoral::MusicalTime framewalk_to_beats (framepos_t pos, framecnt_t distance) const;
+ framepos_t framepos_plus_beats (framepos_t, Evoral::Beats) const;
+ framepos_t framepos_minus_beats (framepos_t, Evoral::Beats) const;
+ Evoral::Beats framewalk_to_beats (framepos_t pos, framecnt_t distance) const;
static const Tempo& default_tempo() { return _default_tempo; }
static const Meter& default_meter() { return _default_meter; }
diff --git a/libs/ardour/ardour/transform.h b/libs/ardour/ardour/transform.h
index 08e4a43521..df77244a17 100644
--- a/libs/ardour/ardour/transform.h
+++ b/libs/ardour/ardour/transform.h
@@ -50,9 +50,9 @@ namespace ARDOUR {
*/
class LIBARDOUR_API Transform : public MidiOperator {
public:
- typedef Evoral::Sequence<Evoral::MusicalTime>::NotePtr NotePtr;
- typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes;
- typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
+ typedef Evoral::Sequence<Evoral::Beats>::NotePtr NotePtr;
+ typedef Evoral::Sequence<Evoral::Beats>::Notes Notes;
+ typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
/** Context while iterating over notes during transformation. */
struct Context {
@@ -132,7 +132,7 @@ public:
Transform(const Program& prog);
Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
- Evoral::MusicalTime position,
+ Evoral::Beats position,
std::vector<Notes>& seqs);
std::string name() const { return std::string ("transform"); }
diff --git a/libs/ardour/ardour/variant.h b/libs/ardour/ardour/variant.h
index 0402ffaa0b..9ecadbfe6a 100644
--- a/libs/ardour/ardour/variant.h
+++ b/libs/ardour/ardour/variant.h
@@ -57,7 +57,7 @@ public:
explicit Variant(int32_t value) : _type(INT) { _int = value; }
explicit Variant(int64_t value) : _type(LONG) { _long = value; }
- explicit Variant(const Evoral::MusicalTime& beats)
+ explicit Variant(const Evoral::Beats& beats)
: _type(BEATS)
, _beats(beats)
{}
@@ -94,7 +94,7 @@ public:
std::min(value, (double)INT64_MAX)));
break;
case BEATS:
- _beats = Evoral::MusicalTime(value);
+ _beats = Evoral::Beats(value);
break;
default:
_type = NOTHING;
@@ -158,19 +158,19 @@ public:
return false;
}
- bool operator==(const Evoral::MusicalTime& v) const {
+ bool operator==(const Evoral::Beats& v) const {
return _type == BEATS && _beats == v;
}
bool operator!() const { return _type == NOTHING; }
- Variant& operator=(Evoral::MusicalTime v) {
+ Variant& operator=(Evoral::Beats v) {
_type = BEATS;
_beats = v;
return *this;
}
- const Evoral::MusicalTime& get_beats() const {
+ const Evoral::Beats& get_beats() const {
ensure_type(BEATS); return _beats;
}
@@ -202,9 +202,9 @@ private:
}
}
- Type _type; ///< Type tag
- std::string _string; ///< PATH, STRING, URI
- Evoral::MusicalTime _beats; ///< BEATS
+ Type _type; ///< Type tag
+ std::string _string; ///< PATH, STRING, URI
+ Evoral::Beats _beats; ///< BEATS
// Union of all primitive numeric types
union {
diff --git a/libs/ardour/beats_frames_converter.cc b/libs/ardour/beats_frames_converter.cc
index b99edbf51e..54db8008da 100644
--- a/libs/ardour/beats_frames_converter.cc
+++ b/libs/ardour/beats_frames_converter.cc
@@ -31,9 +31,9 @@ namespace ARDOUR {
* taking tempo changes into account.
*/
framepos_t
-BeatsFramesConverter::to (Evoral::MusicalTime beats) const
+BeatsFramesConverter::to (Evoral::Beats beats) const
{
- if (beats < Evoral::MusicalTime()) {
+ if (beats < Evoral::Beats()) {
std::cerr << "negative beats passed to BFC: " << beats << std::endl;
PBD::stacktrace (std::cerr, 30);
return 0;
@@ -45,7 +45,7 @@ BeatsFramesConverter::to (Evoral::MusicalTime beats) const
* supplied to the constructor. Returns the equivalent number of beats,
* taking tempo changes into account.
*/
-Evoral::MusicalTime
+Evoral::Beats
BeatsFramesConverter::from (framepos_t frames) const
{
return _tempo_map.framewalk_to_beats (_origin_b, frames);
@@ -60,7 +60,7 @@ DoubleBeatsFramesConverter::to (double beats) const
PBD::stacktrace (std::cerr, 30);
return 0;
}
- return _tempo_map.framepos_plus_beats (_origin_b, Evoral::MusicalTime(beats)) - _origin_b;
+ return _tempo_map.framepos_plus_beats (_origin_b, Evoral::Beats(beats)) - _origin_b;
}
/** As above, but with beats in double instead (for GUI). */
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index eb2ed769d1..3ed028ef91 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -392,9 +392,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
smfs->append_event_beats(
source_lock,
- Evoral::Event<Evoral::MusicalTime>(
+ Evoral::Event<Evoral::Beats>(
0,
- Evoral::MusicalTime::ticks_at_rate(t, source->ppqn()),
+ Evoral::Beats::ticks_at_rate(t, source->ppqn()),
size,
buf));
@@ -407,9 +407,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
/* we wrote something */
- const framepos_t pos = 0;
- const Evoral::MusicalTime length_beats = Evoral::MusicalTime::ticks_at_rate(t, source->ppqn());
- BeatsFramesConverter converter(smfs->session().tempo_map(), pos);
+ const framepos_t pos = 0;
+ const Evoral::Beats length_beats = Evoral::Beats::ticks_at_rate(t, source->ppqn());
+ BeatsFramesConverter converter(smfs->session().tempo_map(), pos);
smfs->update_length(pos + converter.to(length_beats.round_up_to_beat()));
smfs->mark_streaming_write_completed (source_lock);
diff --git a/libs/ardour/legatize.cc b/libs/ardour/legatize.cc
index c5506fe6c0..0c118a6a48 100644
--- a/libs/ardour/legatize.cc
+++ b/libs/ardour/legatize.cc
@@ -31,7 +31,7 @@ Legatize::~Legatize ()
Command*
Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
- Evoral::MusicalTime position,
+ Evoral::Beats position,
std::vector<Legatize::Notes>& seqs)
{
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand(model, "legatize");
@@ -43,10 +43,10 @@ Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model,
break;
}
- const Evoral::MusicalTime new_end = (*next)->time() - Evoral::MusicalTime::tick();
+ const Evoral::Beats new_end = (*next)->time() - Evoral::Beats::tick();
if ((*i)->end_time() > new_end ||
(!_shrink_only && (*i)->end_time() < new_end)) {
- const Evoral::MusicalTime new_length(new_end - (*i)->time());
+ const Evoral::Beats new_length(new_end - (*i)->time());
cmd->change((*i), MidiModel::NoteDiffCommand::Length, new_length);
}
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index e52a7c3ad7..fed0dbc0ce 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -940,14 +940,14 @@ MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen
/* set length in beats to entire capture length */
BeatsFramesConverter converter (_session.tempo_map(), capture_info.front()->start);
- const Evoral::MusicalTime total_capture_beats = converter.from (total_capture);
+ const Evoral::Beats total_capture_beats = converter.from (total_capture);
_write_source->set_length_beats (total_capture_beats);
/* flush to disk: this step differs from the audio path,
where all the data is already on disk.
*/
- _write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, total_capture_beats);
+ _write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, total_capture_beats);
/* we will want to be able to keep (over)writing the source
but we don't want it to be removable. this also differs
diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc
index 18378f5386..e3226e036f 100644
--- a/libs/ardour/midi_model.cc
+++ b/libs/ardour/midi_model.cc
@@ -620,7 +620,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change)
if ((prop = xml_change->property ("old")) != 0) {
istringstream old_str (prop->value());
if (change.property == StartTime || change.property == Length) {
- Evoral::MusicalTime old_time;
+ Evoral::Beats old_time;
old_str >> old_time;
change.old_value = old_time;
} else {
@@ -636,7 +636,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change)
if ((prop = xml_change->property ("new")) != 0) {
istringstream new_str (prop->value());
if (change.property == StartTime || change.property == Length) {
- Evoral::MusicalTime new_time;
+ Evoral::Beats new_time;
new_str >> new_time;
change.new_value = Variant(new_time);
} else {
@@ -1237,7 +1237,7 @@ MidiModel::PatchChangeDiffCommand::unmarshal_patch_change (XMLNode* n)
{
XMLProperty* prop;
Evoral::event_id_t id = 0;
- Evoral::MusicalTime time = Evoral::MusicalTime();
+ Evoral::Beats time = Evoral::Beats();
int channel = 0;
int program = 0;
int bank = 0;
@@ -1476,8 +1476,8 @@ MidiModel::sync_to_source (const Glib::Threads::Mutex::Lock& source_lock)
bool
MidiModel::write_section_to (boost::shared_ptr<MidiSource> source,
const Glib::Threads::Mutex::Lock& source_lock,
- Evoral::MusicalTime begin_time,
- Evoral::MusicalTime end_time)
+ Evoral::Beats begin_time,
+ Evoral::Beats end_time)
{
ReadLock lock(read_lock());
MidiStateTracker mst;
@@ -1489,12 +1489,12 @@ MidiModel::write_section_to (boost::shared_ptr<MidiSource> source,
source->mark_streaming_midi_write_started (source_lock, note_mode());
for (Evoral::Sequence<TimeType>::const_iterator i = begin(TimeType(), true); i != end(); ++i) {
- const Evoral::Event<Evoral::MusicalTime>& ev (*i);
+ const Evoral::Event<Evoral::Beats>& ev (*i);
if (ev.time() >= begin_time && ev.time() < end_time) {
- const Evoral::MIDIEvent<Evoral::MusicalTime>* mev =
- static_cast<const Evoral::MIDIEvent<Evoral::MusicalTime>* > (&ev);
+ const Evoral::MIDIEvent<Evoral::Beats>* mev =
+ static_cast<const Evoral::MIDIEvent<Evoral::Beats>* > (&ev);
if (!mev) {
continue;
@@ -2026,7 +2026,7 @@ MidiModel::transpose (TimeType from, TimeType to, int semitones)
void
MidiModel::control_list_marked_dirty ()
{
- AutomatableSequence<Evoral::MusicalTime>::control_list_marked_dirty ();
+ AutomatableSequence<Evoral::Beats>::control_list_marked_dirty ();
ContentsChanged (); /* EMIT SIGNAL */
}
diff --git a/libs/ardour/midi_playlist_source.cc b/libs/ardour/midi_playlist_source.cc
index 587bc7b12f..4f474f7119 100644
--- a/libs/ardour/midi_playlist_source.cc
+++ b/libs/ardour/midi_playlist_source.cc
@@ -149,7 +149,7 @@ MidiPlaylistSource::write_unlocked (const Lock&,
}
void
-MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::MusicalTime>& /*ev*/)
+MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::Beats>& /*ev*/)
{
fatal << string_compose (_("programming error: %1"), "MidiPlaylistSource::append_event_beats() called - should be impossible") << endmsg;
abort(); /*NOTREACHED*/
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc
index 62c642d57b..c02caff470 100644
--- a/libs/ardour/midi_region.cc
+++ b/libs/ardour/midi_region.cc
@@ -53,9 +53,9 @@ using namespace PBD;
namespace ARDOUR {
namespace Properties {
- PBD::PropertyDescriptor<void*> midi_data;
- PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats;
- PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats;
+ PBD::PropertyDescriptor<void*> midi_data;
+ PBD::PropertyDescriptor<Evoral::Beats> start_beats;
+ PBD::PropertyDescriptor<Evoral::Beats> length_beats;
}
}
@@ -80,7 +80,7 @@ MidiRegion::register_properties ()
/* Basic MidiRegion constructor (many channels) */
MidiRegion::MidiRegion (const SourceList& srcs)
: Region (srcs)
- , _start_beats (Properties::start_beats, Evoral::MusicalTime())
+ , _start_beats (Properties::start_beats, Evoral::Beats())
, _length_beats (Properties::length_beats, midi_source(0)->length_beats())
{
register_properties ();
@@ -94,7 +94,7 @@ MidiRegion::MidiRegion (const SourceList& srcs)
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
: Region (other)
, _start_beats (Properties::start_beats, other->_start_beats)
- , _length_beats (Properties::length_beats, Evoral::MusicalTime())
+ , _length_beats (Properties::length_beats, Evoral::Beats())
{
update_length_beats ();
register_properties ();
@@ -107,11 +107,11 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
/** Create a new MidiRegion that is part of an existing one */
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset)
: Region (other, offset)
- , _start_beats (Properties::start_beats, Evoral::MusicalTime())
- , _length_beats (Properties::length_beats, Evoral::MusicalTime())
+ , _start_beats (Properties::start_beats, Evoral::Beats())
+ , _length_beats (Properties::length_beats, Evoral::Beats())
{
BeatsFramesConverter bfc (_session.tempo_map(), _position);
- Evoral::MusicalTime const offset_beats = bfc.from (offset);
+ Evoral::Beats const offset_beats = bfc.from (offset);
_start_beats = other->_start_beats.val() + offset_beats;
_length_beats = other->_length_beats.val() - offset_beats;
@@ -147,8 +147,8 @@ boost::shared_ptr<MidiRegion>
MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const
{
BeatsFramesConverter bfc (_session.tempo_map(), _position);
- Evoral::MusicalTime const bbegin = bfc.from (_start);
- Evoral::MusicalTime const bend = bfc.from (_start + _length);
+ Evoral::Beats const bbegin = bfc.from (_start);
+ Evoral::Beats const bend = bfc.from (_start + _length);
{
/* Lock our source since we'll be reading from it. write_to() will
@@ -223,7 +223,7 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
/* zero length regions don't exist - so if _length_beats is zero, this object
is under construction.
*/
- if (_length_beats.val() == Evoral::MusicalTime()) {
+ if (_length_beats.val() == Evoral::Beats()) {
/* leave _length_beats alone, and change _length to reflect the state of things
at the new position (tempo map may dictate a different number of frames
*/
@@ -462,7 +462,7 @@ MidiRegion::fix_negative_start ()
model()->insert_silence_at_start (c.from (-_start));
_start = 0;
- _start_beats = Evoral::MusicalTime();
+ _start_beats = Evoral::Beats();
}
/** Transpose the notes in this region by a given number of semitones */
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc
index 0c08adf4a5..8d3b130594 100644
--- a/libs/ardour/midi_source.cc
+++ b/libs/ardour/midi_source.cc
@@ -200,7 +200,7 @@ MidiSource::midi_read (const Lock& lm,
if (_model) {
// Find appropriate model iterator
- Evoral::Sequence<Evoral::MusicalTime>::const_iterator& i = _model_iter;
+ Evoral::Sequence<Evoral::Beats>::const_iterator& i = _model_iter;
if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) {
// Cached iterator is invalid, search for the first event past start
i = _model->begin(converter.from(start), false, filtered);
@@ -297,9 +297,9 @@ MidiSource::mark_streaming_write_started (const Lock& lock)
}
void
-MidiSource::mark_midi_streaming_write_completed (const Lock& lock,
- Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption option,
- Evoral::MusicalTime end)
+MidiSource::mark_midi_streaming_write_completed (const Lock& lock,
+ Evoral::Sequence<Evoral::Beats>::StuckNoteOption option,
+ Evoral::Beats end)
{
if (_model) {
_model->end_write (option, end);
@@ -320,11 +320,11 @@ MidiSource::mark_midi_streaming_write_completed (const Lock&
void
MidiSource::mark_streaming_write_completed (const Lock& lock)
{
- mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
+ mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
}
int
-MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end)
+MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::Beats begin, Evoral::Beats end)
{
Lock newsrc_lock (newsrc->mutex ());
@@ -333,7 +333,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev
newsrc->copy_automation_state_from (this);
if (_model) {
- if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) {
+ if (begin == Evoral::MinBeats && end == Evoral::MaxBeats) {
_model->write_to (newsrc, newsrc_lock);
} else {
_model->write_section_to (newsrc, newsrc_lock, begin, end);
@@ -347,7 +347,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev
/* force a reload of the model if the range is partial */
- if (begin != Evoral::MinMusicalTime || end != Evoral::MaxMusicalTime) {
+ if (begin != Evoral::MinBeats || end != Evoral::MaxBeats) {
newsrc->load_model (newsrc_lock, true);
} else {
newsrc->set_model (newsrc_lock, _model);
diff --git a/libs/ardour/midi_state_tracker.cc b/libs/ardour/midi_state_tracker.cc
index f919a02f35..9e96c4954f 100644
--- a/libs/ardour/midi_state_tracker.cc
+++ b/libs/ardour/midi_state_tracker.cc
@@ -168,7 +168,7 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
}
void
-MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::MusicalTime time)
+MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::Beats time)
{
DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on));
@@ -181,7 +181,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
for (int channel = 0; channel < 16; ++channel) {
for (int note = 0; note < 128; ++note) {
while (_active_notes[note + 128 * channel]) {
- Evoral::MIDIEvent<Evoral::MusicalTime> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
+ Evoral::MIDIEvent<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
ev.set_type (MIDI_CMD_NOTE_OFF);
ev.set_channel (channel);
ev.set_note (note);
@@ -191,7 +191,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
this, (int) note, (int) channel, time));
_active_notes[note + 128 * channel]--;
/* don't stack events up at the same time */
- time += Evoral::MusicalTime::tick();
+ time += Evoral::Beats::tick();
}
}
}
diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc
index 05635600d7..71ffcc21e1 100644
--- a/libs/ardour/midi_stretch.cc
+++ b/libs/ardour/midi_stretch.cc
@@ -108,7 +108,7 @@ MidiStretch::run (boost::shared_ptr<Region> r, Progress*)
new_model->append(ev, Evoral::next_event_id());
}
- new_model->end_write (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
+ new_model->end_write (Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
new_model->set_edited (true);
new_src->copy_interpolation_from (src);
diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc
index dc1976e9ff..6604469007 100644
--- a/libs/ardour/quantize.cc
+++ b/libs/ardour/quantize.cc
@@ -54,8 +54,8 @@ Quantize::~Quantize ()
Command*
Quantize::operator () (boost::shared_ptr<MidiModel> model,
- Evoral::MusicalTime position,
- std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs)
+ Evoral::Beats position,
+ std::vector<Evoral::Sequence<Evoral::Beats>::Notes>& seqs)
{
/* TODO: Rewrite this to be precise with fixed point? */
@@ -69,7 +69,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
bool even;
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize");
- for (std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
+ for (std::vector<Evoral::Sequence<Evoral::Beats>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
even = false;
@@ -119,10 +119,10 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
delta = new_end - (*i)->end_time().to_double();
if (fabs (delta) >= _threshold) {
- Evoral::MusicalTime new_dur(new_end - new_start);
+ Evoral::Beats new_dur(new_end - new_start);
if (!new_dur) {
- new_dur = Evoral::MusicalTime(_end_grid);
+ new_dur = Evoral::Beats(_end_grid);
}
cmd->change ((*i), MidiModel::NoteDiffCommand::Length, new_dur);
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index d1a82eb685..7f5e8059c9 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -278,7 +278,7 @@ SMFSource::read_unlocked (const Lock& lock,
/* Note that we add on the source start time (in session frames) here so that ev_frame_time
is in session frames.
*/
- const framepos_t ev_frame_time = converter.to(Evoral::MusicalTime::ticks_at_rate(time, ppqn())) + source_start;
+ const framepos_t ev_frame_time = converter.to(Evoral::Beats::ticks_at_rate(time, ppqn())) + source_start;
if (ev_frame_time < start + duration) {
destination.write (ev_frame_time, ev_type, ev_size, ev_buffer);
@@ -380,8 +380,8 @@ SMFSource::write_unlocked (const Lock& lock,
/** Append an event with a timestamp in beats */
void
-SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
- const Evoral::Event<Evoral::MusicalTime>& ev)
+SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
+ const Evoral::Event<Evoral::Beats>& ev)
{
if (!_writing || ev.size() == 0) {
return;
@@ -391,9 +391,9 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
name().c_str(), ev.id(), ev.time(), ev.size());
for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n");*/
- Evoral::MusicalTime time = ev.time();
+ Evoral::Beats time = ev.time();
if (time < _last_ev_time_beats) {
- const Evoral::MusicalTime difference = _last_ev_time_beats - time;
+ const Evoral::Beats difference = _last_ev_time_beats - time;
if (difference.to_double() / (double)ppqn() < 1.0) {
/* Close enough. This problem occurs because Sequence is not
actually ordered due to fuzzy time comparison. I'm pretty sure
@@ -423,8 +423,8 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
_length_beats = max(_length_beats, time);
- const Evoral::MusicalTime delta_time_beats = time - _last_ev_time_beats;
- const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
+ const Evoral::Beats delta_time_beats = time - _last_ev_time_beats;
+ const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id);
_last_ev_time_beats = time;
@@ -452,9 +452,9 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock,
return;
}
- BeatsFramesConverter converter(_session.tempo_map(), position);
- const Evoral::MusicalTime ev_time_beats = converter.from(ev.time());
- Evoral::event_id_t event_id;
+ BeatsFramesConverter converter(_session.tempo_map(), position);
+ const Evoral::Beats ev_time_beats = converter.from(ev.time());
+ Evoral::event_id_t event_id;
if (ev.id() < 0) {
event_id = Evoral::next_event_id();
@@ -463,18 +463,18 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock,
}
if (_model) {
- const Evoral::Event<Evoral::MusicalTime> beat_ev (ev.event_type(),
- ev_time_beats,
- ev.size(),
- const_cast<uint8_t*>(ev.buffer()));
+ const Evoral::Event<Evoral::Beats> beat_ev (ev.event_type(),
+ ev_time_beats,
+ ev.size(),
+ const_cast<uint8_t*>(ev.buffer()));
_model->append (beat_ev, event_id);
}
_length_beats = max(_length_beats, ev_time_beats);
- const Evoral::MusicalTime last_time_beats = converter.from (_last_ev_time_frames);
- const Evoral::MusicalTime delta_time_beats = ev_time_beats - last_time_beats;
- const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
+ const Evoral::Beats last_time_beats = converter.from (_last_ev_time_frames);
+ const Evoral::Beats delta_time_beats = ev_time_beats - last_time_beats;
+ const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn());
Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id);
_last_ev_time_frames = ev.time();
@@ -518,18 +518,18 @@ SMFSource::mark_streaming_midi_write_started (const Lock& lock, NoteMode mode)
MidiSource::mark_streaming_midi_write_started (lock, mode);
Evoral::SMF::begin_write ();
- _last_ev_time_beats = Evoral::MusicalTime();
+ _last_ev_time_beats = Evoral::Beats();
_last_ev_time_frames = 0;
}
void
SMFSource::mark_streaming_write_completed (const Lock& lock)
{
- mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
+ mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
}
void
-SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_notes_option, Evoral::MusicalTime when)
+SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_notes_option, Evoral::Beats when)
{
MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when);
@@ -587,8 +587,8 @@ SMFSource::safe_midi_file_extension (const string& file)
}
static bool compare_eventlist (
- const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& a,
- const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& b) {
+ const std::pair< Evoral::Event<Evoral::Beats>*, gint >& a,
+ const std::pair< Evoral::Event<Evoral::Beats>*, gint >& b) {
return ( a.first->time() < b.first->time() );
}
@@ -619,7 +619,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
Evoral::SMF::seek_to_start();
uint64_t time = 0; /* in SMF ticks */
- Evoral::Event<Evoral::MusicalTime> ev;
+ Evoral::Event<Evoral::Beats> ev;
uint32_t scratch_size = 0; // keep track of scratch and minimize reallocs
@@ -631,7 +631,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
bool have_event_id;
// TODO simplify event allocation
- std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > > eventlist;
+ std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > > eventlist;
for (unsigned i = 1; i <= num_tracks(); ++i) {
if (seek_to_track(i)) continue;
@@ -658,7 +658,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
event_id = Evoral::next_event_id();
}
const uint32_t event_type = midi_parameter_type(buf[0]);
- const Evoral::MusicalTime event_time = Evoral::MusicalTime::ticks_at_rate(time, ppqn());
+ const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn());
#ifndef NDEBUG
std::string ss;
@@ -673,7 +673,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
#endif
eventlist.push_back(make_pair (
- new Evoral::Event<Evoral::MusicalTime> (
+ new Evoral::Event<Evoral::Beats> (
event_type, event_time,
size, buf, true)
, event_id));
@@ -692,13 +692,13 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
eventlist.sort(compare_eventlist);
- std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > >::iterator it;
+ std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > >::iterator it;
for (it=eventlist.begin(); it!=eventlist.end(); ++it) {
_model->append (*it->first, it->second);
delete it->first;
}
- _model->end_write (Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, _length_beats);
+ _model->end_write (Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, _length_beats);
_model->set_edited (false);
invalidate(lock);
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 486cbb0643..dfcc264547 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1841,7 +1841,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount)
* pos can be -ve, if required.
*/
framepos_t
-TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const
+TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics::const_iterator next_tempo;
@@ -1891,11 +1891,11 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const
framecnt_t distance_frames = (next_tempo == metrics.end() ? max_framepos : ((*next_tempo)->frame() - pos));
/* Distance to the end in beats */
- Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate(
+ Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate(
distance_frames, tempo->frames_per_beat (_frame_rate));
/* Amount to subtract this time */
- Evoral::MusicalTime const delta = min (distance_beats, beats);
+ Evoral::Beats const delta = min (distance_beats, beats);
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n",
(next_tempo == metrics.end() ? max_framepos : (*next_tempo)->frame()),
@@ -1933,7 +1933,7 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const
/** Subtract some (fractional) beats from a frame position, and return the result in frames */
framepos_t
-TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
+TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics::const_reverse_iterator prev_tempo;
@@ -2000,11 +2000,11 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
framecnt_t distance_frames = (pos - tempo->frame());
/* Distance to the start in beats */
- Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate(
+ Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate(
distance_frames, tempo->frames_per_beat (_frame_rate));
/* Amount to subtract this time */
- Evoral::MusicalTime const sub = min (distance_beats, beats);
+ Evoral::Beats const sub = min (distance_beats, beats);
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n",
tempo->frame(), distance_frames, distance_beats));
@@ -2037,7 +2037,7 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
}
} else {
pos -= llrint (beats.to_double() * tempo->frames_per_beat (_frame_rate));
- beats = Evoral::MusicalTime();
+ beats = Evoral::Beats();
}
}
@@ -2183,7 +2183,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
/** Count the number of beats that are equivalent to distance when going forward,
starting at pos.
*/
-Evoral::MusicalTime
+Evoral::Beats
TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
@@ -2218,7 +2218,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
string_compose ("frame %1 walk by %2 frames, start with tempo = %3 @ %4\n",
pos, distance, *((const Tempo*)tempo), tempo->frame()));
- Evoral::MusicalTime beats = Evoral::MusicalTime();
+ Evoral::Beats beats = Evoral::Beats();
while (distance) {
@@ -2246,7 +2246,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
pos += sub;
distance -= sub;
assert (tempo);
- beats += Evoral::MusicalTime::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate));
+ beats += Evoral::Beats::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate));
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("now at %1, beats = %2 distance left %3\n",
pos, beats, distance));
diff --git a/libs/ardour/test/framepos_minus_beats_test.cc b/libs/ardour/test/framepos_minus_beats_test.cc
index e4c4844146..cc6341fb0b 100644
--- a/libs/ardour/test/framepos_minus_beats_test.cc
+++ b/libs/ardour/test/framepos_minus_beats_test.cc
@@ -26,11 +26,11 @@ FrameposMinusBeatsTest::singleTempoTest ()
map.add_tempo (tempo, BBT_Time (1, 1, 0));
/* Subtract 1 beat from beat 3 of the first bar */
- framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, MusicalTime(1));
+ framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (frames_per_beat * 1));
/* Subtract 4 beats from 3 beats in, to go beyond zero */
- r = map.framepos_minus_beats (frames_per_beat * 3, MusicalTime(4));
+ r = map.framepos_minus_beats (frames_per_beat * 3, Beats(4));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (- frames_per_beat));
}
@@ -70,15 +70,15 @@ FrameposMinusBeatsTest::doubleTempoTest ()
/* Now some tests */
/* Subtract 1 beat from 1|2 */
- framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1));
+ framepos_t r = map.framepos_minus_beats (24e3, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (0));
/* Subtract 2 beats from 4|2 (over the tempo change) */
- r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2));
+ r = map.framepos_minus_beats (288e3 + 12e3, Beats(2));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3));
/* Subtract 2.5 beats from 4|2 (over the tempo change) */
- r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5));
+ r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3));
}
@@ -124,15 +124,15 @@ FrameposMinusBeatsTest::doubleTempoWithMeterTest ()
/* Now some tests */
/* Subtract 1 beat from 1|2 */
- framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1));
+ framepos_t r = map.framepos_minus_beats (24e3, Beats(1));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (0));
/* Subtract 2 beats from 4|2 (over the tempo change) */
- r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2));
+ r = map.framepos_minus_beats (288e3 + 12e3, Beats(2));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3));
/* Subtract 2.5 beats from 4|2 (over the tempo change) */
- r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5));
+ r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5));
CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3));
}
diff --git a/libs/ardour/test/framepos_plus_beats_test.cc b/libs/ardour/test/framepos_plus_beats_test.cc
index abe1310f62..efc57c5872 100644
--- a/libs/ardour/test/framepos_plus_beats_test.cc
+++ b/libs/ardour/test/framepos_plus_beats_test.cc
@@ -25,11 +25,11 @@ FrameposPlusBeatsTest::singleTempoTest ()
map.add_tempo (tempo, BBT_Time (1, 1, 0));
/* Add 1 beat to beat 3 of the first bar */
- framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::MusicalTime(1));
+ framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r);
/* Add 4 beats to a -ve frame of 1 beat before zero */
- r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::MusicalTime(4));
+ r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::Beats(4));
CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r);
}
@@ -69,15 +69,15 @@ FrameposPlusBeatsTest::doubleTempoTest ()
/* Now some tests */
/* Add 1 beat to 1|2 */
- framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1));
+ framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r);
/* Add 2 beats to 3|4 (over the tempo change) */
- r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2));
+ r = map.framepos_plus_beats (264e3, Evoral::Beats(2));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
/* Add 2.5 beats to 3|3|960 (over the tempo change) */
- r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5));
+ r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
}
@@ -123,15 +123,15 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest ()
/* Now some tests */
/* Add 1 beat to 1|2 */
- framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1));
+ framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1));
CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r);
/* Add 2 beats to 3|4 (over the tempo change) */
- r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2));
+ r = map.framepos_plus_beats (264e3, Evoral::Beats(2));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
/* Add 2.5 beats to 3|3|960 (over the tempo change) */
- r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5));
+ r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5));
CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r);
}
diff --git a/libs/ardour/transform.cc b/libs/ardour/transform.cc
index 3b4f53c860..9f029829de 100644
--- a/libs/ardour/transform.cc
+++ b/libs/ardour/transform.cc
@@ -121,7 +121,7 @@ Transform::Operation::eval(Context& ctx) const
Command*
Transform::operator()(boost::shared_ptr<MidiModel> model,
- Evoral::MusicalTime position,
+ Evoral::Beats position,
std::vector<Notes>& seqs)
{
typedef MidiModel::NoteDiffCommand Command;
diff --git a/libs/evoral/evoral/Beats.hpp b/libs/evoral/evoral/Beats.hpp
new file mode 100644
index 0000000000..e0277c4b3d
--- /dev/null
+++ b/libs/evoral/evoral/Beats.hpp
@@ -0,0 +1,247 @@
+/* This file is part of Evoral.
+ * Copyright (C) 2008-2015 David Robillard <http://drobilla.net>
+ * Copyright (C) 2000-2008 Paul Davis
+ *
+ * Evoral is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef EVORAL_BEATS_HPP
+#define EVORAL_BEATS_HPP
+
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+
+#include <iostream>
+#include <limits>
+
+#include "evoral/visibility.h"
+
+namespace Evoral {
+
+/** Musical time in beats. */
+class /*LIBEVORAL_API*/ Beats {
+public:
+ LIBEVORAL_API static const double PPQN;
+
+ Beats() : _time(0.0) {}
+
+ /** Create from a real number of beats. */
+ explicit Beats(double time) : _time(time) {}
+
+ /** Create from an integer number of beats. */
+ static Beats beats(int32_t beats) {
+ return Beats((double)beats);
+ }
+
+ /** Create from ticks at the standard PPQN. */
+ static Beats ticks(uint32_t ticks) {
+ return Beats(ticks / PPQN);
+ }
+
+ /** Create from ticks at a given rate.
+ *
+ * Note this can also be used to create from frames by setting ppqn to the
+ * number of samples per beat.
+ */
+ static Beats ticks_at_rate(uint64_t ticks, uint32_t ppqn) {
+ return Beats((double)ticks / (double)ppqn);
+ }
+
+ Beats& operator=(const Beats& other) {
+ _time = other._time;
+ return *this;
+ }
+
+ Beats round_up_to_beat() const {
+ return Evoral::Beats(ceil(_time));
+ }
+
+ Beats round_down_to_beat() const {
+ return Evoral::Beats(floor(_time));
+ }
+
+ Beats snap_to(const Evoral::Beats& snap) const {
+ return Beats(ceil(_time / snap._time) * snap._time);
+ }
+
+ inline bool operator==(const Beats& b) const {
+ /* Acceptable tolerance is 1 tick. */
+ return fabs(_time - b._time) <= (1.0 / PPQN);
+ }
+
+ inline bool operator==(double t) const {
+ /* Acceptable tolerance is 1 tick. */
+ return fabs(_time - t) <= (1.0 / PPQN);
+ }
+
+ inline bool operator==(int beats) const {
+ /* Acceptable tolerance is 1 tick. */
+ return fabs(_time - beats) <= (1.0 / PPQN);
+ }
+
+ inline bool operator!=(const Beats& b) const {
+ return !operator==(b);
+ }
+
+ inline bool operator<(const Beats& b) const {
+ /* Acceptable tolerance is 1 tick. */
+ if (fabs(_time - b._time) <= (1.0 / PPQN)) {
+ return false; /* Effectively identical. */
+ } else {
+ return _time < b._time;
+ }
+ }
+
+ inline bool operator<=(const Beats& b) const {
+ return operator==(b) || operator<(b);
+ }
+
+ inline bool operator>(const Beats& b) const {
+ /* Acceptable tolerance is 1 tick. */
+ if (fabs(_time - b._time) <= (1.0 / PPQN)) {
+ return false; /* Effectively identical. */
+ } else {
+ return _time > b._time;
+ }
+ }
+
+ inline bool operator>=(const Beats& b) const {
+ return operator==(b) || operator>(b);
+ }
+
+ inline bool operator<(double b) const {
+ /* Acceptable tolerance is 1 tick. */
+ if (fabs(_time - b) <= (1.0 / PPQN)) {
+ return false; /* Effectively identical. */
+ } else {
+ return _time < b;
+ }
+ }
+
+ inline bool operator<=(double b) const {
+ return operator==(b) || operator<(b);
+ }
+
+ inline bool operator>(double b) const {
+ /* Acceptable tolerance is 1 tick. */
+ if (fabs(_time - b) <= (1.0 / PPQN)) {
+ return false; /* Effectively identical. */
+ } else {
+ return _time > b;
+ }
+ }
+
+ inline bool operator>=(double b) const {
+ return operator==(b) || operator>(b);
+ }
+
+ Beats operator+(const Beats& b) const {
+ return Beats(_time + b._time);
+ }
+
+ Beats operator-(const Beats& b) const {
+ return Beats(_time - b._time);
+ }
+
+ Beats operator+(double d) const {
+ return Beats(_time + d);
+ }
+
+ Beats operator-(double d) const {
+ return Beats(_time - d);
+ }
+
+ Beats operator-() const {
+ return Beats(-_time);
+ }
+
+ template<typename Number>
+ Beats operator*(Number factor) const {
+ return Beats(_time * factor);
+ }
+
+ Beats& operator+=(const Beats& b) {
+ _time += b._time;
+ return *this;
+ }
+
+ Beats& operator-=(const Beats& b) {
+ _time -= b._time;
+ return *this;
+ }
+
+ double to_double() const { return _time; }
+ uint64_t to_ticks() const { return lrint(_time * PPQN); }
+ uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); }
+
+ uint32_t get_beats() const { return floor(_time); }
+ uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); }
+
+ bool operator!() const { return _time == 0; }
+
+ static Beats min() { return Beats(DBL_MIN); }
+ static Beats max() { return Beats(DBL_MAX); }
+ static Beats tick() { return Beats(1.0 / PPQN); }
+
+private:
+ double _time;
+};
+
+extern LIBEVORAL_API const Beats MaxBeats;
+extern LIBEVORAL_API const Beats MinBeats;
+
+/*
+ TIL, several horrible hours later, that sometimes the compiler looks in the
+ namespace of a type (Evoral::Beats in this case) for an operator, and
+ does *NOT* look in the global namespace.
+
+ C++ is proof that hell exists and we are living in it. In any case, move
+ these to the global namespace and PBD::Property's loopy
+ virtual-method-in-a-template will bite you.
+*/
+
+inline std::ostream&
+operator<<(std::ostream& os, const Beats& t)
+{
+ os << t.to_double();
+ return os;
+}
+
+inline std::istream&
+operator>>(std::istream& is, Beats& t)
+{
+ double beats;
+ is >> beats;
+ t = Beats(beats);
+ return is;
+}
+
+} // namespace Evoral
+
+namespace PBD {
+ namespace DEBUG {
+ LIBEVORAL_API extern uint64_t Beats;
+ }
+}
+
+namespace std {
+ template<>
+ struct numeric_limits<Evoral::Beats> {
+ static Evoral::Beats min() { return Evoral::Beats::min(); }
+ static Evoral::Beats max() { return Evoral::Beats::max(); }
+ };
+}
+
+#endif // EVORAL_BEATS_HPP
diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp
index 14ba36acdf..1951fb8ba6 100644
--- a/libs/evoral/evoral/types.hpp
+++ b/libs/evoral/evoral/types.hpp
@@ -27,6 +27,7 @@
#include <limits>
#include <list>
+#include "evoral/Beats.hpp"
#include "evoral/visibility.h"
#include "pbd/debug.h"
@@ -38,207 +39,9 @@ namespace Evoral {
*/
typedef int32_t event_id_t;
-/** Musical time: beats relative to some defined origin */
-class /*LIBEVORAL_API*/ MusicalTime {
-public:
- LIBEVORAL_API static const double PPQN;
-
- MusicalTime() : _time(0.0) {}
-
- /** Create from a real number of beats. */
- explicit MusicalTime(double time) : _time(time) {}
-
- /** Create from an integer number of beats. */
- static MusicalTime beats(int32_t beats) {
- return MusicalTime((double)beats);
- }
-
- /** Create from ticks at the standard PPQN. */
- static MusicalTime ticks(uint32_t ticks) {
- return MusicalTime(ticks / PPQN);
- }
-
- /** Create from ticks at a given rate.
- *
- * Note this can also be used to create from frames by setting ppqn to the
- * number of samples per beat.
- */
- static MusicalTime ticks_at_rate(uint64_t ticks, uint32_t ppqn) {
- return MusicalTime((double)ticks / (double)ppqn);
- }
-
- MusicalTime& operator=(const MusicalTime& other) {
- _time = other._time;
- return *this;
- }
-
- MusicalTime round_up_to_beat() const {
- return Evoral::MusicalTime(ceil(_time));
- }
-
- MusicalTime round_down_to_beat() const {
- return Evoral::MusicalTime(floor(_time));
- }
-
- MusicalTime snap_to(const Evoral::MusicalTime& snap) const {
- return MusicalTime(ceil(_time / snap._time) * snap._time);
- }
-
- inline bool operator==(const MusicalTime& b) const {
- /* Acceptable tolerance is 1 tick. */
- return fabs(_time - b._time) <= (1.0 / PPQN);
- }
-
- inline bool operator==(double t) const {
- /* Acceptable tolerance is 1 tick. */
- return fabs(_time - t) <= (1.0 / PPQN);
- }
-
- inline bool operator==(int beats) const {
- /* Acceptable tolerance is 1 tick. */
- return fabs(_time - beats) <= (1.0 / PPQN);
- }
-
- inline bool operator!=(const MusicalTime& b) const {
- return !operator==(b);
- }
-
- inline bool operator<(const MusicalTime& b) const {
- /* Acceptable tolerance is 1 tick. */
- if (fabs(_time - b._time) <= (1.0 / PPQN)) {
- return false; /* Effectively identical. */
- } else {
- return _time < b._time;
- }
- }
-
- inline bool operator<=(const MusicalTime& b) const {
- return operator==(b) || operator<(b);
- }
-
- inline bool operator>(const MusicalTime& b) const {
- /* Acceptable tolerance is 1 tick. */
- if (fabs(_time - b._time) <= (1.0 / PPQN)) {
- return false; /* Effectively identical. */
- } else {
- return _time > b._time;
- }
- }
-
- inline bool operator>=(const MusicalTime& b) const {
- return operator==(b) || operator>(b);
- }
-
- inline bool operator<(double b) const {
- /* Acceptable tolerance is 1 tick. */
- if (fabs(_time - b) <= (1.0 / PPQN)) {
- return false; /* Effectively identical. */
- } else {
- return _time < b;
- }
- }
-
- inline bool operator<=(double b) const {
- return operator==(b) || operator<(b);
- }
-
- inline bool operator>(double b) const {
- /* Acceptable tolerance is 1 tick. */
- if (fabs(_time - b) <= (1.0 / PPQN)) {
- return false; /* Effectively identical. */
- } else {
- return _time > b;
- }
- }
-
- inline bool operator>=(double b) const {
- return operator==(b) || operator>(b);
- }
-
- MusicalTime operator+(const MusicalTime& b) const {
- return MusicalTime(_time + b._time);
- }
-
- MusicalTime operator-(const MusicalTime& b) const {
- return MusicalTime(_time - b._time);
- }
-
- MusicalTime operator+(double d) const {
- return MusicalTime(_time + d);
- }
-
- MusicalTime operator-(double d) const {
- return MusicalTime(_time - d);
- }
-
- MusicalTime operator-() const {
- return MusicalTime(-_time);
- }
-
- template<typename Number>
- MusicalTime operator*(Number factor) const {
- return MusicalTime(_time * factor);
- }
-
- MusicalTime& operator+=(const MusicalTime& b) {
- _time += b._time;
- return *this;
- }
-
- MusicalTime& operator-=(const MusicalTime& b) {
- _time -= b._time;
- return *this;
- }
-
- double to_double() const { return _time; }
- uint64_t to_ticks() const { return lrint(_time * PPQN); }
- uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); }
-
- uint32_t get_beats() const { return floor(_time); }
- uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); }
-
- bool operator!() const { return _time == 0; }
-
- static MusicalTime min() { return MusicalTime(DBL_MIN); }
- static MusicalTime max() { return MusicalTime(DBL_MAX); }
- static MusicalTime tick() { return MusicalTime(1.0 / PPQN); }
-
-private:
- double _time;
-};
-
-extern LIBEVORAL_API const MusicalTime MaxMusicalTime;
-extern LIBEVORAL_API const MusicalTime MinMusicalTime;
-
/** Type of an event (opaque, mapped by application) */
typedef uint32_t EventType;
-/*
- TIL, several horrible hours later, that sometimes the compiler looks in the
- namespace of a type (Evoral::MusicalTime in this case) for an operator, and
- does *NOT* look in the global namespace.
-
- C++ is proof that hell exists and we are living in it. In any case, move
- these to the global namespace and PBD::Property's loopy
- virtual-method-in-a-template will bite you.
-*/
-
-inline std::ostream&
-operator<<(std::ostream& os, const MusicalTime& t)
-{
- os << t.to_double();
- return os;
-}
-
-inline std::istream&
-operator>>(std::istream& is, MusicalTime& t)
-{
- double beats;
- is >> beats;
- t = MusicalTime(beats);
- return is;
-}
-
} // namespace Evoral
namespace PBD {
@@ -246,16 +49,7 @@ namespace PBD {
LIBEVORAL_API extern uint64_t Sequence;
LIBEVORAL_API extern uint64_t Note;
LIBEVORAL_API extern uint64_t ControlList;
- LIBEVORAL_API extern uint64_t MusicalTime;
}
}
-namespace std {
- template<>
- struct numeric_limits<Evoral::MusicalTime> {
- static Evoral::MusicalTime min() { return Evoral::MusicalTime::min(); }
- static Evoral::MusicalTime max() { return Evoral::MusicalTime::max(); }
- };
-}
-
#endif // EVORAL_TYPES_HPP
diff --git a/libs/evoral/src/Event.cpp b/libs/evoral/src/Event.cpp
index b874c37de4..66e45ab2ad 100644
--- a/libs/evoral/src/Event.cpp
+++ b/libs/evoral/src/Event.cpp
@@ -155,7 +155,7 @@ Event<Timestamp>::set_original_time (Timestamp t)
#endif // EVORAL_EVENT_ALLOC
-template class Event<Evoral::MusicalTime>;
+template class Event<Evoral::Beats>;
template class Event<double>;
template class Event<int64_t>;
diff --git a/libs/evoral/src/MIDIEvent.cpp b/libs/evoral/src/MIDIEvent.cpp
index 66a97f73e4..4985f66cf4 100644
--- a/libs/evoral/src/MIDIEvent.cpp
+++ b/libs/evoral/src/MIDIEvent.cpp
@@ -102,7 +102,7 @@ MIDIEvent<Time>::to_xml() const
#endif // EVORAL_MIDI_XML
-template class MIDIEvent<Evoral::MusicalTime>;
+template class MIDIEvent<Evoral::Beats>;
} // namespace Evoral
diff --git a/libs/evoral/src/Note.cpp b/libs/evoral/src/Note.cpp
index 93c0a90478..7e4f58d73f 100644
--- a/libs/evoral/src/Note.cpp
+++ b/libs/evoral/src/Note.cpp
@@ -108,7 +108,7 @@ Note<Time>::operator=(const Note<Time>& other)
return *this;
}
-template class Note<Evoral::MusicalTime>;
+template class Note<Evoral::Beats>;
} // namespace Evoral
diff --git a/libs/evoral/src/OldSMF.cpp b/libs/evoral/src/OldSMF.cpp
index 0cee749c9c..eef61e332b 100644
--- a/libs/evoral/src/OldSMF.cpp
+++ b/libs/evoral/src/OldSMF.cpp
@@ -364,6 +364,6 @@ SMF<Time>::write_var_len(uint32_t value)
return ret;
}
-template class SMF<Evoral::MusicalTime>;
+template class SMF<Evoral::Beats>;
} // namespace Evoral
diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp
index a77e3c94be..10b7e31b79 100644
--- a/libs/evoral/src/Sequence.cpp
+++ b/libs/evoral/src/Sequence.cpp
@@ -1404,6 +1404,6 @@ Sequence<Time>::dump (ostream& str) const
str << "--- dump\n";
}
-template class Sequence<Evoral::MusicalTime>;
+template class Sequence<Evoral::Beats>;
} // namespace Evoral
diff --git a/libs/evoral/src/TimeConverter.cpp b/libs/evoral/src/TimeConverter.cpp
index 0d39087e7c..e1e4b8231f 100644
--- a/libs/evoral/src/TimeConverter.cpp
+++ b/libs/evoral/src/TimeConverter.cpp
@@ -45,6 +45,6 @@ IdentityConverter<A,B>::from(B b) const
template class IdentityConverter<double, framepos_t>;
template class TimeConverter<double, framepos_t>;
-template class TimeConverter<Evoral::MusicalTime, framepos_t>;
+template class TimeConverter<Evoral::Beats, framepos_t>;
} // namespace Evoral
diff --git a/libs/evoral/src/types.cpp b/libs/evoral/src/types.cpp
index 80801dcdea..50c2975d3d 100644
--- a/libs/evoral/src/types.cpp
+++ b/libs/evoral/src/types.cpp
@@ -22,8 +22,8 @@
namespace Evoral {
-const double MusicalTime::PPQN = 1920.0;
-const MusicalTime MaxMusicalTime = Evoral::MusicalTime(DBL_MAX);
-const MusicalTime MinMusicalTime = Evoral::MusicalTime(DBL_MIN);
+const double Beats::PPQN = 1920.0;
+const Beats MaxBeats = Evoral::Beats(DBL_MAX);
+const Beats MinBeats = Evoral::Beats(DBL_MIN);
}
diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp
index 9bbe021947..d42ee26dff 100644
--- a/libs/evoral/test/SMFTest.cpp
+++ b/libs/evoral/test/SMFTest.cpp
@@ -45,25 +45,25 @@ SMFTest::takeFiveTest ()
smf.seek_to_start();
uint64_t time = 0; /* in SMF ticks */
- Evoral::Event<Evoral::MusicalTime> ev;
+ Evoral::Event<Evoral::Beats> ev;
uint32_t delta_t = 0;
uint32_t size = 0;
uint8_t* buf = NULL;
int ret;
while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) {
- ev.set(buf, size, Evoral::MusicalTime());
+ ev.set(buf, size, Evoral::Beats());
time += delta_t;
if (ret > 0) { // didn't skip (meta) event
//cerr << "read smf event type " << hex << int(buf[0]) << endl;
- ev.set_time(Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn()));
+ ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
ev.set_event_type(type_map->midi_event_type(buf[0]));
seq->append(ev, next_event_id ());
}
}
seq->end_write (Sequence<Time>::Relax,
- Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn()));
+ Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
CPPUNIT_ASSERT(!seq->empty());
}
diff --git a/libs/evoral/test/SMFTest.hpp b/libs/evoral/test/SMFTest.hpp
index 6e42b6f7b3..94172c62c8 100644
--- a/libs/evoral/test/SMFTest.hpp
+++ b/libs/evoral/test/SMFTest.hpp
@@ -57,7 +57,7 @@ class SMFTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END();
public:
- typedef Evoral::MusicalTime Time;
+ typedef Evoral::Beats Time;
void setUp() {
type_map = new DummyTypeMap();
diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp
index f6a8363f4d..39afcd3095 100644
--- a/libs/evoral/test/SequenceTest.cpp
+++ b/libs/evoral/test/SequenceTest.cpp
@@ -75,7 +75,7 @@ SequenceTest::iteratorSeekTest ()
}
bool on = true;
- for (Sequence<Time>::const_iterator i = seq->begin(Evoral::MusicalTime(600)); i != seq->end(); ++i) {
+ for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) {
if (on) {
CPPUNIT_ASSERT(((const MIDIEvent<Time>&)*i).is_note_on());
CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100));
diff --git a/libs/evoral/test/SequenceTest.hpp b/libs/evoral/test/SequenceTest.hpp
index d8e0406100..da1991efc8 100644
--- a/libs/evoral/test/SequenceTest.hpp
+++ b/libs/evoral/test/SequenceTest.hpp
@@ -113,7 +113,7 @@ class SequenceTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END ();
public:
- typedef MusicalTime Time;
+ typedef Beats Time;
typedef std::vector< boost::shared_ptr< Note<Time> > > Notes;
void setUp () {
@@ -125,7 +125,7 @@ public:
for (int i = 0; i < 12; i++) {
test_notes.push_back(
boost::shared_ptr<Note<Time> >(
- new Note<Time>(0, MusicalTime(i * 100), MusicalTime(100), 64 + i, 64)));
+ new Note<Time>(0, Beats(i * 100), Beats(100), 64 + i, 64)));
}
}
diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc
index 55e7ac1898..e1b3007bd3 100644
--- a/libs/midi++2/midnam_patch.cc
+++ b/libs/midi++2/midnam_patch.cc
@@ -97,7 +97,7 @@ Patch::get_state (void)
node->add_property("Name", _name);
/*
- typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::MusicalTime> > > PatchMidiCommands;
+ typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::Beats> > > PatchMidiCommands;
XMLNode* commands = node->add_child("PatchMIDICommands");
for (PatchMidiCommands::const_iterator event = _patch_midi_commands.begin();
event != _patch_midi_commands.end();