diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index 72bf7a0fe5..8bd4260283 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -47,7 +47,7 @@ public: , _channel_mask(0x0000FFFF) {} - inline bool read_prefix(EventTime* time, EventType* type, uint32_t* size); + inline bool read_prefix(Evoral::EventTime* time, Evoral::EventType* type, uint32_t* size); inline bool read_contents(uint32_t size, uint8_t* buf); size_t read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t offset=0); @@ -88,11 +88,11 @@ private: * by a call to read_contents (or the read pointer will be garabage). */ inline bool -MidiRingBuffer::read_prefix(EventTime* time, EventType* type, uint32_t* size) +MidiRingBuffer::read_prefix(Evoral::EventTime* time, Evoral::EventType* type, uint32_t* size) { - bool success = Evoral::EventRingBuffer::full_read(sizeof(EventTime), (uint8_t*)time); + bool success = Evoral::EventRingBuffer::full_read(sizeof(Evoral::EventTime), (uint8_t*)time); if (success) - success = Evoral::EventRingBuffer::full_read(sizeof(EventType), (uint8_t*)type); + success = Evoral::EventRingBuffer::full_read(sizeof(Evoral::EventType), (uint8_t*)type); if (success) success = Evoral::EventRingBuffer::full_read(sizeof(uint32_t), (uint8_t*)size); @@ -123,17 +123,17 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t return 0; } - EventTime ev_time; - EventType ev_type; - uint32_t ev_size; + Evoral::EventTime ev_time; + Evoral::EventType ev_type; + uint32_t ev_size; size_t count = 0; //std::cerr << "MRB read " << start << " .. " << end << " + " << offset << std::endl; - while (read_space() >= sizeof(EventTime) + sizeof(EventType) + sizeof(uint32_t)) { + while (read_space() >= sizeof(Evoral::EventTime) + sizeof(Evoral::EventType) + sizeof(uint32_t)) { - full_peek(sizeof(EventTime), (uint8_t*)&ev_time); + full_peek(sizeof(Evoral::EventTime), (uint8_t*)&ev_time); if (ev_time > end) { //std::cerr << "MRB: PAST END (" << ev_time << " : " << end << ")" << std::endl; diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index c60ee7de41..9caf005833 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -197,9 +197,9 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt) { _write_data_count = 0; - EventTime time; - EventType type; - uint32_t size; + Evoral::EventTime time; + Evoral::EventType type; + uint32_t size; size_t buf_capacity = 4; uint8_t* buf = (uint8_t*)malloc(buf_capacity); @@ -643,7 +643,7 @@ SMFSource::load_model(bool lock, bool force_reload) if (ret > 0) { // didn't skip (meta) event // make ev.time absolute time in frames - ev.time() = time * frames_per_beat / (EventTime)ppqn(); + ev.time() = time * frames_per_beat / (Evoral::EventTime)ppqn(); ev.set_event_type(EventTypeMap::instance().midi_event_type(buf[0])); _model->append(ev); } diff --git a/libs/evoral/evoral/Control.hpp b/libs/evoral/evoral/Control.hpp index 46532788f0..31ebe3cfde 100644 --- a/libs/evoral/evoral/Control.hpp +++ b/libs/evoral/evoral/Control.hpp @@ -36,8 +36,8 @@ public: Control(const Parameter& parameter, boost::shared_ptr); virtual ~Control() {} - virtual void set_float(float val, bool to_list=false, nframes_t frame=0); - virtual float get_float(bool from_list=false, nframes_t frame=0) const; + virtual void set_float(float val, bool to_list=false, FrameTime frame=0); + virtual float get_float(bool from_list=false, FrameTime frame=0) const; virtual float user_float() const; void set_list(boost::shared_ptr); diff --git a/libs/evoral/evoral/ControlSet.hpp b/libs/evoral/evoral/ControlSet.hpp index 1b5edb92ac..9a8ea2efcd 100644 --- a/libs/evoral/evoral/ControlSet.hpp +++ b/libs/evoral/evoral/ControlSet.hpp @@ -56,7 +56,7 @@ public: virtual void add_control(boost::shared_ptr); - bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const; + bool find_next_event(FrameTime start, FrameTime end, ControlEvent& ev) const; virtual bool empty() const { return _controls.size() == 0; } virtual void clear(); diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp index e0ac91b515..5ae27131e3 100644 --- a/libs/evoral/evoral/SMF.hpp +++ b/libs/evoral/evoral/SMF.hpp @@ -43,7 +43,7 @@ public: EventTime last_event_time() const { return _last_ev_time; } - void begin_write(nframes_t start_time); + void begin_write(FrameTime start_time); void append_event_unlocked(uint32_t delta_t, const Evoral::Event& ev); void end_write(); diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index a8cfe0cf13..f2bf24b254 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -198,7 +198,7 @@ private: ControlLists _dirty_controls; const const_iterator _end_iter; - mutable nframes_t _next_read; + mutable FrameTime _next_read; bool _percussive; uint8_t _lowest_note; diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp index a722484186..fc1001c7d8 100644 --- a/libs/evoral/evoral/types.hpp +++ b/libs/evoral/evoral/types.hpp @@ -21,8 +21,10 @@ #include +namespace Evoral { + /** Frame count (i.e. length of time in audio frames) */ -typedef uint32_t nframes_t; +typedef uint32_t FrameTime; /** Time-stamp of an event */ typedef double timestamp_t; @@ -39,4 +41,6 @@ typedef double EventLength; /** Type of an event (opaque, mapped by application) */ typedef uint32_t EventType; +} // namespace Evoral + #endif // EVORAL_TYPES_HPP diff --git a/libs/evoral/src/Control.cpp b/libs/evoral/src/Control.cpp index e5301b833c..499a40fd2c 100644 --- a/libs/evoral/src/Control.cpp +++ b/libs/evoral/src/Control.cpp @@ -35,7 +35,7 @@ Control::Control(const Parameter& parameter, boost::shared_ptr list /** Get the currently effective value (ie the one that corresponds to current output) */ float -Control::get_float(bool from_list, nframes_t frame) const +Control::get_float(bool from_list, FrameTime frame) const { if (from_list) return _list->eval(frame); @@ -45,7 +45,7 @@ Control::get_float(bool from_list, nframes_t frame) const void -Control::set_float(float value, bool to_list, nframes_t frame) +Control::set_float(float value, bool to_list, FrameTime frame) { _user_value = value; diff --git a/libs/evoral/src/ControlSet.cpp b/libs/evoral/src/ControlSet.cpp index 837810c727..06046347a6 100644 --- a/libs/evoral/src/ControlSet.cpp +++ b/libs/evoral/src/ControlSet.cpp @@ -70,11 +70,11 @@ ControlSet::control (const Parameter& parameter, bool create_if_missing) } bool -ControlSet::find_next_event (nframes_t now, nframes_t end, ControlEvent& next_event) const +ControlSet::find_next_event (FrameTime now, FrameTime end, ControlEvent& next_event) const { Controls::const_iterator li; - next_event.when = std::numeric_limits::max(); + next_event.when = std::numeric_limits::max(); for (li = _controls.begin(); li != _controls.end(); ++li) { ControlList::const_iterator i; @@ -95,7 +95,7 @@ ControlSet::find_next_event (nframes_t now, nframes_t end, ControlEvent& next_ev } } - return next_event.when != std::numeric_limits::max(); + return next_event.when != std::numeric_limits::max(); } void diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index 4165a331cb..4996f16d6a 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -181,29 +181,6 @@ SMF::write_footer() fflush(_fd); } -/** Returns the offset of the first event in the file with a time past @a start, - * relative to the start of the source. - * - * Returns -1 if not found. - */ -/* -long -SMF::find_first_event_after(nframes_t start) -{ - // FIXME: obviously this is slooow - - fseek(_fd, _header_size, 0); - - while ( ! feof(_fd) ) { - const uint32_t delta_time = read_var_len(); - - if (delta_time > start) - return delta_time; - } - - return -1; -} -*/ /** Read an event from the current position in file. * @@ -303,7 +280,7 @@ SMF::append_event_unlocked(uint32_t delta_t, const Evoral::Event& ev) } void -SMF::begin_write(nframes_t start_frame) +SMF::begin_write(FrameTime start_frame) { _last_ev_time = 0; fseek(_fd, _header_size, SEEK_SET); diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index 3980f46ae2..d746f470b6 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -342,7 +342,7 @@ Sequence::read(EventSink& dst, timestamp_t start, timedur_t nframes, timestamp_t debugout << "Using cached iterator at " << _next_read << endl; } - _next_read = (nframes_t) floor (start + nframes); + _next_read = (FrameTime) floor (start + nframes); while (_read_iter != end() && _read_iter->time() < start + nframes) { assert(_read_iter->size() > 0); diff --git a/libs/evoral/wscript b/libs/evoral/wscript index 1b05ce0bfa..3b44c01514 100644 --- a/libs/evoral/wscript +++ b/libs/evoral/wscript @@ -1,30 +1,46 @@ #!/usr/bin/env python import Params +import autowaf + +# Version of this package (even if built as a child) +EVORAL_VERSION = '0.0.0' + +# Library version (UNIX style major, minor, micro) +# major increment <=> incompatible changes +# minor increment <=> compatible changes (additions) +# micro increment <=> no interface changes +# Version history: +# 0.0.0 = 0,0,0 +EVORAL_LIB_VERSION = '0.0.0' # Variables for 'waf dist' -VERSION = '0.0.1' APPNAME = 'evoral' +VERSION = EVORAL_VERSION # Mandatory variables srcdir = '.' blddir = 'build' def set_options(opt): + autowaf.set_options(opt) + opt.tool_options('compiler_cc') opt.tool_options('compiler_cxx') def configure(conf): - if not conf.env['GLIBMM']: - conf.check_pkg('glibmm-2.4', destvar='GLIBMM', vnum='2.16.0', mandatory=True) - if not conf.env['GTHREAD']: - conf.check_pkg('gthread-2.0', destvar='GTHREAD', vnum='2.16.0', mandatory=True) - if not conf.env['CXX']: - conf.check_tool('compiler_cxx') + autowaf.configure(conf) + autowaf.check_tool(conf, 'compiler_cxx') + autowaf.check_pkg(conf, 'glibmm-2.4', destvar='GLIBMM', vnum='2.16.0', mandatory=True) + autowaf.check_pkg(conf, 'gthread-2.0', destvar='GTHREAD', vnum='2.16.0', mandatory=True) def build(bld): - # Headers (evoral) - install_files('PREFIX', 'include/evoral', 'evoral/*.hpp') + # Headers + #install_files('PREFIX', 'include/evoral', 'evoral/*.h') + #install_files('PREFIX', 'include/evoral', 'evoral/*.hpp') - # Library (src) + # Pkgconfig file + #autowaf.build_pc(bld, 'EVORAL', EVORAL_VERSION, 'GLIBMM GTHREAD') + + # Library obj = bld.create_obj('cpp', 'shlib') obj.source = ''' src/Control.cpp @@ -38,17 +54,21 @@ def build(bld): src/SMFReader.cpp src/Sequence.cpp ''' - obj.includes = '..' + obj.includes = ['.'] obj.name = 'libevoral' obj.target = 'evoral' obj.uselib = 'GLIBMM GTHREAD' - obj.vnum = '0.0.0' + obj.vnum = EVORAL_LIB_VERSION + obj.inst_var = 0 - # Test (test) - obj = bld.create_obj('cpp', 'program') + # Unit tests + obj = bld.create_obj('cpp', 'program') obj.source = 'test/sequence.cpp' obj.includes = '..' obj.uselib_local = 'libevoral' obj.target = 'sequence' obj.inst_var = 0 +def shutdown(): + autowaf.shutdown() +