From 8480cf69ce693e7effeb677d791fbe1d5ea004cb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 1 Dec 2011 16:22:51 +0000 Subject: provide semantic ordering of simultaneous MIDI events; add operator== to MidiBuffer iterator; add empty() to MidiBuffer for no particular reason git-svn-id: svn://localhost/ardour2/branches/3.0@10846 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audio_buffer.h | 1 + libs/ardour/ardour/buffer.h | 3 +++ libs/ardour/ardour/midi_buffer.h | 10 ++++++++++ 3 files changed, 14 insertions(+) (limited to 'libs/ardour/ardour') diff --git a/libs/ardour/ardour/audio_buffer.h b/libs/ardour/ardour/audio_buffer.h index c9aefc3903..57c5de6124 100644 --- a/libs/ardour/ardour/audio_buffer.h +++ b/libs/ardour/ardour/audio_buffer.h @@ -157,6 +157,7 @@ public: */ void resize (size_t nframes); + bool empty() const { return _size == 0; } const Sample* data (framecnt_t offset = 0) const { assert(offset <= _capacity); diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h index 4775f24e95..15e97ccc10 100644 --- a/libs/ardour/ardour/buffer.h +++ b/libs/ardour/ardour/buffer.h @@ -56,6 +56,9 @@ public: /** Amount of valid data in buffer. Use this over capacity almost always. */ size_t size() const { return _size; } + /** Return true if the buffer contains no data, false otherwise */ + virtual bool empty() const { return _size == 0; } + /** Type of this buffer. * Based on this you can static cast a Buffer* to the desired type. */ DataType type() const { return _type; } diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h index 5db64a50fb..611e890304 100644 --- a/libs/ardour/ardour/midi_buffer.h +++ b/libs/ardour/ardour/midi_buffer.h @@ -83,6 +83,9 @@ public: inline bool operator!=(const iterator_base& other) const { return (&buffer != &other.buffer) || (offset != other.offset); } + inline bool operator==(const iterator_base& other) const { + return (&buffer == &other.buffer) && (offset == other.offset); + } BufferType& buffer; size_t offset; }; @@ -98,6 +101,13 @@ public: uint8_t* data() const { return _data; } + /** + * returns true if the message with the second argument as its MIDI + * status byte should preceed the message with the first argument as + * its MIDI status byte. + */ + static bool second_simultaneous_midi_byte_is_first (uint8_t, uint8_t); + private: friend class iterator_base< MidiBuffer, Evoral::MIDIEvent >; friend class iterator_base< const MidiBuffer, const Evoral::MIDIEvent >; -- cgit v1.2.3