Fix more broken whitespace.
git-svn-id: svn://localhost/ardour2/branches/3.0@8314 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
7e3404e2a0
commit
f6ed36a457
|
@ -35,12 +35,12 @@ class TempoMap;
|
|||
*/
|
||||
class BeatsFramesConverter : public Evoral::TimeConverter<double,framepos_t> {
|
||||
public:
|
||||
BeatsFramesConverter (const TempoMap& tempo_map, framepos_t origin)
|
||||
: Evoral::TimeConverter<double, framepos_t> (origin)
|
||||
, _tempo_map(tempo_map)
|
||||
{}
|
||||
BeatsFramesConverter (const TempoMap& tempo_map, framepos_t origin)
|
||||
: Evoral::TimeConverter<double, framepos_t> (origin)
|
||||
, _tempo_map(tempo_map)
|
||||
{}
|
||||
|
||||
framepos_t to (double beats) const;
|
||||
framepos_t to (double beats) const;
|
||||
double from (framepos_t frames) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -62,7 +62,7 @@ class MidiRegion : public Region
|
|||
|
||||
~MidiRegion();
|
||||
|
||||
boost::shared_ptr<MidiRegion> clone ();
|
||||
boost::shared_ptr<MidiRegion> clone ();
|
||||
|
||||
boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
|
||||
|
||||
|
@ -71,17 +71,17 @@ class MidiRegion : public Region
|
|||
virtual framecnt_t readable_length() const { return length(); }
|
||||
|
||||
framecnt_t read_at (Evoral::EventSink<framepos_t>& dst,
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained,
|
||||
MidiStateTracker* tracker = 0) const;
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained,
|
||||
MidiStateTracker* tracker = 0) const;
|
||||
|
||||
framepos_t master_read_at (MidiRingBuffer<framepos_t>& dst,
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained) const;
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained) const;
|
||||
|
||||
XMLNode& state ();
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
@ -117,38 +117,38 @@ class MidiRegion : public Region
|
|||
|
||||
private:
|
||||
friend class RegionFactory;
|
||||
PBD::Property<Evoral::MusicalTime> _length_beats;
|
||||
PBD::Property<Evoral::MusicalTime> _length_beats;
|
||||
|
||||
MidiRegion (const SourceList&);
|
||||
MidiRegion (boost::shared_ptr<const MidiRegion>, frameoffset_t offset = 0, bool offset_relative = true);
|
||||
|
||||
framecnt_t _read_at (const SourceList&, Evoral::EventSink<framepos_t>& dst,
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained,
|
||||
MidiStateTracker* tracker = 0) const;
|
||||
framepos_t position,
|
||||
framecnt_t dur,
|
||||
uint32_t chan_n = 0,
|
||||
NoteMode mode = Sustained,
|
||||
MidiStateTracker* tracker = 0) const;
|
||||
|
||||
void register_properties ();
|
||||
void post_set (const PBD::PropertyChange&);
|
||||
void post_set (const PBD::PropertyChange&);
|
||||
|
||||
void recompute_at_start ();
|
||||
void recompute_at_end ();
|
||||
|
||||
void set_position_internal (framepos_t pos, bool allow_bbt_recompute);
|
||||
void set_length_internal (framecnt_t len);
|
||||
void update_length_beats ();
|
||||
void set_length_internal (framecnt_t len);
|
||||
void update_length_beats ();
|
||||
|
||||
void model_changed ();
|
||||
void model_automation_state_changed (Evoral::Parameter const &);
|
||||
void model_contents_changed ();
|
||||
void model_contents_changed ();
|
||||
|
||||
std::set<Evoral::Parameter> _filtered_parameters; ///< parameters that we ask our source not to return when reading
|
||||
PBD::ScopedConnection _model_connection;
|
||||
PBD::ScopedConnection _source_connection;
|
||||
PBD::ScopedConnection _model_contents_connection;
|
||||
PBD::ScopedConnection _model_contents_connection;
|
||||
|
||||
double _last_length_beats;
|
||||
double _last_length_beats;
|
||||
};
|
||||
|
||||
} /* namespace ARDOUR */
|
||||
|
|
|
@ -96,6 +96,7 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
|
|||
int set_state (const XMLNode&, int version);
|
||||
|
||||
bool length_mutable() const { return true; }
|
||||
double length_beats() const { return _length_beats; }
|
||||
|
||||
virtual void load_model(bool lock=true, bool force_reload=false) = 0;
|
||||
virtual void destroy_model() = 0;
|
||||
|
@ -150,7 +151,7 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
|
|||
mutable Evoral::Sequence<Evoral::MusicalTime>::const_iterator _model_iter;
|
||||
mutable bool _model_iter_valid;
|
||||
|
||||
mutable double _length_beats;
|
||||
mutable double _length_beats;
|
||||
mutable framepos_t _last_read_end;
|
||||
framepos_t _last_write_end;
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@ namespace ARDOUR {
|
|||
framecnt_t
|
||||
BeatsFramesConverter::to (double beats) const
|
||||
{
|
||||
return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)) - _origin_b;
|
||||
return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)) - _origin_b;
|
||||
}
|
||||
|
||||
double
|
||||
BeatsFramesConverter::from (framecnt_t frames) const
|
||||
{
|
||||
return _tempo_map.framewalk_to_beats (_origin_b, frames);
|
||||
return _tempo_map.framewalk_to_beats (_origin_b, frames);
|
||||
}
|
||||
|
||||
} /* namespace ARDOUR */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -51,16 +51,16 @@ namespace ARDOUR {
|
|||
namespace Properties {
|
||||
PBD::PropertyDescriptor<void*> midi_data;
|
||||
PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegion::make_property_quarks ()
|
||||
{
|
||||
Properties::midi_data.property_id = g_quark_from_static_string (X_("midi-data"));
|
||||
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for midi-data = %1\n", Properties::midi_data.property_id));
|
||||
Properties::length_beats.property_id = g_quark_from_static_string (X_("length-beats"));
|
||||
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length-beats = %1\n", Properties::length_beats.property_id));
|
||||
Properties::midi_data.property_id = g_quark_from_static_string (X_("midi-data"));
|
||||
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for midi-data = %1\n", Properties::midi_data.property_id));
|
||||
Properties::length_beats.property_id = g_quark_from_static_string (X_("length-beats"));
|
||||
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length-beats = %1\n", Properties::length_beats.property_id));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -72,10 +72,12 @@ MidiRegion::register_properties ()
|
|||
/* Basic MidiRegion constructor (many channels) */
|
||||
MidiRegion::MidiRegion (const SourceList& srcs)
|
||||
: Region (srcs)
|
||||
, _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0)
|
||||
, _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0)
|
||||
{
|
||||
update_length_beats ();
|
||||
register_properties ();
|
||||
_length_beats = midi_source(0)->length_beats();
|
||||
cout << "NEW MIDI REGION LENGTH BEATS: " << _length_beats << endl;
|
||||
|
||||
register_properties ();
|
||||
|
||||
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
|
||||
model_changed ();
|
||||
|
@ -86,10 +88,10 @@ MidiRegion::MidiRegion (const SourceList& srcs)
|
|||
/** Create a new MidiRegion, that is part of an existing one */
|
||||
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset, bool offset_relative)
|
||||
: Region (other, offset, offset_relative)
|
||||
, _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0)
|
||||
, _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0)
|
||||
{
|
||||
update_length_beats ();
|
||||
register_properties ();
|
||||
update_length_beats ();
|
||||
register_properties ();
|
||||
|
||||
assert(_name.val().find("/") == string::npos);
|
||||
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
|
||||
|
@ -105,60 +107,60 @@ MidiRegion::~MidiRegion ()
|
|||
boost::shared_ptr<MidiRegion>
|
||||
MidiRegion::clone ()
|
||||
{
|
||||
BeatsFramesConverter bfc (_session.tempo_map(), _position);
|
||||
BeatsFramesConverter bfc (_session.tempo_map(), _position);
|
||||
Evoral::MusicalTime const bbegin = bfc.from (_start);
|
||||
Evoral::MusicalTime const bend = bfc.from (_start + _length);
|
||||
|
||||
boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (bbegin, bend);
|
||||
boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (bbegin, bend);
|
||||
|
||||
PropertyList plist;
|
||||
PropertyList plist;
|
||||
|
||||
plist.add (Properties::name, ms->name());
|
||||
plist.add (Properties::whole_file, true);
|
||||
plist.add (Properties::start, _start);
|
||||
plist.add (Properties::length, _length);
|
||||
plist.add (Properties::length_beats, _length_beats);
|
||||
plist.add (Properties::layer, 0);
|
||||
plist.add (Properties::name, ms->name());
|
||||
plist.add (Properties::whole_file, true);
|
||||
plist.add (Properties::start, _start);
|
||||
plist.add (Properties::length, _length);
|
||||
plist.add (Properties::length_beats, _length_beats);
|
||||
plist.add (Properties::layer, 0);
|
||||
|
||||
return boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (ms, plist, true));
|
||||
return boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (ms, plist, true));
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegion::post_set (const PropertyChange& pc)
|
||||
{
|
||||
if (pc.contains (Properties::length) || pc.contains (Properties::position)) {
|
||||
update_length_beats ();
|
||||
}
|
||||
if (pc.contains (Properties::length) || pc.contains (Properties::position)) {
|
||||
update_length_beats ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegion::set_length_internal (framecnt_t len)
|
||||
{
|
||||
Region::set_length_internal (len);
|
||||
update_length_beats ();
|
||||
Region::set_length_internal (len);
|
||||
update_length_beats ();
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegion::update_length_beats ()
|
||||
{
|
||||
BeatsFramesConverter converter (_session.tempo_map(), _position);
|
||||
_length_beats = converter.from (_length);
|
||||
_length_beats = converter.from (_length);
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
|
||||
{
|
||||
Region::set_position_internal (pos, allow_bbt_recompute);
|
||||
/* zero length regions don't exist - so if _length_beats is zero, this object
|
||||
is under construction.
|
||||
*/
|
||||
if (_length_beats) {
|
||||
/* leave _length_beats alone, and change _length to reflect the state of things
|
||||
at the new position (tempo map may dictate a different number of frames
|
||||
*/
|
||||
BeatsFramesConverter converter (_session.tempo_map(), _position);
|
||||
Region::set_length_internal (converter.to (_length_beats));
|
||||
}
|
||||
/* zero length regions don't exist - so if _length_beats is zero, this object
|
||||
is under construction.
|
||||
*/
|
||||
if (_length_beats) {
|
||||
/* leave _length_beats alone, and change _length to reflect the state of things
|
||||
at the new position (tempo map may dictate a different number of frames
|
||||
*/
|
||||
BeatsFramesConverter converter (_session.tempo_map(), _position);
|
||||
Region::set_length_internal (converter.to (_length_beats));
|
||||
}
|
||||
}
|
||||
|
||||
framecnt_t
|
||||
|
@ -247,11 +249,11 @@ MidiRegion::set_state (const XMLNode& node, int version)
|
|||
{
|
||||
int ret = Region::set_state (node, version);
|
||||
|
||||
if (ret == 0) {
|
||||
update_length_beats ();
|
||||
}
|
||||
if (ret == 0) {
|
||||
update_length_beats ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -327,7 +329,7 @@ MidiRegion::model_changed ()
|
|||
void
|
||||
MidiRegion::model_contents_changed ()
|
||||
{
|
||||
send_change (PropertyChange (Properties::midi_data));
|
||||
send_change (PropertyChange (Properties::midi_data));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -358,7 +360,7 @@ MidiRegion::model_automation_state_changed (Evoral::Parameter const & p)
|
|||
void
|
||||
MidiRegion::fix_negative_start ()
|
||||
{
|
||||
BeatsFramesConverter c (_session.tempo_map(), _position);
|
||||
BeatsFramesConverter c (_session.tempo_map(), _position);
|
||||
|
||||
model()->insert_silence_at_start (c.from (-_start));
|
||||
_start = 0;
|
||||
|
|
|
@ -168,15 +168,15 @@ MidiSource::set_state (const XMLNode& node, int /*version*/)
|
|||
bool
|
||||
MidiSource::empty () const
|
||||
{
|
||||
return _length_beats == 0;
|
||||
return _length_beats == 0;
|
||||
}
|
||||
|
||||
framecnt_t
|
||||
MidiSource::length (framepos_t pos) const
|
||||
{
|
||||
if (_length_beats == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (_length_beats == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BeatsFramesConverter converter(_session.tempo_map(), pos);
|
||||
return converter.to(_length_beats);
|
||||
|
@ -200,7 +200,7 @@ framecnt_t
|
|||
MidiSource::midi_read (Evoral::EventSink<framepos_t>& dst, framepos_t source_start,
|
||||
framepos_t start, framecnt_t cnt,
|
||||
MidiStateTracker* tracker,
|
||||
std::set<Evoral::Parameter> const & filtered) const
|
||||
std::set<Evoral::Parameter> const & filtered) const
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
|
@ -298,86 +298,84 @@ MidiSource::mark_streaming_write_completed ()
|
|||
boost::shared_ptr<MidiSource>
|
||||
MidiSource::clone (Evoral::MusicalTime begin, Evoral::MusicalTime end)
|
||||
{
|
||||
string newname = PBD::basename_nosuffix(_name.val());
|
||||
string newpath;
|
||||
string newname = PBD::basename_nosuffix(_name.val());
|
||||
string newpath;
|
||||
|
||||
/* get a new name for the MIDI file we're going to write to
|
||||
*/
|
||||
/* get a new name for the MIDI file we're going to write to
|
||||
*/
|
||||
|
||||
do {
|
||||
do {
|
||||
|
||||
newname = bump_name_once (newname, '-');
|
||||
/* XXX build path safely */
|
||||
newpath = _session.session_directory().midi_path().to_string() +"/"+ newname + ".mid";
|
||||
newname = bump_name_once (newname, '-');
|
||||
/* XXX build path safely */
|
||||
newpath = _session.session_directory().midi_path().to_string() +"/"+ newname + ".mid";
|
||||
|
||||
} while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
|
||||
} while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
|
||||
|
||||
boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
|
||||
SourceFactory::createWritable(DataType::MIDI, _session,
|
||||
newpath, string(), false, _session.frame_rate()));
|
||||
boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
|
||||
SourceFactory::createWritable(DataType::MIDI, _session,
|
||||
newpath, string(), false, _session.frame_rate()));
|
||||
|
||||
newsrc->set_timeline_position(_timeline_position);
|
||||
newsrc->set_timeline_position(_timeline_position);
|
||||
newsrc->copy_interpolation_from (this);
|
||||
newsrc->copy_automation_state_from (this);
|
||||
|
||||
if (_model) {
|
||||
if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) {
|
||||
_model->write_to (newsrc);
|
||||
} else {
|
||||
_model->write_section_to (newsrc, begin, end);
|
||||
}
|
||||
} else {
|
||||
error << string_compose (_("programming error: %1"), X_("no model for MidiSource during ::clone()"));
|
||||
return boost::shared_ptr<MidiSource>();
|
||||
}
|
||||
if (_model) {
|
||||
if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) {
|
||||
_model->write_to (newsrc);
|
||||
} else {
|
||||
_model->write_section_to (newsrc, begin, end);
|
||||
}
|
||||
} else {
|
||||
error << string_compose (_("programming error: %1"), X_("no model for MidiSource during ::clone()"));
|
||||
return boost::shared_ptr<MidiSource>();
|
||||
}
|
||||
|
||||
newsrc->flush_midi();
|
||||
newsrc->flush_midi();
|
||||
|
||||
/* force a reload of the model if the range is partial */
|
||||
/* force a reload of the model if the range is partial */
|
||||
|
||||
if (begin != Evoral::MinMusicalTime || end != Evoral::MaxMusicalTime) {
|
||||
newsrc->load_model (true, true);
|
||||
} else {
|
||||
if (begin != Evoral::MinMusicalTime || end != Evoral::MaxMusicalTime) {
|
||||
newsrc->load_model (true, true);
|
||||
} else {
|
||||
newsrc->set_model (_model);
|
||||
}
|
||||
|
||||
return newsrc;
|
||||
return newsrc;
|
||||
}
|
||||
|
||||
void
|
||||
MidiSource::session_saved()
|
||||
{
|
||||
/* this writes a copy of the data to disk.
|
||||
XXX do we need to do this every time?
|
||||
*/
|
||||
/* this writes a copy of the data to disk.
|
||||
XXX do we need to do this every time?
|
||||
*/
|
||||
|
||||
if (_model && _model->edited()) {
|
||||
|
||||
// if the model is edited, write its contents into
|
||||
// the current source file (overwiting previous contents.
|
||||
|
||||
/* temporarily drop our reference to the model so that
|
||||
as the model pushes its current state to us, we don't
|
||||
try to update it.
|
||||
*/
|
||||
|
||||
// if the model is edited, write its contents into
|
||||
// the current source file (overwiting previous contents.
|
||||
boost::shared_ptr<MidiModel> mm = _model ;
|
||||
_model.reset ();
|
||||
|
||||
/* temporarily drop our reference to the model so that
|
||||
as the model pushes its current state to us, we don't
|
||||
try to update it.
|
||||
*/
|
||||
/* flush model contents to disk
|
||||
*/
|
||||
|
||||
boost::shared_ptr<MidiModel> mm = _model ;
|
||||
_model.reset ();
|
||||
mm->sync_to_source ();
|
||||
|
||||
/* flush model contents to disk
|
||||
*/
|
||||
/* reacquire model */
|
||||
|
||||
mm->sync_to_source ();
|
||||
_model = mm;
|
||||
|
||||
/* reacquire model */
|
||||
|
||||
_model = mm;
|
||||
|
||||
} else {
|
||||
flush_midi();
|
||||
}
|
||||
} else {
|
||||
flush_midi();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -391,7 +389,7 @@ MidiSource::set_note_mode(NoteMode mode)
|
|||
void
|
||||
MidiSource::drop_model ()
|
||||
{
|
||||
_model.reset();
|
||||
_model.reset();
|
||||
ModelChanged (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
|
|
|
@ -140,21 +140,20 @@ MidiStateTracker::resolve_notes (MidiSource& src, Evoral::MusicalTime time)
|
|||
return;
|
||||
}
|
||||
|
||||
/* NOTE: the src must be locked */
|
||||
/* NOTE: the src must be locked */
|
||||
|
||||
for (int channel = 0; channel < 16; ++channel) {
|
||||
for (int note = 0; note < 128; ++note) {
|
||||
while (_active_notes[note + 128 * channel]) {
|
||||
Evoral::MIDIEvent<Evoral::MusicalTime> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
|
||||
ev.set_type (MIDI_CMD_NOTE_OFF);
|
||||
ev.set_channel (channel);
|
||||
ev.set_note (note);
|
||||
ev.set_velocity (0);
|
||||
src.append_event_unlocked_beats (ev);
|
||||
Evoral::MIDIEvent<Evoral::MusicalTime> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
|
||||
ev.set_type (MIDI_CMD_NOTE_OFF);
|
||||
ev.set_channel (channel);
|
||||
ev.set_note (note);
|
||||
ev.set_velocity (0);
|
||||
src.append_event_unlocked_beats (ev);
|
||||
_active_notes[note + 128 * channel]--;
|
||||
/* don't stack events up at the same time
|
||||
*/
|
||||
time += 1.0/128.0;
|
||||
/* don't stack events up at the same time */
|
||||
time += 1.0/128.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
|
|||
, _smf_last_read_end (0)
|
||||
, _smf_last_read_time (0)
|
||||
{
|
||||
/* note that origin remains empty */
|
||||
/* note that origin remains empty */
|
||||
|
||||
if (init(_path, false)) {
|
||||
throw failed_constructor ();
|
||||
|
@ -131,7 +131,7 @@ SMFSource::read_unlocked (Evoral::EventSink<framepos_t>& destination, framepos_t
|
|||
DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked: seek to %1\n", start));
|
||||
Evoral::SMF::seek_to_start();
|
||||
while (time < start_ticks) {
|
||||
gint ignored;
|
||||
gint ignored;
|
||||
|
||||
ret = read_event(&ev_delta_t, &ev_size, &ev_buffer, &ignored);
|
||||
if (ret == -1) { // EOF
|
||||
|
@ -148,7 +148,7 @@ SMFSource::read_unlocked (Evoral::EventSink<framepos_t>& destination, framepos_t
|
|||
_smf_last_read_end = start + duration;
|
||||
|
||||
while (true) {
|
||||
gint ignored; /* XXX don't ignore note id's ??*/
|
||||
gint ignored; /* XXX don't ignore note id's ??*/
|
||||
|
||||
ret = read_event(&ev_delta_t, &ev_size, &ev_buffer, &ignored);
|
||||
if (ret == -1) { // EOF
|
||||
|
@ -250,7 +250,7 @@ SMFSource::write_unlocked (MidiRingBuffer<framepos_t>& source, framepos_t positi
|
|||
|
||||
ev.set(buf, size, time);
|
||||
ev.set_event_type(EventTypeMap::instance().midi_event_type(ev.buffer()[0]));
|
||||
ev.set_id (Evoral::next_event_id());
|
||||
ev.set_id (Evoral::next_event_id());
|
||||
|
||||
if (!(ev.is_channel_event() || ev.is_smf_meta_event() || ev.is_sysex())) {
|
||||
/*cerr << "SMFSource: WARNING: caller tried to write non SMF-Event of type "
|
||||
|
@ -287,13 +287,13 @@ SMFSource::append_event_unlocked_beats (const Evoral::Event<double>& ev)
|
|||
return;
|
||||
}
|
||||
|
||||
Evoral::event_id_t event_id;
|
||||
Evoral::event_id_t event_id;
|
||||
|
||||
if (ev.id() < 0) {
|
||||
event_id = Evoral::next_event_id();
|
||||
} else {
|
||||
event_id = ev.id();
|
||||
}
|
||||
if (ev.id() < 0) {
|
||||
event_id = Evoral::next_event_id();
|
||||
} else {
|
||||
event_id = ev.id();
|
||||
}
|
||||
|
||||
if (_model) {
|
||||
_model->append (ev, event_id);
|
||||
|
@ -330,28 +330,28 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event<framepos_t>& ev, fr
|
|||
}
|
||||
|
||||
BeatsFramesConverter converter(_session.tempo_map(), position);
|
||||
const double ev_time_beats = converter.from(ev.time());
|
||||
Evoral::event_id_t event_id;
|
||||
const double ev_time_beats = converter.from(ev.time());
|
||||
Evoral::event_id_t event_id;
|
||||
|
||||
if (ev.id() < 0) {
|
||||
event_id = Evoral::next_event_id();
|
||||
} else {
|
||||
event_id = ev.id();
|
||||
}
|
||||
if (ev.id() < 0) {
|
||||
event_id = Evoral::next_event_id();
|
||||
} else {
|
||||
event_id = ev.id();
|
||||
}
|
||||
|
||||
if (_model) {
|
||||
const Evoral::Event<double> beat_ev (ev.event_type(),
|
||||
ev_time_beats,
|
||||
ev.size(),
|
||||
(uint8_t*)ev.buffer());
|
||||
ev_time_beats,
|
||||
ev.size(),
|
||||
(uint8_t*)ev.buffer());
|
||||
_model->append (beat_ev, event_id);
|
||||
}
|
||||
|
||||
_length_beats = max(_length_beats, ev_time_beats);
|
||||
|
||||
const framepos_t delta_time_frames = ev.time() - _last_ev_time_frames;
|
||||
const double delta_time_beats = converter.from(delta_time_frames);
|
||||
const uint32_t delta_time_ticks = (uint32_t)(lrint(delta_time_beats * (double)ppqn()));
|
||||
const double delta_time_beats = converter.from(delta_time_frames);
|
||||
const uint32_t delta_time_ticks = (uint32_t)(lrint(delta_time_beats * (double)ppqn()));
|
||||
|
||||
Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id);
|
||||
_last_ev_time_frames = ev.time();
|
||||
|
@ -363,9 +363,9 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event<framepos_t>& ev, fr
|
|||
XMLNode&
|
||||
SMFSource::get_state ()
|
||||
{
|
||||
XMLNode& node = MidiSource::get_state();
|
||||
node.add_property (X_("origin"), _origin);
|
||||
return node;
|
||||
XMLNode& node = MidiSource::get_state();
|
||||
node.add_property (X_("origin"), _origin);
|
||||
return node;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -412,9 +412,9 @@ SMFSource::mark_streaming_write_completed ()
|
|||
|
||||
Evoral::SMF::end_write ();
|
||||
|
||||
/* data in the file now, not removable */
|
||||
/* data in the file now, not removable */
|
||||
|
||||
mark_nonremovable ();
|
||||
mark_nonremovable ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -456,63 +456,63 @@ SMFSource::load_model (bool lock, bool force_reload)
|
|||
uint32_t size = 0;
|
||||
uint8_t* buf = NULL;
|
||||
int ret;
|
||||
gint event_id;
|
||||
bool have_event_id = false;
|
||||
gint event_id;
|
||||
bool have_event_id = false;
|
||||
|
||||
while ((ret = read_event (&delta_t, &size, &buf, &event_id)) >= 0) {
|
||||
|
||||
time += delta_t;
|
||||
|
||||
if (ret == 0) {
|
||||
if (ret == 0) {
|
||||
|
||||
/* meta-event : did we get an event ID ?
|
||||
*/
|
||||
/* meta-event : did we get an event ID ?
|
||||
*/
|
||||
|
||||
if (event_id >= 0) {
|
||||
have_event_id = true;
|
||||
}
|
||||
if (event_id >= 0) {
|
||||
have_event_id = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ret > 0) {
|
||||
|
||||
/* not a meta-event */
|
||||
/* not a meta-event */
|
||||
|
||||
ev.set (buf, size, time / (double)ppqn());
|
||||
ev.set (buf, size, time / (double)ppqn());
|
||||
ev.set_event_type(EventTypeMap::instance().midi_event_type(buf[0]));
|
||||
|
||||
if (!have_event_id) {
|
||||
event_id = Evoral::next_event_id();
|
||||
}
|
||||
if (!have_event_id) {
|
||||
event_id = Evoral::next_event_id();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
std::string ss;
|
||||
std::string ss;
|
||||
|
||||
for (uint32_t xx = 0; xx < size; ++xx) {
|
||||
char b[8];
|
||||
snprintf (b, sizeof (b), "0x%x ", buf[xx]);
|
||||
ss += b;
|
||||
}
|
||||
for (uint32_t xx = 0; xx < size; ++xx) {
|
||||
char b[8];
|
||||
snprintf (b, sizeof (b), "0x%x ", buf[xx]);
|
||||
ss += b;
|
||||
}
|
||||
|
||||
DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %6 load model delta %1, time %2, size %3 buf %4, type %5\n",
|
||||
delta_t, time, size, ss , ev.event_type(), name()));
|
||||
DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %6 load model delta %1, time %2, size %3 buf %4, type %5\n",
|
||||
delta_t, time, size, ss , ev.event_type(), name()));
|
||||
#endif
|
||||
|
||||
_model->append (ev, event_id);
|
||||
|
||||
if (ev.size() > scratch_size) {
|
||||
scratch_size = ev.size();
|
||||
}
|
||||
if (ev.size() > scratch_size) {
|
||||
scratch_size = ev.size();
|
||||
}
|
||||
|
||||
ev.size() = scratch_size; // ensure read_event only allocates if necessary
|
||||
ev.size() = scratch_size; // ensure read_event only allocates if necessary
|
||||
|
||||
_length_beats = max(_length_beats, ev.time());
|
||||
}
|
||||
_length_beats = max(_length_beats, ev.time());
|
||||
}
|
||||
|
||||
/* event ID's must immediately precede the event they are for
|
||||
*/
|
||||
/* event ID's must immediately precede the event they are for
|
||||
*/
|
||||
|
||||
have_event_id = false;
|
||||
have_event_id = false;
|
||||
}
|
||||
|
||||
_model->end_write(false);
|
||||
|
@ -533,18 +533,18 @@ SMFSource::destroy_model ()
|
|||
void
|
||||
SMFSource::flush_midi ()
|
||||
{
|
||||
if (!writable()) {
|
||||
return;
|
||||
}
|
||||
if (!writable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Evoral::SMF::end_write();
|
||||
/* data in the file means its no longer removable */
|
||||
mark_nonremovable ();
|
||||
/* data in the file means its no longer removable */
|
||||
mark_nonremovable ();
|
||||
}
|
||||
|
||||
void
|
||||
SMFSource::set_path (const string& p)
|
||||
{
|
||||
FileSource::set_path (p);
|
||||
SMF::set_path (_path);
|
||||
FileSource::set_path (p);
|
||||
SMF::set_path (_path);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user