Fix broken whitespace via merciless application of the emacs hammer.
git-svn-id: svn://localhost/ardour2/branches/3.0@10782 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -35,12 +35,12 @@ class Curve;
|
||||
/** A single event (time-stamped value) for a control
|
||||
*/
|
||||
struct ControlEvent {
|
||||
ControlEvent (double w, double v)
|
||||
: when (w), value (v), coeff (0)
|
||||
ControlEvent (double w, double v)
|
||||
: when (w), value (v), coeff (0)
|
||||
{}
|
||||
|
||||
ControlEvent (const ControlEvent& other)
|
||||
: when (other.when), value (other.value), coeff (0)
|
||||
ControlEvent (const ControlEvent& other)
|
||||
: when (other.when), value (other.value), coeff (0)
|
||||
{
|
||||
if (other.coeff) {
|
||||
create_coeffs();
|
||||
@@ -58,9 +58,9 @@ struct ControlEvent {
|
||||
coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0;
|
||||
}
|
||||
|
||||
double when;
|
||||
double value;
|
||||
double* coeff; ///< double[4] allocated by Curve as needed
|
||||
double when;
|
||||
double value;
|
||||
double* coeff; ///< double[4] allocated by Curve as needed
|
||||
};
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ struct ControlEvent {
|
||||
* and allocates 8k blocks of new pointers at a time
|
||||
*/
|
||||
typedef boost::fast_pool_allocator<
|
||||
ControlEvent*,
|
||||
boost::default_user_allocator_new_delete,
|
||||
boost::details::pool::null_mutex,
|
||||
8192>
|
||||
ControlEventAllocator;
|
||||
ControlEvent*,
|
||||
boost::default_user_allocator_new_delete,
|
||||
boost::details::pool::null_mutex,
|
||||
8192>
|
||||
ControlEventAllocator;
|
||||
|
||||
|
||||
/** A list (sequence) of time-stamped values for a control
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
void slide (iterator before, double distance);
|
||||
void shift (double before, double distance);
|
||||
|
||||
virtual bool clamp_value (double& /*when*/, double& /*value*/) const { return true; }
|
||||
virtual bool clamp_value (double& /*when*/, double& /*value*/) const { return true; }
|
||||
|
||||
void rt_add (double when, double value);
|
||||
void add (double when, double value);
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
mutable PBD::Signal0<void> Dirty;
|
||||
/** Emitted when our interpolation style changes */
|
||||
PBD::Signal1<void, InterpolationStyle> InterpolationChanged;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** Called by unlocked_eval() to handle cases of 3 or more control points. */
|
||||
@@ -282,13 +282,13 @@ protected:
|
||||
EventList events;
|
||||
double start_time;
|
||||
double end_time;
|
||||
|
||||
|
||||
NascentInfo (double start = -1.0)
|
||||
: start_time (start)
|
||||
, end_time (-1.0)
|
||||
{}
|
||||
, end_time (-1.0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
std::list<NascentInfo*> nascent;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
|
||||
/** @param capacity Ringbuffer capacity in bytes.
|
||||
*/
|
||||
EventRingBuffer(size_t capacity) : PBD::RingBufferNPT<uint8_t>(capacity)
|
||||
EventRingBuffer(size_t capacity) : PBD::RingBufferNPT<uint8_t>(capacity)
|
||||
{}
|
||||
|
||||
size_t capacity() const { return bufsize(); }
|
||||
size_t capacity() const { return bufsize(); }
|
||||
|
||||
/** Peek at the ringbuffer (read w/o advancing read pointer).
|
||||
* @return how much has been peeked (wraps around if read exceeds
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* read-pointer---^
|
||||
* </pre>
|
||||
*/
|
||||
bool peek (uint8_t*, size_t size);
|
||||
bool peek (uint8_t*, size_t size);
|
||||
|
||||
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);
|
||||
@@ -67,25 +67,25 @@ template<typename Time>
|
||||
inline bool
|
||||
EventRingBuffer<Time>::peek (uint8_t* buf, size_t size)
|
||||
{
|
||||
PBD::RingBufferNPT<uint8_t>::rw_vector vec;
|
||||
PBD::RingBufferNPT<uint8_t>::rw_vector vec;
|
||||
|
||||
get_read_vector (&vec);
|
||||
get_read_vector (&vec);
|
||||
|
||||
if (vec.len[0] + vec.len[1] < size) {
|
||||
return false;
|
||||
}
|
||||
if (vec.len[0] + vec.len[1] < size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vec.len[0] > 0) {
|
||||
memcpy (buf, vec.buf[0], min (vec.len[0], size));
|
||||
}
|
||||
if (vec.len[0] > 0) {
|
||||
memcpy (buf, vec.buf[0], min (vec.len[0], size));
|
||||
}
|
||||
|
||||
if (vec.len[0] < size) {
|
||||
if (vec.len[1]) {
|
||||
memcpy (buf + vec.len[0], vec.buf[1], size - vec.len[0]);
|
||||
}
|
||||
}
|
||||
if (vec.len[0] < size) {
|
||||
if (vec.len[1]) {
|
||||
memcpy (buf + vec.len[0], vec.buf[1], size - vec.len[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Time>
|
||||
@@ -93,20 +93,20 @@ inline bool
|
||||
EventRingBuffer<Time>::read(Time* time, EventType* type, uint32_t* size, uint8_t* buf)
|
||||
{
|
||||
if (PBD::RingBufferNPT<uint8_t>::read ((uint8_t*)time, sizeof (Time)) != sizeof (Time)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PBD::RingBufferNPT<uint8_t>::read ((uint8_t*)type, sizeof(EventType)) != sizeof (EventType)) {
|
||||
return false;
|
||||
}
|
||||
if (PBD::RingBufferNPT<uint8_t>::read ((uint8_t*)type, sizeof(EventType)) != sizeof (EventType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PBD::RingBufferNPT<uint8_t>::read ((uint8_t*)size, sizeof(uint32_t)) != sizeof (uint32_t)) {
|
||||
return false;
|
||||
}
|
||||
if (PBD::RingBufferNPT<uint8_t>::read ((uint8_t*)size, sizeof(uint32_t)) != sizeof (uint32_t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PBD::RingBufferNPT<uint8_t>::read (buf, *size) != *size) {
|
||||
return false;
|
||||
}
|
||||
if (PBD::RingBufferNPT<uint8_t>::read (buf, *size) != *size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -119,10 +119,10 @@ EventRingBuffer<Time>::write(Time time, EventType type, uint32_t size, const uin
|
||||
if (write_space() < (sizeof(Time) + sizeof(EventType) + sizeof(uint32_t) + size)) {
|
||||
return 0;
|
||||
} else {
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&time, sizeof(Time));
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&type, sizeof(EventType));
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&size, sizeof(uint32_t));
|
||||
PBD::RingBufferNPT<uint8_t>::write (buf, size);
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&time, sizeof(Time));
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&type, sizeof(EventType));
|
||||
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&size, sizeof(uint32_t));
|
||||
PBD::RingBufferNPT<uint8_t>::write (buf, size);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/* This file is part of Evoral.
|
||||
* Copyright (C) 2008 David Robillard <http://drobilla.net>
|
||||
* Copyright (C) 2000-2008 Paul Davis
|
||||
@@ -95,7 +94,7 @@ public:
|
||||
inline void set_range(double min, double max, double normal, bool toggled) {
|
||||
_metadata = boost::shared_ptr<Metadata>(new Metadata(min, max, normal, toggled));
|
||||
}
|
||||
|
||||
|
||||
inline Metadata& metadata() const {
|
||||
if (_metadata)
|
||||
return *_metadata.get();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright (C) 2010 Paul Davis
|
||||
Author: Carl Hetherington <cth@carlh.net>
|
||||
Copyright (C) 2010 Paul Davis
|
||||
Author: Carl Hetherington <cth@carlh.net>
|
||||
|
||||
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 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.
|
||||
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.
|
||||
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 EVORAL_PATCH_CHANGE_HPP
|
||||
@@ -28,7 +28,7 @@ namespace Evoral {
|
||||
/** Event representing a `patch change', composed of a LSB and MSB
|
||||
* bank select and then a program change.
|
||||
*/
|
||||
template<typename Time>
|
||||
template<typename Time>
|
||||
class PatchChange
|
||||
{
|
||||
public:
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
_bank_change_lsb.buffer()[0] = MIDI_CMD_CONTROL | c;
|
||||
_bank_change_lsb.buffer()[1] = MIDI_CTL_LSB_BANK;
|
||||
_bank_change_lsb.buffer()[2] = b & 0x7f;
|
||||
|
||||
|
||||
_program_change.buffer()[0] = MIDI_CMD_PGM_CHANGE | c;
|
||||
_program_change.buffer()[1] = p;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
event_id_t id () const {
|
||||
return _program_change.id ();
|
||||
}
|
||||
|
||||
|
||||
void set_id (event_id_t id) {
|
||||
_bank_change_msb.set_id (id);
|
||||
_bank_change_lsb.set_id (id);
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
void set_program (uint8_t p) {
|
||||
_program_change.buffer()[1] = p;
|
||||
}
|
||||
|
||||
|
||||
int bank () const {
|
||||
return (bank_msb() << 7) | bank_lsb();
|
||||
}
|
||||
@@ -115,14 +115,14 @@ public:
|
||||
uint8_t bank_lsb () const {
|
||||
return _bank_change_lsb.buffer()[2];
|
||||
}
|
||||
|
||||
|
||||
uint8_t channel () const { return _program_change.buffer()[0] & 0xf; }
|
||||
|
||||
inline bool operator< (const PatchChange<Time>& o) const {
|
||||
if (time() != o.time()) {
|
||||
return time() < o.time();
|
||||
}
|
||||
|
||||
|
||||
if (bank != o.bank()) {
|
||||
return bank() < o.bank();
|
||||
}
|
||||
@@ -164,5 +164,5 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
|
||||
double round_to_file_precision (double val) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void set_path (const std::string& p);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
std::string _file_path;
|
||||
smf_t* _smf;
|
||||
smf_track_t* _smf_track;
|
||||
|
||||
@@ -98,13 +98,13 @@ public:
|
||||
void start_write();
|
||||
bool writing() const { return _writing; }
|
||||
|
||||
enum StuckNoteOption {
|
||||
enum StuckNoteOption {
|
||||
Relax,
|
||||
DeleteStuckNotes,
|
||||
ResolveStuckNotes
|
||||
};
|
||||
|
||||
void end_write (StuckNoteOption, Time when = 0);
|
||||
void end_write (StuckNoteOption, Time when = 0);
|
||||
|
||||
void append(const Event<Time>& ev, Evoral::event_id_t evid);
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
inline Notes& notes() { return _notes; }
|
||||
inline const Notes& notes() const { return _notes; }
|
||||
|
||||
enum NoteOperator {
|
||||
enum NoteOperator {
|
||||
PitchEqual,
|
||||
PitchLessThan,
|
||||
PitchLessThanOrEqual,
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
void trim_overlapping_notes ();
|
||||
void remove_duplicate_notes ();
|
||||
|
||||
enum OverlapPitchResolution {
|
||||
enum OverlapPitchResolution {
|
||||
LastOnFirstOff,
|
||||
FirstOnFirstOff
|
||||
};
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
|
||||
typedef boost::shared_ptr<PatchChange<Time> > PatchChangePtr;
|
||||
typedef boost::shared_ptr<const PatchChange<Time> > constPatchChangePtr;
|
||||
|
||||
|
||||
struct EarlierPatchChangeComparator {
|
||||
inline bool operator() (constPatchChangePtr a, constPatchChangePtr b) const {
|
||||
return a->time() < b->time();
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
inline PatchChanges& patch_changes () { return _patch_changes; }
|
||||
inline const PatchChanges& patch_changes () const { return _patch_changes; }
|
||||
|
||||
void dump (std::ostream&) const;
|
||||
void dump (std::ostream&) const;
|
||||
|
||||
private:
|
||||
typedef std::priority_queue<NotePtr, std::deque<NotePtr>, LaterNoteEndComparator> ActiveNotes;
|
||||
@@ -257,7 +257,7 @@ public:
|
||||
std::set<Evoral::Parameter> const & f = std::set<Evoral::Parameter> ()) const {
|
||||
return const_iterator (*this, t, force_discrete, f);
|
||||
}
|
||||
|
||||
|
||||
const const_iterator& end() const { return _end_iter; }
|
||||
|
||||
typename Notes::const_iterator note_lower_bound (Time t) const;
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
bool edited() const { return _edited; }
|
||||
void set_edited(bool yn) { _edited = yn; }
|
||||
|
||||
bool overlaps (const NotePtr& ev,
|
||||
bool overlaps (const NotePtr& ev,
|
||||
const NotePtr& ignore_this_note) const;
|
||||
bool contains (const NotePtr& ev) const;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ protected:
|
||||
template<typename A, typename B>
|
||||
class IdentityConverter : public TimeConverter<A,B> {
|
||||
public:
|
||||
IdentityConverter() {}
|
||||
IdentityConverter() {}
|
||||
B to(A a) const { return static_cast<B>(a); }
|
||||
A from(B b) const { return static_cast<A>(b); }
|
||||
};
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace Evoral {
|
||||
/** ID of an event (note or other). This must be operable on by glib
|
||||
atomic ops
|
||||
*/
|
||||
|
||||
typedef int32_t event_id_t;
|
||||
|
||||
/** Musical time: beats relative to some defined origin */
|
||||
|
||||
@@ -4,7 +4,7 @@ srcdir=`pwd`
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$srcdir/../../build/default/libs/evoral:$srcdir/../../build/default/libs/pbd
|
||||
if [ ! -f './test/testdata/TakeFive.mid' ]; then
|
||||
echo "This script must be run from within the libs/evoral directory";
|
||||
exit 1;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Make symlink to TakeFive.mid in build directory
|
||||
|
||||
@@ -107,11 +107,11 @@ ControlList::~ControlList()
|
||||
for (EventList::iterator x = _events.begin(); x != _events.end(); ++x) {
|
||||
delete (*x);
|
||||
}
|
||||
|
||||
|
||||
for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
|
||||
for (EventList::iterator x = (*n)->events.begin(); x != (*n)->events.end(); ++x) {
|
||||
delete *x;
|
||||
}
|
||||
for (EventList::iterator x = (*n)->events.begin(); x != (*n)->events.end(); ++x) {
|
||||
delete *x;
|
||||
}
|
||||
delete (*n);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ ControlList::extend_to (double when)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ControlList::_x_scale (double factor)
|
||||
{
|
||||
for (iterator i = _events.begin(); i != _events.end(); ++i) {
|
||||
@@ -220,7 +220,7 @@ ControlList::_x_scale (double factor)
|
||||
void
|
||||
ControlList::write_pass_finished (double when)
|
||||
{
|
||||
merge_nascent (when);
|
||||
merge_nascent (when);
|
||||
}
|
||||
|
||||
|
||||
@@ -233,104 +233,104 @@ struct ControlEventTimeComparator {
|
||||
void
|
||||
ControlList::merge_nascent (double when)
|
||||
{
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
if (nascent.empty()) {
|
||||
return;
|
||||
}
|
||||
if (nascent.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
|
||||
for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
|
||||
|
||||
NascentInfo* ninfo = *n;
|
||||
EventList& nascent_events (ninfo->events);
|
||||
bool need_adjacent_start_clamp;
|
||||
bool need_adjacent_end_clamp;
|
||||
NascentInfo* ninfo = *n;
|
||||
EventList& nascent_events (ninfo->events);
|
||||
bool need_adjacent_start_clamp;
|
||||
bool need_adjacent_end_clamp;
|
||||
|
||||
if (nascent_events.empty()) {
|
||||
delete ninfo;
|
||||
continue;
|
||||
}
|
||||
if (nascent_events.empty()) {
|
||||
delete ninfo;
|
||||
continue;
|
||||
}
|
||||
|
||||
nascent_events.sort (ControlEventTimeComparator ());
|
||||
|
||||
if (ninfo->start_time < 0.0) {
|
||||
ninfo->start_time = nascent_events.front()->when;
|
||||
}
|
||||
|
||||
if (ninfo->end_time < 0.0) {
|
||||
ninfo->end_time = when;
|
||||
}
|
||||
|
||||
bool preexisting = !_events.empty();
|
||||
if (ninfo->start_time < 0.0) {
|
||||
ninfo->start_time = nascent_events.front()->when;
|
||||
}
|
||||
|
||||
if (!preexisting) {
|
||||
|
||||
_events = nascent_events;
|
||||
|
||||
} else if (ninfo->end_time < _events.front()->when) {
|
||||
|
||||
/* all points in nascent are before the first existing point */
|
||||
if (ninfo->end_time < 0.0) {
|
||||
ninfo->end_time = when;
|
||||
}
|
||||
|
||||
_events.insert (_events.begin(), nascent_events.begin(), nascent_events.end());
|
||||
|
||||
} else if (ninfo->start_time > _events.back()->when) {
|
||||
|
||||
/* all points in nascent are after the last existing point */
|
||||
bool preexisting = !_events.empty();
|
||||
|
||||
_events.insert (_events.end(), nascent_events.begin(), nascent_events.end());
|
||||
|
||||
} else {
|
||||
|
||||
/* find the range that overlaps with nascent events,
|
||||
and insert the contents of nascent events.
|
||||
*/
|
||||
|
||||
iterator i;
|
||||
iterator range_begin = _events.end();
|
||||
iterator range_end = _events.end();
|
||||
double end_value = unlocked_eval (ninfo->end_time);
|
||||
double start_value = unlocked_eval (ninfo->start_time - 1);
|
||||
if (!preexisting) {
|
||||
|
||||
need_adjacent_end_clamp = true;
|
||||
need_adjacent_start_clamp = true;
|
||||
_events = nascent_events;
|
||||
|
||||
for (i = _events.begin(); i != _events.end(); ++i) {
|
||||
} else if (ninfo->end_time < _events.front()->when) {
|
||||
|
||||
if ((*i)->when == ninfo->start_time) {
|
||||
/* existing point at same time, remove it
|
||||
and the consider the next point instead.
|
||||
*/
|
||||
i = _events.erase (i);
|
||||
/* all points in nascent are before the first existing point */
|
||||
|
||||
if (i == _events.end()) {
|
||||
break;
|
||||
}
|
||||
_events.insert (_events.begin(), nascent_events.begin(), nascent_events.end());
|
||||
|
||||
if (range_begin == _events.end()) {
|
||||
range_begin = i;
|
||||
need_adjacent_start_clamp = false;
|
||||
} else {
|
||||
need_adjacent_end_clamp = false;
|
||||
}
|
||||
|
||||
if ((*i)->when > ninfo->end_time) {
|
||||
range_end = i;
|
||||
break;
|
||||
}
|
||||
} else if (ninfo->start_time > _events.back()->when) {
|
||||
|
||||
} else if ((*i)->when > ninfo->start_time) {
|
||||
|
||||
if (range_begin == _events.end()) {
|
||||
range_begin = i;
|
||||
}
|
||||
|
||||
if ((*i)->when > ninfo->end_time) {
|
||||
range_end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* all points in nascent are after the last existing point */
|
||||
|
||||
_events.insert (_events.end(), nascent_events.begin(), nascent_events.end());
|
||||
|
||||
} else {
|
||||
|
||||
/* find the range that overlaps with nascent events,
|
||||
and insert the contents of nascent events.
|
||||
*/
|
||||
|
||||
iterator i;
|
||||
iterator range_begin = _events.end();
|
||||
iterator range_end = _events.end();
|
||||
double end_value = unlocked_eval (ninfo->end_time);
|
||||
double start_value = unlocked_eval (ninfo->start_time - 1);
|
||||
|
||||
need_adjacent_end_clamp = true;
|
||||
need_adjacent_start_clamp = true;
|
||||
|
||||
for (i = _events.begin(); i != _events.end(); ++i) {
|
||||
|
||||
if ((*i)->when == ninfo->start_time) {
|
||||
/* existing point at same time, remove it
|
||||
and the consider the next point instead.
|
||||
*/
|
||||
i = _events.erase (i);
|
||||
|
||||
if (i == _events.end()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (range_begin == _events.end()) {
|
||||
range_begin = i;
|
||||
need_adjacent_start_clamp = false;
|
||||
} else {
|
||||
need_adjacent_end_clamp = false;
|
||||
}
|
||||
|
||||
if ((*i)->when > ninfo->end_time) {
|
||||
range_end = i;
|
||||
break;
|
||||
}
|
||||
|
||||
} else if ((*i)->when > ninfo->start_time) {
|
||||
|
||||
if (range_begin == _events.end()) {
|
||||
range_begin = i;
|
||||
}
|
||||
|
||||
if ((*i)->when > ninfo->end_time) {
|
||||
range_end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now:
|
||||
range_begin is the first event on our list after the first nascent event
|
||||
@@ -339,59 +339,59 @@ ControlList::merge_nascent (double when)
|
||||
range_begin may be equal to _events.end() iff the last event on our list
|
||||
was at the same time as the first nascent event.
|
||||
*/
|
||||
|
||||
if (range_begin != _events.begin()) {
|
||||
/* clamp point before */
|
||||
if (need_adjacent_start_clamp) {
|
||||
_events.insert (range_begin, new ControlEvent (ninfo->start_time, start_value));
|
||||
}
|
||||
}
|
||||
|
||||
_events.insert (range_begin, nascent_events.begin(), nascent_events.end());
|
||||
if (range_begin != _events.begin()) {
|
||||
/* clamp point before */
|
||||
if (need_adjacent_start_clamp) {
|
||||
_events.insert (range_begin, new ControlEvent (ninfo->start_time, start_value));
|
||||
}
|
||||
}
|
||||
|
||||
if (range_end != _events.end()) {
|
||||
/* clamp point after */
|
||||
if (need_adjacent_end_clamp) {
|
||||
_events.insert (range_begin, new ControlEvent (ninfo->end_time, end_value));
|
||||
}
|
||||
}
|
||||
|
||||
_events.erase (range_begin, range_end);
|
||||
}
|
||||
_events.insert (range_begin, nascent_events.begin(), nascent_events.end());
|
||||
|
||||
delete ninfo;
|
||||
}
|
||||
if (range_end != _events.end()) {
|
||||
/* clamp point after */
|
||||
if (need_adjacent_end_clamp) {
|
||||
_events.insert (range_begin, new ControlEvent (ninfo->end_time, end_value));
|
||||
}
|
||||
}
|
||||
|
||||
nascent.clear ();
|
||||
_events.erase (range_begin, range_end);
|
||||
}
|
||||
|
||||
if (writing()) {
|
||||
nascent.push_back (new NascentInfo ());
|
||||
}
|
||||
}
|
||||
delete ninfo;
|
||||
}
|
||||
|
||||
maybe_signal_changed ();
|
||||
nascent.clear ();
|
||||
|
||||
if (writing()) {
|
||||
nascent.push_back (new NascentInfo ());
|
||||
}
|
||||
}
|
||||
|
||||
maybe_signal_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
ControlList::rt_add (double when, double value)
|
||||
{
|
||||
// this is for automation recording
|
||||
|
||||
if (touch_enabled() && !touching()) {
|
||||
return;
|
||||
}
|
||||
// this is for automation recording
|
||||
|
||||
if (touch_enabled() && !touching()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//cerr << "RT: alist " << this << " add " << value << " @ " << when << endl;
|
||||
|
||||
Glib::Mutex::Lock lm (_lock, Glib::TRY_LOCK);
|
||||
Glib::Mutex::Lock lm (_lock, Glib::TRY_LOCK);
|
||||
|
||||
if (lm.locked()) {
|
||||
assert (!nascent.empty());
|
||||
if (lm.locked()) {
|
||||
assert (!nascent.empty());
|
||||
/* we don't worry about adding events out of time order as we will
|
||||
sort them in merge_nascent.
|
||||
*/
|
||||
nascent.back()->events.push_back (new ControlEvent (when, value));
|
||||
}
|
||||
nascent.back()->events.push_back (new ControlEvent (when, value));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -405,13 +405,13 @@ ControlList::fast_simple_add (double when, double value)
|
||||
void
|
||||
ControlList::add (double when, double value)
|
||||
{
|
||||
/* this is for making changes from some kind of user interface or
|
||||
control surface (GUI, MIDI, OSC etc)
|
||||
*/
|
||||
/* this is for making changes from some kind of user interface or
|
||||
control surface (GUI, MIDI, OSC etc)
|
||||
*/
|
||||
|
||||
if (!clamp_value (when, value)) {
|
||||
return;
|
||||
}
|
||||
if (!clamp_value (when, value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
@@ -483,7 +483,7 @@ ControlList::erase (double when, double value)
|
||||
if (i != end ()) {
|
||||
_events.erase (i);
|
||||
}
|
||||
|
||||
|
||||
mark_dirty ();
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ ControlList::slide (iterator before, double distance)
|
||||
++before;
|
||||
}
|
||||
|
||||
mark_dirty ();
|
||||
mark_dirty ();
|
||||
}
|
||||
|
||||
maybe_signal_changed ();
|
||||
@@ -588,7 +588,7 @@ ControlList::shift (double pos, double frames)
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
for (iterator i = _events.begin(); i != _events.end(); ++i) {
|
||||
for (iterator i = _events.begin(); i != _events.end(); ++i) {
|
||||
if ((*i)->when >= pos) {
|
||||
(*i)->when += frames;
|
||||
}
|
||||
@@ -727,7 +727,7 @@ ControlList::truncate_end (double last_coordinate)
|
||||
if (last_coordinate > _events.back()->when) {
|
||||
|
||||
/* extending end:
|
||||
*/
|
||||
*/
|
||||
|
||||
iterator foo = _events.begin();
|
||||
bool lessthantwo;
|
||||
@@ -1129,7 +1129,7 @@ ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double& x,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* No points in range */
|
||||
/* No points in range */
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1150,9 +1150,9 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
|
||||
const_iterator length_check_iter = _events.begin();
|
||||
if (_events.empty()) { // 0 events
|
||||
return false;
|
||||
} else if (_events.end() == ++length_check_iter) { // 1 event
|
||||
} else if (_events.end() == ++length_check_iter) { // 1 event
|
||||
return rt_safe_earliest_event_discrete_unlocked (start, x, y, inclusive);
|
||||
}
|
||||
}
|
||||
|
||||
// Hack to avoid infinitely repeating the same event
|
||||
build_search_cache_if_necessary (start);
|
||||
@@ -1171,7 +1171,7 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
|
||||
}
|
||||
next = *_search_cache.first;
|
||||
|
||||
/* Step is before first */
|
||||
/* Step is before first */
|
||||
} else {
|
||||
const_iterator prev = _search_cache.first;
|
||||
--prev;
|
||||
@@ -1229,11 +1229,11 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
|
||||
}
|
||||
|
||||
/*cerr << first->value << " @ " << first->when << " ... "
|
||||
<< next->value << " @ " << next->when
|
||||
<< " = " << y << " @ " << x << endl;*/
|
||||
<< next->value << " @ " << next->when
|
||||
<< " = " << y << " @ " << x << endl;*/
|
||||
|
||||
assert( (y >= first->value && y <= next->value)
|
||||
|| (y <= first->value && y >= next->value) );
|
||||
|| (y <= first->value && y >= next->value) );
|
||||
|
||||
|
||||
const bool past_start = (inclusive ? x >= start : x > start);
|
||||
@@ -1247,7 +1247,7 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, do
|
||||
return false;
|
||||
}
|
||||
|
||||
/* No points in the future, so no steps (towards them) in the future */
|
||||
/* No points in the future, so no steps (towards them) in the future */
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1263,14 +1263,14 @@ ControlList::cut_copy_clear (double start, double end, int op)
|
||||
{
|
||||
boost::shared_ptr<ControlList> nal = create (_parameter);
|
||||
iterator s, e;
|
||||
ControlEvent cp (start, 0.0);
|
||||
ControlEvent cp (start, 0.0);
|
||||
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
/* first, determine s & e, two iterators that define the range of points
|
||||
affected by this operation
|
||||
*/
|
||||
/* first, determine s & e, two iterators that define the range of points
|
||||
affected by this operation
|
||||
*/
|
||||
|
||||
if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
|
||||
return nal;
|
||||
@@ -1281,43 +1281,43 @@ ControlList::cut_copy_clear (double start, double end, int op)
|
||||
e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
|
||||
|
||||
|
||||
/* if "start" isn't the location of an existing point,
|
||||
evaluate the curve to get a value for the start. Add a point to
|
||||
both the existing event list, and if its not a "clear" operation,
|
||||
to the copy ("nal") as well.
|
||||
/* if "start" isn't the location of an existing point,
|
||||
evaluate the curve to get a value for the start. Add a point to
|
||||
both the existing event list, and if its not a "clear" operation,
|
||||
to the copy ("nal") as well.
|
||||
|
||||
Note that the time positions of the points in each list are different
|
||||
because we want the copy ("nal") to have a zero time reference.
|
||||
*/
|
||||
Note that the time positions of the points in each list are different
|
||||
because we want the copy ("nal") to have a zero time reference.
|
||||
*/
|
||||
|
||||
|
||||
/* before we begin any cut/clear operations, get the value of the curve
|
||||
at "end".
|
||||
*/
|
||||
|
||||
double end_value = unlocked_eval (end);
|
||||
/* before we begin any cut/clear operations, get the value of the curve
|
||||
at "end".
|
||||
*/
|
||||
|
||||
if ((*s)->when != start) {
|
||||
|
||||
double val = unlocked_eval (start);
|
||||
double end_value = unlocked_eval (end);
|
||||
|
||||
if ((*s)->when != start) {
|
||||
|
||||
double val = unlocked_eval (start);
|
||||
|
||||
if (op == 0) { // cut
|
||||
if (start > _events.front()->when) {
|
||||
_events.insert (s, (new ControlEvent (start, val)));
|
||||
}
|
||||
}
|
||||
|
||||
if (op != 2) { // ! clear
|
||||
nal->_events.push_back (new ControlEvent (0, val));
|
||||
}
|
||||
}
|
||||
|
||||
if (op != 2) { // ! clear
|
||||
nal->_events.push_back (new ControlEvent (0, val));
|
||||
}
|
||||
}
|
||||
|
||||
for (iterator x = s; x != e; ) {
|
||||
|
||||
/* adjust new points to be relative to start, which
|
||||
has been set to zero.
|
||||
*/
|
||||
|
||||
|
||||
if (op != 2) {
|
||||
nal->_events.push_back (new ControlEvent ((*x)->when - start, (*x)->value));
|
||||
}
|
||||
@@ -1325,30 +1325,30 @@ ControlList::cut_copy_clear (double start, double end, int op)
|
||||
if (op != 1) {
|
||||
x = _events.erase (x);
|
||||
} else {
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
if (e == _events.end() || (*e)->when != end) {
|
||||
|
||||
/* only add a boundary point if there is a point after "end"
|
||||
*/
|
||||
|
||||
if (op == 0 && (e != _events.end() && end < (*e)->when)) { // cut
|
||||
_events.insert (e, new ControlEvent (end, end_value));
|
||||
}
|
||||
|
||||
if (op != 2 && (e != _events.end() && end < (*e)->when)) { // cut/copy
|
||||
nal->_events.push_back (new ControlEvent (end - start, end_value));
|
||||
}
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
mark_dirty ();
|
||||
if (e == _events.end() || (*e)->when != end) {
|
||||
|
||||
/* only add a boundary point if there is a point after "end"
|
||||
*/
|
||||
|
||||
if (op == 0 && (e != _events.end() && end < (*e)->when)) { // cut
|
||||
_events.insert (e, new ControlEvent (end, end_value));
|
||||
}
|
||||
|
||||
if (op != 2 && (e != _events.end() && end < (*e)->when)) { // cut/copy
|
||||
nal->_events.push_back (new ControlEvent (end - start, end_value));
|
||||
}
|
||||
}
|
||||
|
||||
mark_dirty ();
|
||||
}
|
||||
|
||||
if (op != 1) {
|
||||
maybe_signal_changed ();
|
||||
}
|
||||
if (op != 1) {
|
||||
maybe_signal_changed ();
|
||||
}
|
||||
|
||||
return nal;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ ControlSet::ControlSet()
|
||||
}
|
||||
|
||||
ControlSet::ControlSet (const ControlSet&)
|
||||
: noncopyable ()
|
||||
: noncopyable ()
|
||||
{
|
||||
/* derived class must copy controls */
|
||||
/* derived class must copy controls */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -47,7 +47,7 @@ ControlSet::add_control(boost::shared_ptr<Control> ac)
|
||||
|
||||
ac->list()->InterpolationChanged.connect_same_thread (
|
||||
_list_connections, boost::bind (&ControlSet::control_list_interpolation_changed, this, ac->parameter(), _1)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -91,26 +91,26 @@ ControlSet::find_next_event (double now, double end, ControlEvent& next_event) c
|
||||
|
||||
next_event.when = std::numeric_limits<double>::max();
|
||||
|
||||
for (li = _controls.begin(); li != _controls.end(); ++li) {
|
||||
for (li = _controls.begin(); li != _controls.end(); ++li) {
|
||||
ControlList::const_iterator i;
|
||||
boost::shared_ptr<const ControlList> alist (li->second->list());
|
||||
ControlEvent cp (now, 0.0f);
|
||||
|
||||
for (i = lower_bound (alist->begin(), alist->end(), &cp, ControlList::time_comparator);
|
||||
i != alist->end() && (*i)->when < end; ++i) {
|
||||
if ((*i)->when > now) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = lower_bound (alist->begin(), alist->end(), &cp, ControlList::time_comparator);
|
||||
i != alist->end() && (*i)->when < end; ++i) {
|
||||
if ((*i)->when > now) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i != alist->end() && (*i)->when < end) {
|
||||
if ((*i)->when < next_event.when) {
|
||||
next_event.when = (*i)->when;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i != alist->end() && (*i)->when < end) {
|
||||
if ((*i)->when < next_event.when) {
|
||||
next_event.when = (*i)->when;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return next_event.when != std::numeric_limits<double>::max();
|
||||
return next_event.when != std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -26,7 +26,7 @@ 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)
|
||||
: _on_event (0xDE, t, 3, NULL, true)
|
||||
, _off_event (0xAD, t + l, 3, NULL, true)
|
||||
{
|
||||
assert(chan < 16);
|
||||
@@ -50,21 +50,21 @@ Note<Time>::Note(uint8_t chan, Time t, Time l, uint8_t n, uint8_t v)
|
||||
|
||||
template<typename Time>
|
||||
Note<Time>::Note(const Note<Time>& copy)
|
||||
: _on_event(copy._on_event, true)
|
||||
: _on_event(copy._on_event, true)
|
||||
, _off_event(copy._off_event, true)
|
||||
{
|
||||
set_id (copy.id());
|
||||
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._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(copy._off_event.size == 3);
|
||||
_off_event.buffer = _off_event_buffer;
|
||||
memcpy(_off_event_buffer, copy._off_event_buffer, 3);
|
||||
*/
|
||||
|
||||
assert(time() == copy.time());
|
||||
@@ -84,8 +84,8 @@ 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);
|
||||
_on_event.set_id (id);
|
||||
_off_event.set_id (id);
|
||||
}
|
||||
|
||||
template<typename Time>
|
||||
|
||||
@@ -88,14 +88,14 @@ SMF::open(const std::string& path, int track) THROW_FILE_ERROR
|
||||
if (f == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ((_smf = smf_load (f)) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((_smf_track = smf_get_track_by_number(_smf, track)) == 0) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
//cerr << "Track " << track << " # events: " << _smf_track->number_of_events << endl;
|
||||
if (_smf_track->number_of_events == 0) {
|
||||
@@ -129,7 +129,7 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) THROW_FILE_ERROR
|
||||
_smf = smf_new();
|
||||
|
||||
if (_smf == NULL) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (smf_set_ppqn(_smf, ppqn) != 0) {
|
||||
@@ -148,19 +148,19 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) THROW_FILE_ERROR
|
||||
|
||||
_smf_track->next_event_number = 0;
|
||||
|
||||
{
|
||||
/* put a stub file on disk */
|
||||
{
|
||||
/* put a stub file on disk */
|
||||
|
||||
PBD::StdioFileDescriptor d (_file_path, "w+");
|
||||
FILE* f = d.allocate ();
|
||||
if (f == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (smf_save (_smf, f)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
PBD::StdioFileDescriptor d (_file_path, "w+");
|
||||
FILE* f = d.allocate ();
|
||||
if (f == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (smf_save (_smf, f)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
_empty = true;
|
||||
|
||||
@@ -208,34 +208,34 @@ SMF::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* no
|
||||
assert(delta_t);
|
||||
assert(size);
|
||||
assert(buf);
|
||||
assert(note_id);
|
||||
assert(note_id);
|
||||
|
||||
if ((event = smf_track_get_next_event(_smf_track)) != NULL) {
|
||||
|
||||
*delta_t = event->delta_time_pulses;
|
||||
|
||||
if (smf_event_is_metadata(event)) {
|
||||
*note_id = -1; // "no note id in this meta-event */
|
||||
*note_id = -1; // "no note id in this meta-event */
|
||||
|
||||
if (event->midi_buffer[1] == 0x7f) { // Sequencer-specific
|
||||
if (event->midi_buffer[1] == 0x7f) { // Sequencer-specific
|
||||
|
||||
uint32_t evsize;
|
||||
uint32_t lenlen;
|
||||
|
||||
if (smf_extract_vlq (&event->midi_buffer[2], event->midi_buffer_length-2, &evsize, &lenlen) == 0) {
|
||||
|
||||
if (event->midi_buffer[2+lenlen] == 0x99 && // Evoral
|
||||
event->midi_buffer[3+lenlen] == 0x1) { // Evoral Note ID
|
||||
|
||||
uint32_t id;
|
||||
uint32_t idlen;
|
||||
|
||||
if (smf_extract_vlq (&event->midi_buffer[4+lenlen], event->midi_buffer_length-(4+lenlen), &id, &idlen) == 0) {
|
||||
*note_id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32_t evsize;
|
||||
uint32_t lenlen;
|
||||
|
||||
if (smf_extract_vlq (&event->midi_buffer[2], event->midi_buffer_length-2, &evsize, &lenlen) == 0) {
|
||||
|
||||
if (event->midi_buffer[2+lenlen] == 0x99 && // Evoral
|
||||
event->midi_buffer[3+lenlen] == 0x1) { // Evoral Note ID
|
||||
|
||||
uint32_t id;
|
||||
uint32_t idlen;
|
||||
|
||||
if (smf_extract_vlq (&event->midi_buffer[4+lenlen], event->midi_buffer_length-(4+lenlen), &id, &idlen) == 0) {
|
||||
*note_id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* this is a meta-event */
|
||||
}
|
||||
|
||||
@@ -252,9 +252,9 @@ SMF::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* no
|
||||
assert(midi_event_is_valid(*buf, *size));
|
||||
|
||||
/* printf("SMF::read_event @ %u: ", *delta_t);
|
||||
for (size_t i = 0; i < *size; ++i) {
|
||||
printf("%X ", (*buf)[i]);
|
||||
} printf("\n") */
|
||||
for (size_t i = 0; i < *size; ++i) {
|
||||
printf("%X ", (*buf)[i]);
|
||||
} printf("\n") */
|
||||
|
||||
return event_size;
|
||||
} else {
|
||||
@@ -270,9 +270,9 @@ SMF::append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, eve
|
||||
}
|
||||
|
||||
/* printf("SMF::append_event_delta @ %u:", delta_t);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
printf("%X ", buf[i]);
|
||||
} printf("\n"); */
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
printf("%X ", buf[i]);
|
||||
} printf("\n"); */
|
||||
|
||||
if (!midi_event_is_valid(buf, size)) {
|
||||
cerr << "WARNING: SMF ignoring illegal MIDI event" << endl;
|
||||
@@ -281,8 +281,8 @@ SMF::append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, eve
|
||||
|
||||
smf_event_t* event;
|
||||
|
||||
/* XXX july 2010: currently only store event ID's for notes, program changes and bank changes
|
||||
*/
|
||||
/* XXX july 2010: currently only store event ID's for notes, program changes and bank changes
|
||||
*/
|
||||
|
||||
uint8_t const c = buf[0] & 0xf0;
|
||||
bool const store_id = (
|
||||
@@ -290,42 +290,42 @@ SMF::append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf, eve
|
||||
c == MIDI_CMD_NOTE_OFF ||
|
||||
c == MIDI_CMD_PGM_CHANGE ||
|
||||
(c == MIDI_CMD_CONTROL && (buf[1] == MIDI_CTL_MSB_BANK || buf[1] == MIDI_CTL_LSB_BANK))
|
||||
);
|
||||
);
|
||||
|
||||
if (store_id && note_id >= 0) {
|
||||
int idlen;
|
||||
int lenlen;
|
||||
uint8_t idbuf[16];
|
||||
uint8_t lenbuf[16];
|
||||
int idlen;
|
||||
int lenlen;
|
||||
uint8_t idbuf[16];
|
||||
uint8_t lenbuf[16];
|
||||
|
||||
event = smf_event_new ();
|
||||
assert(event != NULL);
|
||||
event = smf_event_new ();
|
||||
assert(event != NULL);
|
||||
|
||||
/* generate VLQ representation of note ID */
|
||||
idlen = smf_format_vlq (idbuf, sizeof(idbuf), note_id);
|
||||
/* generate VLQ representation of note ID */
|
||||
idlen = smf_format_vlq (idbuf, sizeof(idbuf), note_id);
|
||||
|
||||
/* generate VLQ representation of meta event length,
|
||||
which is the idlen + 2 bytes (Evoral type ID plus Note ID type)
|
||||
*/
|
||||
/* generate VLQ representation of meta event length,
|
||||
which is the idlen + 2 bytes (Evoral type ID plus Note ID type)
|
||||
*/
|
||||
|
||||
lenlen = smf_format_vlq (lenbuf, sizeof(lenbuf), idlen+2);
|
||||
lenlen = smf_format_vlq (lenbuf, sizeof(lenbuf), idlen+2);
|
||||
|
||||
event->midi_buffer_length = 2 + lenlen + 2 + idlen;
|
||||
event->midi_buffer_length = 2 + lenlen + 2 + idlen;
|
||||
/* this should be allocated by malloc(3) because libsmf will
|
||||
call free(3) on it
|
||||
*/
|
||||
event->midi_buffer = (uint8_t*) malloc (sizeof (uint8_t*) * event->midi_buffer_length);
|
||||
event->midi_buffer = (uint8_t*) malloc (sizeof (uint8_t*) * event->midi_buffer_length);
|
||||
|
||||
event->midi_buffer[0] = 0xff; // Meta-event
|
||||
event->midi_buffer[1] = 0x7f; // Sequencer-specific
|
||||
memcpy (&event->midi_buffer[2], lenbuf, lenlen);
|
||||
event->midi_buffer[2+lenlen] = 0x99; // Evoral type ID
|
||||
event->midi_buffer[3+lenlen] = 0x1; // Evoral type Note ID
|
||||
memcpy (&event->midi_buffer[4+lenlen], idbuf, idlen);
|
||||
event->midi_buffer[0] = 0xff; // Meta-event
|
||||
event->midi_buffer[1] = 0x7f; // Sequencer-specific
|
||||
memcpy (&event->midi_buffer[2], lenbuf, lenlen);
|
||||
event->midi_buffer[2+lenlen] = 0x99; // Evoral type ID
|
||||
event->midi_buffer[3+lenlen] = 0x1; // Evoral type Note ID
|
||||
memcpy (&event->midi_buffer[4+lenlen], idbuf, idlen);
|
||||
|
||||
assert(_smf_track);
|
||||
smf_track_add_event_delta_pulses(_smf_track, event, 0);
|
||||
}
|
||||
assert(_smf_track);
|
||||
smf_track_add_event_delta_pulses(_smf_track, event, 0);
|
||||
}
|
||||
|
||||
event = smf_event_new_from_pointer(buf, size);
|
||||
assert(event != NULL);
|
||||
@@ -373,7 +373,7 @@ SMF::round_to_file_precision (double val) const
|
||||
void
|
||||
SMF::set_path (const std::string& p)
|
||||
{
|
||||
_file_path = p;
|
||||
_file_path = p;
|
||||
}
|
||||
|
||||
} // namespace Evoral
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -251,7 +251,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len)
|
||||
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
||||
smf_event_delete(event);
|
||||
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
memcpy(event->midi_buffer, midi_data, len);
|
||||
@@ -269,7 +269,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len)
|
||||
* like this:
|
||||
*
|
||||
* smf_event_new_from_bytes(0xC0, 0x42, -1);
|
||||
*
|
||||
*
|
||||
* \param first_byte First byte of MIDI message. Must be valid status byte.
|
||||
* \param second_byte Second byte of MIDI message or -1, if message is one byte long.
|
||||
* \param third_byte Third byte of MIDI message or -1, if message is two bytes long.
|
||||
@@ -341,7 +341,7 @@ smf_event_new_from_bytes(int first_byte, int second_byte, int third_byte)
|
||||
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
|
||||
smf_event_delete(event);
|
||||
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
event->midi_buffer[0] = first_byte;
|
||||
@@ -378,7 +378,7 @@ static gint
|
||||
events_array_compare_function(gconstpointer aa, gconstpointer bb)
|
||||
{
|
||||
smf_event_t *a, *b;
|
||||
|
||||
|
||||
/* "The comparison function for g_ptr_array_sort() doesn't take the pointers
|
||||
from the array as arguments, it takes pointers to the pointers in the array." */
|
||||
a = (smf_event_t *)*(gpointer *)aa;
|
||||
@@ -790,7 +790,7 @@ smf_track_get_last_event(const smf_track_t *track)
|
||||
|
||||
if (track->number_of_events == 0)
|
||||
return (NULL);
|
||||
|
||||
|
||||
event = smf_track_get_event_by_number(track, track->number_of_events);
|
||||
|
||||
return (event);
|
||||
@@ -845,7 +845,7 @@ smf_get_next_event(smf_t *smf)
|
||||
}
|
||||
|
||||
event = smf_track_get_next_event(track);
|
||||
|
||||
|
||||
assert(event != NULL);
|
||||
|
||||
event->track->smf->last_seek_position = -1.0;
|
||||
@@ -884,7 +884,7 @@ smf_peek_next_event(smf_t *smf)
|
||||
}
|
||||
|
||||
event = smf_peek_next_event_from_track(track);
|
||||
|
||||
|
||||
assert(event != NULL);
|
||||
|
||||
return (event);
|
||||
@@ -950,7 +950,7 @@ smf_seek_to_event(smf_t *smf, const smf_event_t *target)
|
||||
smf_skip_next_event(smf);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
smf->last_seek_position = event->time_seconds;
|
||||
|
||||
|
||||
@@ -12,20 +12,20 @@ main()
|
||||
{
|
||||
Glib::thread_init();
|
||||
|
||||
CppUnit::TestResult testresult;
|
||||
CppUnit::TestResult testresult;
|
||||
|
||||
CppUnit::TestResultCollector collectedresults;
|
||||
testresult.addListener (&collectedresults);
|
||||
CppUnit::TestResultCollector collectedresults;
|
||||
testresult.addListener (&collectedresults);
|
||||
|
||||
CppUnit::BriefTestProgressListener progress;
|
||||
testresult.addListener (&progress);
|
||||
CppUnit::BriefTestProgressListener progress;
|
||||
testresult.addListener (&progress);
|
||||
|
||||
CppUnit::TestRunner testrunner;
|
||||
testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ());
|
||||
testrunner.run (testresult);
|
||||
CppUnit::TestRunner testrunner;
|
||||
testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ());
|
||||
testrunner.run (testresult);
|
||||
|
||||
CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||
compileroutputter.write ();
|
||||
CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||
compileroutputter.write ();
|
||||
|
||||
return collectedresults.wasSuccessful () ? 0 : 1;
|
||||
return collectedresults.wasSuccessful () ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user