summaryrefslogtreecommitdiff
path: root/libs/evoral/evoral
diff options
context:
space:
mode:
Diffstat (limited to 'libs/evoral/evoral')
-rw-r--r--libs/evoral/evoral/Event.hpp30
-rw-r--r--libs/evoral/evoral/EventList.hpp4
-rw-r--r--libs/evoral/evoral/EventRingBuffer.hpp3
-rw-r--r--libs/evoral/evoral/EventSink.hpp2
-rw-r--r--libs/evoral/evoral/MIDIEvent.hpp4
-rw-r--r--libs/evoral/evoral/Note.hpp10
-rw-r--r--libs/evoral/evoral/SMF.hpp5
-rw-r--r--libs/evoral/evoral/Sequence.hpp8
-rw-r--r--libs/evoral/evoral/types.hpp6
9 files changed, 37 insertions, 35 deletions
diff --git a/libs/evoral/evoral/Event.hpp b/libs/evoral/evoral/Event.hpp
index 75dfbdbe3a..2410b3684a 100644
--- a/libs/evoral/evoral/Event.hpp
+++ b/libs/evoral/evoral/Event.hpp
@@ -26,7 +26,6 @@
#include <assert.h>
#include "evoral/types.hpp"
-
/** If this is not defined, all methods of MidiEvent are RT safe
* but MidiEvent will never deep copy and (depending on the scenario)
* may not be usable in STL containers, signals, etc.
@@ -35,6 +34,9 @@
namespace Evoral {
+event_id_t event_id_counter();
+event_id_t next_event_id();
+void init_event_id_counter (event_id_t n);
/** An event (much like a type generic jack_midi_event_t)
*
@@ -43,7 +45,7 @@ namespace Evoral {
template<typename Time>
struct Event {
#ifdef EVORAL_EVENT_ALLOC
- Event(EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false);
+ Event (EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false);
/** Copy \a copy.
*
@@ -56,6 +58,7 @@ struct Event {
~Event();
inline const Event& operator=(const Event& copy) {
+ _id = copy.id(); // XXX is this right? do we want ID copy semantics?
_type = copy._type;
_original_time = copy._original_time;
_nominal_time = copy._nominal_time;
@@ -77,20 +80,6 @@ struct Event {
return *this;
}
- inline void shallow_copy(const Event& copy) {
- if (_owns_buf) {
- free(_buf);
- _buf = false;
- _owns_buf = false;
- }
-
- _type = copy._type;
- _original_time = copy._nominal_time;
- _nominal_time = copy._nominal_time;
- _size = copy._size;
- _buf = copy._buf;
- }
-
inline void set(uint8_t* buf, uint32_t size, Time t) {
if (_owns_buf) {
if (_size < size) {
@@ -181,6 +170,9 @@ struct Event {
inline const uint8_t* buffer() const { return _buf; }
inline uint8_t*& buffer() { return _buf; }
+ inline event_id_t id() const { return _id; }
+ inline void set_id (event_id_t n) { _id = n; }
+
protected:
EventType _type; /**< Type of event (application relative, NOT MIDI 'type') */
Time _original_time; /**< Sample index (or beat time) at which event is valid */
@@ -189,17 +181,17 @@ protected:
uint8_t* _buf; /**< Raw MIDI data */
#ifdef EVORAL_EVENT_ALLOC
- bool _owns_buf; /**< Whether buffer is locally allocated */
+ bool _owns_buf; /**< Whether buffer is locally allocated */
#endif
+ event_id_t _id; /** UUID for each event, should probably be 64bit or at least unsigned */
};
-
} // namespace Evoral
template<typename Time>
std::ostream& operator<<(std::ostream& o, const Evoral::Event<Time>& ev) {
- o << "Event type = " << ev.event_type() << " @ " << ev.time();
+ o << "Event #" << ev.id() << " type = " << ev.event_type() << " @ " << ev.time();
o << std::hex;
for (uint32_t n = 0; n < ev.size(); ++n) {
o << ' ' << (int) ev.buffer()[n];
diff --git a/libs/evoral/evoral/EventList.hpp b/libs/evoral/evoral/EventList.hpp
index a024e73d9b..a227629549 100644
--- a/libs/evoral/evoral/EventList.hpp
+++ b/libs/evoral/evoral/EventList.hpp
@@ -35,9 +35,9 @@ class EventList : public std::list<Evoral::Event<Time> *>, public Evoral::EventS
public:
EventList() {}
- uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) {
+ uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) {
push_back(new Evoral::Event<Time>(
- type, time, size, const_cast<uint8_t*>(buf), true)); // Event copies buffer
+ type, time, size, const_cast<uint8_t*>(buf), true)); // Event copies buffer
return size;
}
};
diff --git a/libs/evoral/evoral/EventRingBuffer.hpp b/libs/evoral/evoral/EventRingBuffer.hpp
index 714d8d6f4c..72b4ab29ad 100644
--- a/libs/evoral/evoral/EventRingBuffer.hpp
+++ b/libs/evoral/evoral/EventRingBuffer.hpp
@@ -18,7 +18,6 @@
#ifndef EVORAL_EVENT_RING_BUFFER_HPP
#define EVORAL_EVENT_RING_BUFFER_HPP
-#include <glib.h>
#include "evoral/RingBuffer.hpp"
#include "evoral/EventSink.hpp"
#include "evoral/types.hpp"
@@ -47,7 +46,7 @@ public:
bool peek_time(Time* time);
- uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf);
+ uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf);
bool read (Time* time, EventType* type, uint32_t* size, uint8_t* buf);
};
diff --git a/libs/evoral/evoral/EventSink.hpp b/libs/evoral/evoral/EventSink.hpp
index 3c44095816..11daf1f64e 100644
--- a/libs/evoral/evoral/EventSink.hpp
+++ b/libs/evoral/evoral/EventSink.hpp
@@ -30,7 +30,7 @@ template<typename Time>
class EventSink {
public:
virtual ~EventSink() {}
- virtual uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) = 0;
+ virtual uint32_t write(Time time, EventType type, uint32_t size, const uint8_t* buf) = 0;
};
diff --git a/libs/evoral/evoral/MIDIEvent.hpp b/libs/evoral/evoral/MIDIEvent.hpp
index 359d640fe5..1322f31432 100644
--- a/libs/evoral/evoral/MIDIEvent.hpp
+++ b/libs/evoral/evoral/MIDIEvent.hpp
@@ -37,8 +37,8 @@ namespace Evoral {
*/
template<typename Time>
struct MIDIEvent : public Event<Time> {
- MIDIEvent(EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false)
- : Event<Time>(type, time, size, buf, alloc)
+ MIDIEvent(EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false)
+ : Event<Time>(type, time, size, buf, alloc)
{}
MIDIEvent(const Event<Time>& copy, bool alloc)
diff --git a/libs/evoral/evoral/Note.hpp b/libs/evoral/evoral/Note.hpp
index 1c48634530..b30f0a2385 100644
--- a/libs/evoral/evoral/Note.hpp
+++ b/libs/evoral/evoral/Note.hpp
@@ -19,6 +19,7 @@
#ifndef EVORAL_NOTE_HPP
#define EVORAL_NOTE_HPP
+#include <glib.h>
#include <stdint.h>
#include "evoral/MIDIEvent.hpp"
@@ -31,7 +32,7 @@ namespace Evoral {
template<typename Time>
class Note {
public:
- Note(uint8_t chan=0, Time time=0, Time len=0, uint8_t note=0, uint8_t vel=0x40);
+ Note(uint8_t chan=0, Time time=0, Time len=0, uint8_t note=0, uint8_t vel=0x40);
Note(const Note<Time>& copy);
~Note();
@@ -46,6 +47,9 @@ public:
channel() == other.channel();
}
+ inline event_id_t id() const { return _on_event.id(); }
+ void set_id (event_id_t);
+
inline Time time() const { return _on_event.time(); }
inline Time end_time() const { return _off_event.time(); }
inline uint8_t note() const { return _on_event.note(); }
@@ -69,7 +73,7 @@ public:
inline Event<Time>& off_event() { return _off_event; }
inline const Event<Time>& off_event() const { return _off_event; }
-private:
+ private:
// Event buffers are self-contained
MIDIEvent<Time> _on_event;
MIDIEvent<Time> _off_event;
@@ -79,7 +83,7 @@ private:
template<typename Time>
std::ostream& operator<<(std::ostream& o, const Evoral::Note<Time>& n) {
- o << "Note: pitch = " << (int) n.note()
+ o << "Note #" << n.id() << ": pitch = " << (int) n.note()
<< " @ " << n.time() << " .. " << n.end_time()
<< " velocity " << (int) n.velocity()
<< " chn " << (int) n.channel();
diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp
index a99514829d..1b2eab4b82 100644
--- a/libs/evoral/evoral/SMF.hpp
+++ b/libs/evoral/evoral/SMF.hpp
@@ -21,6 +21,7 @@
#define EVORAL_SMF_HPP
#include <cassert>
+#include "evoral/types.hpp"
struct smf_struct;
struct smf_track_struct;
@@ -52,14 +53,14 @@ public:
void seek_to_start() const;
int seek_to_track(int track);
- int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf) const;
+ int read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* note_id) const;
uint16_t num_tracks() const;
uint16_t ppqn() const;
bool is_empty() const { return _empty; }
void begin_write();
- void append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf);
+ void append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, event_id_t note_id);
void end_write() THROW_FILE_ERROR;
void flush() {};
diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp
index 24a3c44625..6c6c58357f 100644
--- a/libs/evoral/evoral/Sequence.hpp
+++ b/libs/evoral/evoral/Sequence.hpp
@@ -98,7 +98,7 @@ public:
bool writing() const { return _writing; }
void end_write(bool delete_stuck=false);
- void append(const Event<Time>& ev);
+ void append(const Event<Time>& ev, Evoral::event_id_t evid);
inline size_t n_notes() const { return _notes.size(); }
inline bool empty() const { return _notes.size() == 0 && ControlSet::controls_empty(); }
@@ -268,10 +268,10 @@ private:
bool overlaps_unlocked (const NotePtr& ev, const NotePtr& ignore_this_note) const;
bool contains_unlocked (const NotePtr& ev) const;
- void append_note_on_unlocked (NotePtr);
+ void append_note_on_unlocked (NotePtr, Evoral::event_id_t);
void append_note_off_unlocked(NotePtr);
- void append_control_unlocked(const Parameter& param, Time time, double value);
- void append_sysex_unlocked(const MIDIEvent<Time>& ev);
+ void append_control_unlocked(const Parameter& param, Time time, double value, Evoral::event_id_t);
+ void append_sysex_unlocked(const MIDIEvent<Time>& ev, Evoral::event_id_t);
void get_notes_by_pitch (Notes&, NoteOperator, uint8_t val, int chan_mask = 0) const;
void get_notes_by_velocity (Notes&, NoteOperator, uint8_t val, int chan_mask = 0) const;
diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp
index 5ae646c292..4df560465f 100644
--- a/libs/evoral/evoral/types.hpp
+++ b/libs/evoral/evoral/types.hpp
@@ -28,6 +28,12 @@
namespace Evoral {
+/** ID of an event (note or other). This must be operable on by glib
+ atomic ops
+*/
+
+typedef int32_t event_id_t;
+
/** Frame count (i.e. length of time in audio frames) */
typedef uint32_t FrameTime;