diff options
Diffstat (limited to 'libs/evoral')
37 files changed, 441 insertions, 97 deletions
diff --git a/libs/evoral/evoral/Control.hpp b/libs/evoral/evoral/Control.hpp index 369c4df630..2b7fd0aa65 100644 --- a/libs/evoral/evoral/Control.hpp +++ b/libs/evoral/evoral/Control.hpp @@ -23,6 +23,8 @@ #include <map> #include <boost/shared_ptr.hpp> #include "pbd/signals.h" + +#include "evoral/visibility.h" #include "evoral/types.hpp" #include "evoral/Parameter.hpp" @@ -38,7 +40,7 @@ class Transport; * a list of values for automation. */ -class Control +class LIBEVORAL_API Control { public: Control(const Parameter& parameter, boost::shared_ptr<ControlList>); diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 967e08d619..de6eb6e3d9 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -25,6 +25,8 @@ #include <boost/pool/pool_alloc.hpp> #include <glibmm/threads.h> #include "pbd/signals.h" + +#include "evoral/visibility.h" #include "evoral/types.hpp" #include "evoral/Range.hpp" #include "evoral/Parameter.hpp" @@ -35,7 +37,7 @@ class Curve; /** A single event (time-stamped value) for a control */ -class ControlEvent { +class LIBEVORAL_API ControlEvent { public: ControlEvent (double w, double v) : when (w), value (v), coeff (0) @@ -67,7 +69,7 @@ public: /** A list (sequence) of time-stamped values for a control */ -class ControlList +class LIBEVORAL_API ControlList { public: typedef std::list<ControlEvent*> EventList; diff --git a/libs/evoral/evoral/ControlSet.hpp b/libs/evoral/evoral/ControlSet.hpp index 716d199fec..57a77afe71 100644 --- a/libs/evoral/evoral/ControlSet.hpp +++ b/libs/evoral/evoral/ControlSet.hpp @@ -25,6 +25,8 @@ #include <boost/utility.hpp> #include <glibmm/threads.h> #include "pbd/signals.h" + +#include "evoral/visibility.h" #include "evoral/types.hpp" #include "evoral/Parameter.hpp" #include "evoral/ControlList.hpp" @@ -34,7 +36,7 @@ namespace Evoral { class Control; class ControlEvent; -class ControlSet : public boost::noncopyable { +class LIBEVORAL_API ControlSet : public boost::noncopyable { public: ControlSet(); ControlSet (const ControlSet&); diff --git a/libs/evoral/evoral/Curve.hpp b/libs/evoral/evoral/Curve.hpp index 5719abf2d4..6aeeb039d7 100644 --- a/libs/evoral/evoral/Curve.hpp +++ b/libs/evoral/evoral/Curve.hpp @@ -22,11 +22,13 @@ #include <inttypes.h> #include <boost/utility.hpp> +#include "evoral/visibility.h" + namespace Evoral { class ControlList; -class Curve : public boost::noncopyable +class LIBEVORAL_API Curve : public boost::noncopyable { public: Curve (const ControlList& cl); @@ -51,7 +53,7 @@ private: } // namespace Evoral extern "C" { - void curve_get_vector_from_c (void *arg, double, double, float*, int32_t); + LIBEVORAL_API void curve_get_vector_from_c (void *arg, double, double, float*, int32_t); } #endif // EVORAL_CURVE_HPP diff --git a/libs/evoral/evoral/Event.hpp b/libs/evoral/evoral/Event.hpp index 747b795480..59e5612e0e 100644 --- a/libs/evoral/evoral/Event.hpp +++ b/libs/evoral/evoral/Event.hpp @@ -25,6 +25,7 @@ #include <sstream> #include <stdint.h> +#include "evoral/visibility.h" #include "evoral/types.hpp" /** If this is not defined, all methods of MidiEvent are RT safe @@ -35,16 +36,16 @@ namespace Evoral { -event_id_t event_id_counter(); -event_id_t next_event_id(); -void init_event_id_counter(event_id_t n); +LIBEVORAL_API event_id_t event_id_counter(); +LIBEVORAL_API event_id_t next_event_id(); +LIBEVORAL_API void init_event_id_counter(event_id_t n); /** An event (much like a type generic jack_midi_event_t) * * Template parameter Time is the type of the time stamp used for this event. */ template<typename Time> -class Event { +class LIBEVORAL_API Event { public: #ifdef EVORAL_EVENT_ALLOC Event (EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false); @@ -157,7 +158,7 @@ protected: template<typename Time> -std::ostream& operator<<(std::ostream& o, const Evoral::Event<Time>& ev) { +/*LIBEVORAL_API*/ std::ostream& operator<<(std::ostream& o, const Evoral::Event<Time>& ev) { o << "Event #" << ev.id() << " type = " << ev.event_type() << " @ " << ev.time(); o << std::hex; for (uint32_t n = 0; n < ev.size(); ++n) { diff --git a/libs/evoral/evoral/EventList.hpp b/libs/evoral/evoral/EventList.hpp index e1a2679ce7..0766d488ac 100644 --- a/libs/evoral/evoral/EventList.hpp +++ b/libs/evoral/evoral/EventList.hpp @@ -19,6 +19,8 @@ #define EVORAL_EVENT_LIST_HPP #include <list> + +#include "evoral/visibility.h" #include "evoral/EventSink.hpp" #include "evoral/types.hpp" #include "evoral/Event.hpp" @@ -31,7 +33,7 @@ namespace Evoral { * Used when we need an unsorted list of Events that is also an EventSink. Absolutely nothing more. */ template<typename Time> -class EventList : public std::list<Evoral::Event<Time> *>, public Evoral::EventSink<Time> { +class /*LIBEVORAL_API*/ EventList : public std::list<Evoral::Event<Time> *>, public Evoral::EventSink<Time> { public: EventList() {} diff --git a/libs/evoral/evoral/EventRingBuffer.hpp b/libs/evoral/evoral/EventRingBuffer.hpp index 419f427f33..df9e6aa9ee 100644 --- a/libs/evoral/evoral/EventRingBuffer.hpp +++ b/libs/evoral/evoral/EventRingBuffer.hpp @@ -22,6 +22,7 @@ #include "pbd/ringbufferNPT.h" +#include "evoral/visibility.h" #include "evoral/EventSink.hpp" #include "evoral/types.hpp" @@ -39,7 +40,7 @@ namespace Evoral { * possible interpretation of uint8_t. */ template<typename Time> -class EventRingBuffer : public PBD::RingBufferNPT<uint8_t>, public Evoral::EventSink<Time> { +class /*LIBEVORAL_API*/ EventRingBuffer : public PBD::RingBufferNPT<uint8_t>, public Evoral::EventSink<Time> { public: /** @param capacity Ringbuffer capacity in bytes. diff --git a/libs/evoral/evoral/EventSink.hpp b/libs/evoral/evoral/EventSink.hpp index 29d2793dd3..fa8b2ef05f 100644 --- a/libs/evoral/evoral/EventSink.hpp +++ b/libs/evoral/evoral/EventSink.hpp @@ -19,15 +19,15 @@ #ifndef EVORAL_EVENT_SINK_HPP #define EVORAL_EVENT_SINK_HPP +#include "evoral/visibility.h" #include "evoral/types.hpp" namespace Evoral { - /** Pure virtual base for anything you can write events to. */ template<typename Time> -class EventSink { +class /*LIBEVORAL_API*/ EventSink { public: virtual ~EventSink() {} 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 6ba7269571..9b1d72c400 100644 --- a/libs/evoral/evoral/MIDIEvent.hpp +++ b/libs/evoral/evoral/MIDIEvent.hpp @@ -21,8 +21,11 @@ #include <cmath> #include <boost/shared_ptr.hpp> + +#include "evoral/visibility.h" #include "evoral/Event.hpp" #include "evoral/midi_events.h" + #ifdef EVORAL_MIDI_XML class XMLNode; #endif @@ -36,7 +39,7 @@ namespace Evoral { * valid MIDI data for these functions to make sense. */ template<typename Time> -class MIDIEvent : public Event<Time> { +class /*LIBEVORAL_API*/ MIDIEvent : public Event<Time> { public: 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) diff --git a/libs/evoral/evoral/MIDIParameters.hpp b/libs/evoral/evoral/MIDIParameters.hpp index 931d29b48d..977c2c18a2 100644 --- a/libs/evoral/evoral/MIDIParameters.hpp +++ b/libs/evoral/evoral/MIDIParameters.hpp @@ -19,23 +19,25 @@ #ifndef EVORAL_MIDI_PARAMETERS_HPP #define EVORAL_MIDI_PARAMETERS_HPP +#include "evoral/visibility.h" + namespace Evoral { namespace MIDI { -struct ContinuousController : public Parameter { +struct /*LIBEVORAL_API*/ ContinuousController : public Parameter { ContinuousController(uint32_t cc_type, uint8_t channel, uint32_t controller) : Parameter(cc_type, channel, controller) {} }; -struct ProgramChange : public Parameter { +struct /*LIBEVORAL_API*/ ProgramChange : public Parameter { ProgramChange(uint32_t pc_type, uint8_t channel) : Parameter(pc_type, channel, 0) {} }; -struct ChannelPressure : public Parameter { +struct /*LIBEVORAL_API*/ ChannelPressure : public Parameter { ChannelPressure(uint32_t ca_type, uint32_t channel) : Parameter(ca_type, channel, 0) {} }; -struct PitchBender : public Parameter { +struct /*LIBEVORAL_API*/ PitchBender : public Parameter { PitchBender(uint32_t pb_type, uint32_t channel) : Parameter(pb_type, channel, 0) {} }; diff --git a/libs/evoral/evoral/Note.hpp b/libs/evoral/evoral/Note.hpp index a400137f77..e84d6b9dc4 100644 --- a/libs/evoral/evoral/Note.hpp +++ b/libs/evoral/evoral/Note.hpp @@ -22,6 +22,8 @@ #include <algorithm> #include <glib.h> #include <stdint.h> + +#include "evoral/visibility.h" #include "evoral/MIDIEvent.hpp" namespace Evoral { @@ -31,7 +33,7 @@ namespace Evoral { * Currently a note is defined as (on event, length, off event). */ template<typename Time> -class Note { +class LIBEVORAL_TEMPLATE_API Note { public: Note(uint8_t chan=0, Time time=0, Time len=0, uint8_t note=0, uint8_t vel=0x40); Note(const Note<Time>& copy); @@ -106,7 +108,7 @@ private: } // namespace Evoral template<typename Time> -std::ostream& operator<<(std::ostream& o, const Evoral::Note<Time>& n) { +/*LIBEVORAL_API*/ std::ostream& operator<<(std::ostream& o, const Evoral::Note<Time>& n) { o << "Note #" << n.id() << ": pitch = " << (int) n.note() << " @ " << n.time() << " .. " << n.end_time() << " velocity " << (int) n.velocity() @@ -114,5 +116,9 @@ std::ostream& operator<<(std::ostream& o, const Evoral::Note<Time>& n) { return o; } +#ifdef COMPILER_MSVC +#include "../src/Note.impl" +#endif + #endif // EVORAL_NOTE_HPP diff --git a/libs/evoral/evoral/OldSMF.hpp b/libs/evoral/evoral/OldSMF.hpp index 692e159926..ef1c751d04 100644 --- a/libs/evoral/evoral/OldSMF.hpp +++ b/libs/evoral/evoral/OldSMF.hpp @@ -19,6 +19,8 @@ #ifndef EVORAL_OLD_SMF_HPP #define EVORAL_OLD_SMF_HPP +#include "evoral/visibility.h" + namespace Evoral { template<typename Time> class Event; @@ -28,7 +30,7 @@ template<typename Time> class EventRingBuffer; /** Standard Midi File (Type 0) */ template<typename Time> -class SMF { +class /*LIBEVORAL_API*/ SMF { public: SMF(); virtual ~SMF(); diff --git a/libs/evoral/evoral/Parameter.hpp b/libs/evoral/evoral/Parameter.hpp index 7142574dbd..2164475cf9 100644 --- a/libs/evoral/evoral/Parameter.hpp +++ b/libs/evoral/evoral/Parameter.hpp @@ -24,6 +24,8 @@ #include <stdint.h> #include <boost/shared_ptr.hpp> +#include "evoral/visibility.h" + namespace Evoral { @@ -36,7 +38,7 @@ namespace Evoral { * This class defines a < operator which is a strict weak ordering, so * Parameter may be stored in a std::set, used as a std::map key, etc. */ -class Parameter +class LIBEVORAL_API Parameter { public: Parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) diff --git a/libs/evoral/evoral/PatchChange.hpp b/libs/evoral/evoral/PatchChange.hpp index 53b50a3383..e05157aa92 100644 --- a/libs/evoral/evoral/PatchChange.hpp +++ b/libs/evoral/evoral/PatchChange.hpp @@ -20,6 +20,7 @@ #ifndef EVORAL_PATCH_CHANGE_HPP #define EVORAL_PATCH_CHANGE_HPP +#include "evoral/visibility.h" #include "evoral/Event.hpp" #include "evoral/MIDIEvent.hpp" @@ -29,7 +30,7 @@ namespace Evoral { * bank select and then a program change. */ template<typename Time> -class PatchChange +class /*LIBEVORAL_API*/ PatchChange { public: /** @param t Time. @@ -166,7 +167,7 @@ private: } template<typename Time> -std::ostream& operator<< (std::ostream& o, const Evoral::PatchChange<Time>& p) { +/*LIBEVORAL_API*/ std::ostream& operator<< (std::ostream& o, const Evoral::PatchChange<Time>& p) { o << "Patch Change " << p.id() << " @ " << p.time() << " bank " << (int) p.bank() << " program " << (int) p.program(); return o; } diff --git a/libs/evoral/evoral/Range.hpp b/libs/evoral/evoral/Range.hpp index 02d92100b9..689dc439b4 100644 --- a/libs/evoral/evoral/Range.hpp +++ b/libs/evoral/evoral/Range.hpp @@ -21,9 +21,11 @@ #include <list> +#include "evoral/visibility.h" + namespace Evoral { -enum OverlapType { +enum /*LIBEVORAL_API*/ OverlapType { OverlapNone, // no overlap OverlapInternal, // the overlap is 100% with the object OverlapStart, // overlap covers start, but ends within @@ -32,7 +34,7 @@ enum OverlapType { }; template<typename T> -OverlapType coverage (T sa, T ea, T sb, T eb) { +/*LIBEVORAL_API*/ OverlapType coverage (T sa, T ea, T sb, T eb) { /* OverlapType returned reflects how the second (B) range overlaps the first (A). @@ -107,7 +109,7 @@ OverlapType coverage (T sa, T ea, T sb, T eb) { /** Type to describe a time range */ template<typename T> -struct Range { +struct /*LIBEVORAL_API*/ Range { Range (T f, T t) : from (f), to (t) {} T from; ///< start of the range T to; ///< end of the range @@ -119,7 +121,7 @@ bool operator== (Range<T> a, Range<T> b) { } template<typename T> -class RangeList { +class /*LIBEVORAL_API*/ RangeList { public: RangeList () : _dirty (false) {} @@ -172,7 +174,7 @@ private: /** Type to describe the movement of a time range */ template<typename T> -struct RangeMove { +struct /*LIBEVORAL_API*/ RangeMove { RangeMove (T f, double l, T t) : from (f), length (l), to (t) {} T from; ///< start of the range double length; ///< length of the range diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp index 8bd05444c4..91bc928d9a 100644 --- a/libs/evoral/evoral/SMF.hpp +++ b/libs/evoral/evoral/SMF.hpp @@ -21,6 +21,8 @@ #define EVORAL_SMF_HPP #include <cassert> + +#include "evoral/visibility.h" #include "evoral/types.hpp" struct smf_struct; @@ -35,7 +37,7 @@ namespace Evoral { /** Standard Midi File. * Currently only tempo-based time of a given PPQN is supported. */ -class SMF { +class LIBEVORAL_API SMF { public: class FileError : public std::exception { public: diff --git a/libs/evoral/evoral/SMFReader.hpp b/libs/evoral/evoral/SMFReader.hpp index 91dd31da21..df7dc7073f 100644 --- a/libs/evoral/evoral/SMFReader.hpp +++ b/libs/evoral/evoral/SMFReader.hpp @@ -24,6 +24,8 @@ #include <string> #include <inttypes.h> +#include "evoral/visibility.h" + namespace Evoral { @@ -31,7 +33,7 @@ namespace Evoral { * * Currently this only reads SMF files with tempo-based timing. */ -class SMFReader { +class LIBEVORAL_API SMFReader { public: class PrematureEOF : public std::exception { const char* what() const throw() { return "Unexpected end of file"; } diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index e2e92385aa..280fc600de 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -26,6 +26,8 @@ #include <utility> #include <boost/shared_ptr.hpp> #include <glibmm/threads.h> + +#include "evoral/visibility.h" #include "evoral/types.hpp" #include "evoral/Note.hpp" #include "evoral/Parameter.hpp" @@ -42,7 +44,7 @@ template<typename Time> class Event; /** An iterator over (the x axis of) a 2-d double coordinate space. */ -class ControlIterator { +class /*LIBEVORAL_API*/ ControlIterator { public: ControlIterator(boost::shared_ptr<const ControlList> al, double ax, double ay) : list(al) @@ -60,7 +62,7 @@ public: * notes (instead of just unassociated note on/off events) and controller data. * Controller data is represented as a list of time-stamped float values. */ template<typename Time> -class Sequence : virtual public ControlSet { +class LIBEVORAL_API Sequence : virtual public ControlSet { public: Sequence(const TypeMap& type_map); Sequence(const Sequence<Time>& other); @@ -179,7 +181,7 @@ public: OverlapPitchResolution overlap_pitch_resolution() const { return _overlap_pitch_resolution; } void set_overlap_pitch_resolution(OverlapPitchResolution opr); - void set_notes (const Sequence<Time>::Notes& n); + void set_notes (const typename Sequence<Time>::Notes& n); typedef boost::shared_ptr< Event<Time> > SysExPtr; typedef boost::shared_ptr<const Event<Time> > constSysExPtr; @@ -214,7 +216,7 @@ private: public: /** Read iterator */ - class const_iterator { + class LIBEVORAL_API /* Added by JE - */ const_iterator { public: const_iterator(); const_iterator(const Sequence<Time>& seq, Time t, bool, std::set<Evoral::Parameter> const &); @@ -269,10 +271,16 @@ public: const const_iterator& end() const { return _end_iter; } + // CONST iterator implementations (x3) typename Notes::const_iterator note_lower_bound (Time t) const; typename PatchChanges::const_iterator patch_change_lower_bound (Time t) const; typename SysExes::const_iterator sysex_lower_bound (Time t) const; + // NON-CONST iterator implementations (x3) + typename Notes::iterator note_lower_bound (Time t); + typename PatchChanges::iterator patch_change_lower_bound (Time t); + typename SysExes::iterator sysex_lower_bound (Time t); + bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev, const ControlIterator& iter) const; @@ -354,7 +362,8 @@ private: } // namespace Evoral -template<typename Time> std::ostream& operator<<(std::ostream& o, const Evoral::Sequence<Time>& s) { s.dump (o); return o; } +template<typename Time> /*LIBEVORAL_API*/ std::ostream& operator<<(std::ostream& o, const Evoral::Sequence<Time>& s) { s.dump (o); return o; } + #endif // EVORAL_SEQUENCE_HPP diff --git a/libs/evoral/evoral/TimeConverter.hpp b/libs/evoral/evoral/TimeConverter.hpp index da765c4b78..5572876cef 100644 --- a/libs/evoral/evoral/TimeConverter.hpp +++ b/libs/evoral/evoral/TimeConverter.hpp @@ -19,6 +19,8 @@ #ifndef EVORAL_TIME_CONVERTER_HPP #define EVORAL_TIME_CONVERTER_HPP +#include "evoral/visibility.h" + namespace Evoral { /** A bidirectional converter between two different time units. @@ -33,7 +35,7 @@ namespace Evoral { * from() converts a time _origin_b + b into an offset from _origin_b in units of A. */ template<typename A, typename B> -class TimeConverter { +class LIBEVORAL_TEMPLATE_API TimeConverter { public: TimeConverter () : _origin_b (0) {} TimeConverter (B ob) : _origin_b (ob) {} @@ -63,11 +65,12 @@ protected: * going on. */ template<typename A, typename B> -class IdentityConverter : public TimeConverter<A,B> { +class LIBEVORAL_TEMPLATE_API IdentityConverter : public TimeConverter<A,B> { public: IdentityConverter() {} - B to(A a) const { return static_cast<B>(a); } - A from(B b) const { return static_cast<A>(b); } + + B to(A a) const; + A from(B b) const; }; diff --git a/libs/evoral/evoral/TypeMap.hpp b/libs/evoral/evoral/TypeMap.hpp index 9d57cb8080..d751c22a42 100644 --- a/libs/evoral/evoral/TypeMap.hpp +++ b/libs/evoral/evoral/TypeMap.hpp @@ -19,6 +19,7 @@ #ifndef EVORAL_TYPE_MAP_HPP #define EVORAL_TYPE_MAP_HPP +#include "evoral/visibility.h" #include "evoral/types.hpp" namespace Evoral { @@ -28,7 +29,7 @@ class Parameter; /** The applications passes one of these which provide the implementation * with required information about event types in an opaque, type neutral way */ -class TypeMap { +class /*LIBEVORAL_API*/ TypeMap { public: virtual ~TypeMap() {} diff --git a/libs/evoral/evoral/midi_util.h b/libs/evoral/evoral/midi_util.h index e1ae7f4620..5c72fb86c9 100644 --- a/libs/evoral/evoral/midi_util.h +++ b/libs/evoral/evoral/midi_util.h @@ -22,10 +22,11 @@ #include <iostream> #include <stdint.h> -#include <stdbool.h> #include <string> #include <sys/types.h> #include <assert.h> + +#include "evoral/visibility.h" #include "evoral/midi_events.h" namespace Evoral { @@ -120,7 +121,7 @@ midi_event_is_valid(const uint8_t* buffer, size_t len) return true; } -std::string midi_note_name (uint8_t noteval); +LIBEVORAL_API std::string midi_note_name (uint8_t noteval); } // namespace Evoral diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp index 000b79bb94..7259a5c0de 100644 --- a/libs/evoral/evoral/types.hpp +++ b/libs/evoral/evoral/types.hpp @@ -26,6 +26,8 @@ #include "pbd/debug.h" +#include "evoral/visibility.h" + namespace Evoral { /** ID of an event (note or other). This must be operable on by glib @@ -35,6 +37,7 @@ typedef int32_t event_id_t; /** Musical time: beats relative to some defined origin */ typedef double MusicalTime; + const MusicalTime MaxMusicalTime = DBL_MAX; const MusicalTime MinMusicalTime = DBL_MIN; @@ -77,9 +80,9 @@ typedef uint32_t EventType; namespace PBD { namespace DEBUG { - extern uint64_t Sequence; - extern uint64_t Note; - extern uint64_t ControlList; + LIBEVORAL_API extern uint64_t Sequence; + LIBEVORAL_API extern uint64_t Note; + LIBEVORAL_API extern uint64_t ControlList; } } diff --git a/libs/evoral/evoral/visibility.h b/libs/evoral/evoral/visibility.h new file mode 100644 index 0000000000..7f4a898875 --- /dev/null +++ b/libs/evoral/evoral/visibility.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2013 Paul Davis + + This program 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. + + This program 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 more 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libevoral_visibility_h__ +#define __libevoral_visibility_h__ + +#if defined(COMPILER_MSVC) + #define LIBEVORAL_DLL_IMPORT __declspec(dllimport) + #define LIBEVORAL_DLL_EXPORT __declspec(dllexport) + #define LIBEVORAL_DLL_LOCAL + #define LIBEVORAL_TEMPLATE_DLL_IMPORT + #define LIBEVORAL_TEMPLATE_DLL_EXPORT +#else + #define LIBEVORAL_DLL_IMPORT __attribute__ ((visibility ("default"))) + #define LIBEVORAL_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define LIBEVORAL_DLL_LOCAL __attribute__ ((visibility ("hidden"))) + #define LIBEVORAL_TEMPLATE_DLL_IMPORT __attribute__ ((visibility ("default"))) + #define LIBEVORAL_TEMPLATE_DLL_EXPORT __attribute__ ((visibility ("default"))) +#endif + +#ifdef LIBEVORAL_STATIC // libevoral is not a DLL + #define LIBEVORAL_API + #define LIBEVORAL_LOCAL +#else + #ifdef LIBEVORAL_DLL_EXPORTS // defined if we are building the libevoral DLL (instead of using it) + #define LIBEVORAL_API LIBEVORAL_DLL_EXPORT + #define LIBEVORAL_TEMPLATE_API LIBEVORAL_TEMPLATE_DLL_EXPORT + #else + #define LIBEVORAL_API LIBEVORAL_DLL_IMPORT + #define LIBEVORAL_TEMPLATE_API LIBEVORAL_TEMPLATE_DLL_IMPORT + #endif + #define LIBEVORAL_LOCAL LIBEVORAL_DLL_LOCAL +#endif + +#endif /* __libevoral_visibility_h__ */ diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index a095daa135..2453574e5c 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -812,7 +812,7 @@ ControlList::modify (iterator iter, double when, double val) (*iter)->when = when; (*iter)->value = val; - if (std::isnan (val)) { + if (isnan (val)) { abort (); } diff --git a/libs/evoral/src/Curve.cpp b/libs/evoral/src/Curve.cpp index 6f3532fdcb..44fc48f728 100644 --- a/libs/evoral/src/Curve.cpp +++ b/libs/evoral/src/Curve.cpp @@ -22,6 +22,7 @@ #include <climits> #include <cfloat> #include <cmath> +#include <vector> #include <glibmm/threads.h> @@ -56,8 +57,8 @@ Curve::solve () (www.korf.co.uk/spline.pdf) for more details. */ - double x[npoints]; - double y[npoints]; + vector<double> x(npoints); + vector<double> y(npoints); uint32_t i; ControlList::EventList::const_iterator xx; diff --git a/libs/evoral/src/IdentityConverter.cpp b/libs/evoral/src/IdentityConverter.cpp new file mode 100644 index 0000000000..1af21debae --- /dev/null +++ b/libs/evoral/src/IdentityConverter.cpp @@ -0,0 +1,43 @@ +/* This file is part of Evoral. + * Copyright (C) 2008 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 + */ + +#include <stdint.h> +#include "evoral/TimeConverter.hpp" + +typedef int64_t framepos_t; /* MUST match libs/ardour/ardour/types.h */ + +namespace Evoral { + +template<typename A, typename B> +B +IdentityConverter<A,B>::to(A a) const +{ + return static_cast<B>(a); +} + +template<typename A, typename B> +A +IdentityConverter<A,B>::from(B b) const +{ + return static_cast<A>(b); +} + +template class IdentityConverter<double, framepos_t>; +template class TimeConverter<double, framepos_t>; + +} // namespace Evoral diff --git a/libs/evoral/src/Note.impl b/libs/evoral/src/Note.impl new file mode 100644 index 0000000000..d63e31a831 --- /dev/null +++ b/libs/evoral/src/Note.impl @@ -0,0 +1,112 @@ +/* This file is part of Evoral. + * Copyright (C) 2008 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 + */ + +#include <iostream> +#include <limits> +#include <glib.h> +// Commented out by JE - 23-10-2013 #include "evoral/Note.hpp" + +namespace Evoral { + +template<typename Time> +Note<Time>::Note(uint8_t chan, Time t, Time l, uint8_t n, uint8_t v) + // FIXME: types? + : _on_event (0xDE, t, 3, NULL, true) + , _off_event (0xAD, t + l, 3, NULL, true) +{ + assert(chan < 16); + + _on_event.buffer()[0] = MIDI_CMD_NOTE_ON + chan; + _on_event.buffer()[1] = n; + _on_event.buffer()[2] = v; + + _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF + chan; + _off_event.buffer()[1] = n; + _off_event.buffer()[2] = 0x40; + + assert(musical_time_equal (time(),t)); + assert(musical_time_equal (length(), l)); + assert(note() == n); + assert(velocity() == v); + assert(_on_event.channel() == _off_event.channel()); + assert(channel() == chan); +} + + +template<typename Time> +Note<Time>::Note(const Note<Time>& copy) + : _on_event(copy._on_event, true) + , _off_event(copy._off_event, true) +{ + set_id (copy.id()); + + assert(_on_event.buffer()); + assert(_off_event.buffer()); + /* + assert(copy._on_event.size == 3); + _on_event.buffer = _on_event_buffer; + memcpy(_on_event_buffer, copy._on_event_buffer, 3); + + assert(copy._off_event.size == 3); + _off_event.buffer = _off_event_buffer; + memcpy(_off_event_buffer, copy._off_event_buffer, 3); + */ + + assert(musical_time_equal (time(),copy.time())); + assert(musical_time_equal (end_time(), copy.end_time())); + assert(musical_time_equal (length(), copy.length())); + assert(note() == copy.note()); + assert(velocity() == copy.velocity()); + assert(_on_event.channel() == _off_event.channel()); + assert(channel() == copy.channel()); +} + +template<typename Time> +Note<Time>::~Note() +{ +} + +template<typename Time> void +Note<Time>::set_id (event_id_t id) +{ + _on_event.set_id (id); + _off_event.set_id (id); +} + +template<typename Time> +const Note<Time>& +Note<Time>::operator=(const Note<Time>& other) +{ + _on_event = other._on_event; + _off_event = other._off_event; + + assert(musical_time_equal (time(),other.time())); + assert(musical_time_equal (end_time(), other.end_time())); + assert(musical_time_equal (length(), other.length())); + assert(note() == other.note()); + assert(velocity() == other.velocity()); + assert(_on_event.channel() == _off_event.channel()); + assert(channel() == other.channel()); + + return *this; +} + +template class Note<Evoral::MusicalTime>; + +} // namespace Evoral + diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index b84507818c..8b2d10d197 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -27,6 +27,10 @@ #include "evoral/midi_util.h" #include "pbd/file_manager.h" +#ifdef COMPILER_MSVC +extern double round(double x); +#endif + using namespace std; namespace Evoral { diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index 204ef58f33..7084a90491 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -1201,11 +1201,13 @@ Sequence<Time>::overlaps_unlocked (const NotePtr& note, const NotePtr& without) template<typename Time> void -Sequence<Time>::set_notes (const Sequence<Time>::Notes& n) +Sequence<Time>::set_notes (const typename Sequence<Time>::Notes& n) { _notes = n; } +// CONST iterator implementations (x3) + /** Return the earliest note with time >= t */ template<typename Time> typename Sequence<Time>::Notes::const_iterator @@ -1239,6 +1241,41 @@ Sequence<Time>::sysex_lower_bound (Time t) const return i; } +// NON-CONST iterator implementations (x3) + +/** Return the earliest note with time >= t */ +template<typename Time> +typename Sequence<Time>::Notes::iterator +Sequence<Time>::note_lower_bound (Time t) +{ + NotePtr search_note(new Note<Time>(0, t, 0, 0, 0)); + typename Sequence<Time>::Notes::iterator i = _notes.lower_bound(search_note); + assert(i == _notes.end() || (*i)->time() >= t); + return i; +} + +/** Return the earliest patch change with time >= t */ +template<typename Time> +typename Sequence<Time>::PatchChanges::iterator +Sequence<Time>::patch_change_lower_bound (Time t) +{ + PatchChangePtr search (new PatchChange<Time> (t, 0, 0, 0)); + typename Sequence<Time>::PatchChanges::iterator i = _patch_changes.lower_bound (search); + assert (i == _patch_changes.end() || musical_time_greater_or_equal_to ((*i)->time(), t)); + return i; +} + +/** Return the earliest sysex with time >= t */ +template<typename Time> +typename Sequence<Time>::SysExes::iterator +Sequence<Time>::sysex_lower_bound (Time t) +{ + SysExPtr search (new Event<Time> (0, t)); + typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search); + assert (i == _sysexes.end() || (*i)->time() >= t); + return i; +} + template<typename Time> void Sequence<Time>::get_notes (Notes& n, NoteOperator op, uint8_t val, int chan_mask) const @@ -1393,4 +1430,3 @@ Sequence<Time>::dump (ostream& str) const template class Sequence<Evoral::MusicalTime>; } // namespace Evoral - diff --git a/libs/evoral/src/libsmf/smf.c b/libs/evoral/src/libsmf/smf.c index b79d7543b6..3fde1d831e 100644 --- a/libs/evoral/src/libsmf/smf.c +++ b/libs/evoral/src/libsmf/smf.c @@ -39,7 +39,11 @@ #include <assert.h> #include <math.h> #include <errno.h> +#ifdef PLATFORM_WINDOWS +#include <winsock2.h> +#else #include <arpa/inet.h> +#endif #include "smf.h" #include "smf_private.h" @@ -52,7 +56,7 @@ smf_new(void) { int cantfail; - smf_t *smf = malloc(sizeof(smf_t)); + smf_t *smf = (smf_t*)malloc(sizeof(smf_t)); if (smf == NULL) { g_critical("Cannot allocate smf_t structure: %s", strerror(errno)); return (NULL); @@ -85,7 +89,7 @@ smf_delete(smf_t *smf) { /* Remove all the tracks, from last to first. */ while (smf->tracks_array->len > 0) - smf_track_delete(g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1)); + smf_track_delete((smf_track_t*)g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1)); smf_fini_tempo(smf); @@ -105,7 +109,7 @@ smf_delete(smf_t *smf) smf_track_t * smf_track_new(void) { - smf_track_t *track = malloc(sizeof(smf_track_t)); + smf_track_t *track = (smf_track_t*)malloc(sizeof(smf_track_t)); if (track == NULL) { g_critical("Cannot allocate smf_track_t structure: %s", strerror(errno)); return (NULL); @@ -131,7 +135,7 @@ smf_track_delete(smf_track_t *track) /* Remove all the events, from last to first. */ while (track->events_array->len > 0) - smf_event_delete(g_ptr_array_index(track->events_array, track->events_array->len - 1)); + smf_event_delete((smf_event_t*)g_ptr_array_index(track->events_array, track->events_array->len - 1)); if (track->smf) smf_track_remove_from_smf(track); @@ -151,7 +155,9 @@ smf_track_delete(smf_track_t *track) void smf_add_track(smf_t *smf, smf_track_t *track) { +#ifndef NDEBUG int cantfail; +#endif assert(track->smf == NULL); @@ -162,8 +168,13 @@ smf_add_track(smf_t *smf, smf_track_t *track) track->track_number = smf->number_of_tracks; if (smf->number_of_tracks > 1) { +#ifndef NDEBUG cantfail = smf_set_format(smf, 1); assert(!cantfail); +#else + smf_set_format(smf, 1); +#endif + } } @@ -213,7 +224,7 @@ smf_track_remove_from_smf(smf_track_t *track) smf_event_t * smf_event_new(void) { - smf_event_t *event = malloc(sizeof(smf_event_t)); + smf_event_t *event = (smf_event_t*)malloc(sizeof(smf_event_t)); if (event == NULL) { g_critical("Cannot allocate smf_event_t structure: %s", strerror(errno)); return (NULL); @@ -246,7 +257,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len) return (NULL); event->midi_buffer_length = len; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); @@ -336,7 +347,7 @@ smf_event_new_from_bytes(int first_byte, int second_byte, int third_byte) } event->midi_buffer_length = len; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); @@ -773,7 +784,7 @@ smf_track_get_event_by_number(const smf_track_t *track, size_t event_number) if (event_number > track->number_of_events) return (NULL); - event = g_ptr_array_index(track->events_array, event_number - 1); + event = (smf_event_t*)g_ptr_array_index(track->events_array, event_number - 1); assert(event); @@ -860,9 +871,8 @@ smf_get_next_event(smf_t *smf) void smf_skip_next_event(smf_t *smf) { - void *notused; - - notused = smf_get_next_event(smf); + smf_event_t *ignored = smf_get_next_event(smf); + (void) ignored; } /** diff --git a/libs/evoral/src/libsmf/smf_decode.c b/libs/evoral/src/libsmf/smf_decode.c index bfba08e9f9..8037fd80d2 100644 --- a/libs/evoral/src/libsmf/smf_decode.c +++ b/libs/evoral/src/libsmf/smf_decode.c @@ -37,7 +37,11 @@ #include <assert.h> #include <math.h> #include <errno.h> +#ifdef PLATFORM_WINDOWS +#include <winsock2.h> +#else #include <arpa/inet.h> +#endif #include <stdint.h> #include "smf.h" #include "smf_private.h" @@ -114,7 +118,7 @@ smf_event_decode_textual(const smf_event_t *event, const char *name) int off = 0; char *buf, *extracted; - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_textual: malloc failed."); return (NULL); @@ -177,7 +181,7 @@ smf_event_decode_metadata(const smf_event_t *event) break; } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_metadata: malloc failed."); return (NULL); @@ -235,7 +239,7 @@ smf_event_decode_metadata(const smf_event_t *event) off += snprintf(buf + off, BUFFER_SIZE - off, "Time Signature: %d/%d, %d clocks per click, %d notated 32nd notes per quarter note", - event->midi_buffer[3], (int)pow(2, event->midi_buffer[4]), event->midi_buffer[5], + event->midi_buffer[3], (int)pow((double)2, event->midi_buffer[4]), event->midi_buffer[5], event->midi_buffer[6]); break; @@ -302,7 +306,7 @@ smf_event_decode_system_realtime(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_system_realtime: malloc failed."); return (NULL); @@ -354,7 +358,7 @@ smf_event_decode_sysex(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_sysex: malloc failed."); return (NULL); @@ -455,7 +459,7 @@ smf_event_decode_system_common(const smf_event_t *event) if (smf_event_is_sysex(event)) return (smf_event_decode_sysex(event)); - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_system_realtime: malloc failed."); return (NULL); @@ -526,7 +530,7 @@ smf_event_decode(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode: malloc failed."); return (NULL); @@ -596,7 +600,7 @@ smf_decode(const smf_t *smf) int off = 0; char *buf; - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode: malloc failed."); return (NULL); diff --git a/libs/evoral/src/libsmf/smf_load.c b/libs/evoral/src/libsmf/smf_load.c index f27d092a8b..d8168d0e6a 100644 --- a/libs/evoral/src/libsmf/smf_load.c +++ b/libs/evoral/src/libsmf/smf_load.c @@ -40,7 +40,11 @@ #include <math.h> #include <errno.h> #include <ctype.h> +#ifdef PLATFORM_WINDOWS +#include <winsock2.h> +#else #include <arpa/inet.h> +#endif #include "smf.h" #include "smf_private.h" @@ -119,7 +123,7 @@ parse_mthd_header(smf_t *smf) return (-1); } - tmp_mthd = smf->file_buffer; + tmp_mthd = (struct chunk_header_struct*)smf->file_buffer; if (!chunk_signature_matches(tmp_mthd, "MThd")) { g_critical("SMF error: MThd signature not found, is that a MIDI file?"); @@ -278,7 +282,11 @@ expected_sysex_length(const unsigned char status, const unsigned char *second_by uint32_t sysex_length = 0; uint32_t len = 0; +#ifndef NDEBUG + (void) status; +#else assert(status == 0xF0); +#endif if (buffer_length < 3) { g_critical("SMF error: end of buffer in expected_sysex_length()."); @@ -405,7 +413,7 @@ extract_sysex_event(const unsigned char *buf, const size_t buffer_length, smf_ev } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno)); return (-4); @@ -448,7 +456,7 @@ extract_escaped_event(const unsigned char *buf, const size_t buffer_length, smf_ } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno)); return (-4); @@ -518,7 +526,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno)); return (-4); @@ -541,7 +549,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve static smf_event_t * parse_next_event(smf_track_t *track) { - uint32_t time = 0; + uint32_t etime = 0; uint32_t len; size_t buffer_length; unsigned char *c, *start; @@ -560,7 +568,7 @@ parse_next_event(smf_track_t *track) assert(buffer_length > 0); /* First, extract time offset from previous event. */ - if (smf_extract_vlq(c, buffer_length, &time, &len)) + if (smf_extract_vlq(c, buffer_length, &etime, &len)) goto error; c += len; @@ -578,7 +586,7 @@ parse_next_event(smf_track_t *track) track->last_status = event->midi_buffer[0]; track->next_event_offset += c - start; - smf_track_add_event_delta_pulses(track, event, time); + smf_track_add_event_delta_pulses(track, event, etime); return (event); @@ -607,7 +615,7 @@ make_string(const unsigned char *buf, const size_t buffer_length, uint32_t len) len = buffer_length; } - str = malloc(len + 1); + str = (char*)malloc(len + 1); if (str == NULL) { g_critical("Cannot allocate memory in make_string()."); return (NULL); @@ -658,14 +666,14 @@ smf_event_extract_text(const smf_event_t *event) return (NULL); } - smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); + smf_extract_vlq((const unsigned char*)(void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); if (string_length <= 0) { g_critical("smf_event_extract_text: truncated MIDI message."); return (NULL); } - return (make_string((void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length)); + return (make_string((const unsigned char*)(void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length)); } /** diff --git a/libs/evoral/src/libsmf/smf_private.h b/libs/evoral/src/libsmf/smf_private.h index 537a29b889..f415eac9da 100644 --- a/libs/evoral/src/libsmf/smf_private.h +++ b/libs/evoral/src/libsmf/smf_private.h @@ -75,6 +75,7 @@ void remove_last_tempo_with_pulses(smf_t *smf, size_t pulses); int smf_event_is_tempo_change_or_time_signature(const smf_event_t *event) WARN_UNUSED_RESULT; int smf_event_length_is_valid(const smf_event_t *event) WARN_UNUSED_RESULT; int is_status_byte(const unsigned char status) WARN_UNUSED_RESULT; +smf_track_t* smf_find_track_with_next_event (smf_t *smf); #endif /* SMF_PRIVATE_H */ diff --git a/libs/evoral/src/libsmf/smf_save.c b/libs/evoral/src/libsmf/smf_save.c index b99af75461..120c3a95eb 100644 --- a/libs/evoral/src/libsmf/smf_save.c +++ b/libs/evoral/src/libsmf/smf_save.c @@ -39,7 +39,11 @@ #include <assert.h> #include <math.h> #include <errno.h> +#ifdef PLATFORM_WINDOWS +#include <winsock2.h> +#else #include <arpa/inet.h> +#endif #include "smf.h" #include "smf_private.h" @@ -54,7 +58,7 @@ static void * smf_extend(smf_t *smf, const int length) { int i, previous_file_buffer_length = smf->file_buffer_length; - char *previous_file_buffer = smf->file_buffer; + char *previous_file_buffer = (char*)smf->file_buffer; /* XXX: Not terribly efficient. */ smf->file_buffer_length += length; @@ -201,7 +205,7 @@ smf_event_new_textual(int type, const char *text) /* "2 +" is for leading 0xFF 0xtype. */ event->midi_buffer_length = 2 + text_length + MAX_VLQ_LENGTH; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); @@ -215,7 +219,11 @@ smf_event_new_textual(int type, const char *text) vlq_length = smf_format_vlq(event->midi_buffer + 2, MAX_VLQ_LENGTH - 2, text_length); copied_length = snprintf((char *)event->midi_buffer + vlq_length + 2, event->midi_buffer_length - vlq_length - 2, "%s", text); +#ifndef NDEBUG + (void) copied_length; /* stop gcc warning about unusued vars for non-debug build */ +#else assert(copied_length == text_length); +#endif event->midi_buffer_length = 2 + vlq_length + text_length; @@ -541,7 +549,7 @@ assert_smf_event_is_identical(const smf_event_t *a, const smf_event_t *b) { assert(a->event_number == b->event_number); assert(a->delta_time_pulses == b->delta_time_pulses); - assert(abs(a->time_pulses - b->time_pulses) <= 2); + assert(abs((long)(a->time_pulses - b->time_pulses)) <= 2); assert(fabs(a->time_seconds - b->time_seconds) <= 0.01); assert(a->track_number == b->track_number); assert(a->midi_buffer_length == b->midi_buffer_length); diff --git a/libs/evoral/src/libsmf/smf_tempo.c b/libs/evoral/src/libsmf/smf_tempo.c index c24e7460c1..f3e3f7fc1b 100644 --- a/libs/evoral/src/libsmf/smf_tempo.c +++ b/libs/evoral/src/libsmf/smf_tempo.c @@ -59,7 +59,7 @@ new_tempo(smf_t *smf, size_t pulses) return (previous_tempo); } - tempo = malloc(sizeof(smf_tempo_t)); + tempo = (smf_tempo_t*)malloc(sizeof(smf_tempo_t)); if (tempo == NULL) { g_critical("Cannot allocate smf_tempo_t."); return (NULL); @@ -133,13 +133,13 @@ maybe_add_to_tempo_map(smf_event_t *event) /* Tempo Change? */ if (event->midi_buffer[1] == 0x51) { - int new_tempo = (event->midi_buffer[3] << 16) + (event->midi_buffer[4] << 8) + event->midi_buffer[5]; - if (new_tempo <= 0) { + int ntempo = (event->midi_buffer[3] << 16) + (event->midi_buffer[4] << 8) + event->midi_buffer[5]; + if (ntempo <= 0) { g_critical("Ignoring invalid tempo change."); return; } - add_tempo(event->track->smf, event->time_pulses, new_tempo); + add_tempo(event->track->smf, event->time_pulses, ntempo); } /* Time Signature? */ @@ -152,7 +152,7 @@ maybe_add_to_tempo_map(smf_event_t *event) } numerator = event->midi_buffer[3]; - denominator = (int)pow(2, event->midi_buffer[4]); + denominator = (int)pow((double)2, event->midi_buffer[4]); clocks_per_click = event->midi_buffer[5]; notes_per_note = event->midi_buffer[6]; @@ -259,7 +259,7 @@ smf_get_tempo_by_number(const smf_t *smf, size_t number) if (number >= smf->tempo_array->len) return (NULL); - return (g_ptr_array_index(smf->tempo_array, number)); + return ((smf_tempo_t*)g_ptr_array_index(smf->tempo_array, number)); } /** @@ -341,7 +341,7 @@ smf_fini_tempo(smf_t *smf) smf_tempo_t *tempo; while (smf->tempo_array->len > 0) { - tempo = g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1); + tempo = (smf_tempo_t*)g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1); assert(tempo); memset(tempo, 0, sizeof(smf_tempo_t)); diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp index d4b2a28aff..fe9efa479f 100644 --- a/libs/evoral/test/SMFTest.cpp +++ b/libs/evoral/test/SMFTest.cpp @@ -1,5 +1,9 @@ #include "SMFTest.hpp" +#ifdef WIN32 +#include <io.h> // for R_OK +#endif + using namespace std; CPPUNIT_TEST_SUITE_REGISTRATION( SMFTest ); diff --git a/libs/evoral/wscript b/libs/evoral/wscript index bfb081217f..55c03fcdf5 100644 --- a/libs/evoral/wscript +++ b/libs/evoral/wscript @@ -57,7 +57,7 @@ def build(bld): # Pkgconfig file #autowaf.build_pc(bld, 'EVORAL', EVORAL_VERSION, 'GLIBMM GTHREAD') - libsmf = bld(features = 'c cshlib') + libsmf = bld(features = 'c cstlib') libsmf.source = ''' src/libsmf/smf.c src/libsmf/smf_decode.c @@ -66,11 +66,13 @@ def build(bld): src/libsmf/smf_tempo.c ''' libsmf.export_includes = ['./src/libsmf'] - libsmf.defines = 'SMF_VERSION="1.2"' + libsmf.defines = ['SMF_VERSION="1.2"', 'LIBSMF_DLL_EXPORTS'] libsmf.includes = ['./src'] libsmf.name = 'libsmf' libsmf.target = 'smf' libsmf.uselib = 'GLIB' + libsmf.cxxflags = [ '-fPIC' ] + libsmf.cflags = [ '-fPIC' ] libsmf.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3') lib_source = ''' @@ -79,6 +81,7 @@ def build(bld): src/ControlSet.cpp src/Curve.cpp src/Event.cpp + src/IdentityConverter.cpp src/midi_util.cpp src/MIDIEvent.cpp src/Note.cpp @@ -88,8 +91,16 @@ def build(bld): ''' # Library - obj = bld(features = 'cxx cxxshlib') - obj.source = lib_source + if bld.is_defined ('INTERNAL_SHARED_LIBS'): + obj = bld.shlib(features = 'c cxx cshlib cxxshlib', source=lib_source) + # DLL exports for this library + obj.defines = [ 'LIBEVORAL_DLL_EXPORTS' ] + else: + obj = bld.stlib(features = 'c cxx cstlib cxxstlib', source=lib_source) + obj.cxxflags = [ '-fPIC' ] + obj.cflags = [ '-fPIC' ] + obj.defines = [ ] + obj.export_includes = ['.'] obj.includes = ['.', './src'] obj.name = 'libevoral' @@ -98,7 +109,7 @@ def build(bld): obj.use = 'libsmf libpbd' obj.vnum = EVORAL_LIB_VERSION obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3') - obj.defines = ['PACKAGE="libevoral"', 'EVORAL_MIDI_XML=1' ] + obj.defines += [ 'PACKAGE="libevoral"', 'EVORAL_MIDI_XML=1' ] if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'): # Static library (for unit test code coverage) |