diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/midi_ring_buffer.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/note.h | 1 | ||||
-rw-r--r-- | libs/ardour/midi_model.cc | 34 | ||||
-rw-r--r-- | libs/ardour/note.cc | 14 | ||||
-rw-r--r-- | libs/ardour/smf_source.cc | 14 |
5 files changed, 50 insertions, 19 deletions
diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index b514ea2bc2..c817866600 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -368,8 +368,9 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t break; bool success = MidiRingBufferBase<Byte>::full_read(sizeof(double), (Byte*)&ev.time()); - if (success) + if (success) { success = MidiRingBufferBase<Byte>::full_read(sizeof(size_t), (Byte*)&ev.size()); + } if (!success) { std::cerr << "MRB: READ ERROR (time/size)" << std::endl; @@ -377,8 +378,9 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t } Byte first_event_byte; - if(success) + if(success) { success = full_peek(sizeof(Byte), &first_event_byte); + } // could this ever happen??? if (!success) { diff --git a/libs/ardour/ardour/note.h b/libs/ardour/ardour/note.h index 713d732113..f32a2e75f9 100644 --- a/libs/ardour/ardour/note.h +++ b/libs/ardour/ardour/note.h @@ -36,6 +36,7 @@ class Note { public: Note(uint8_t chan=0, double time=0, double dur=0, uint8_t note=0, uint8_t vel=0x40); Note(const Note& copy); + ~Note(); const Note& operator=(const Note& copy); diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index e544a64afb..8c6f569c5c 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -143,14 +143,16 @@ MidiModel::const_iterator::const_iterator(const MidiModel& model, double t) MidiModel::const_iterator::~const_iterator() { - if (_locked) + if (_locked) { _model->read_unlock(); + } } const MidiModel::const_iterator& MidiModel::const_iterator::operator++() { - if (_is_end) + if (_is_end) { throw std::logic_error("Attempt to iterate past end of MidiModel"); + } /*cerr << "const_iterator::operator++: _event type:" << hex << "0x" << int(_event.type()) << " buffer: 0x" << int(_event.buffer()[0]) << " 0x" << int(_event.buffer()[1]) @@ -264,7 +266,7 @@ MidiModel::const_iterator& MidiModel::const_iterator::operator=(const const_iter size_t index = other._control_iter - other._control_iters.begin(); _control_iter = _control_iters.begin() + index; - assert( ! _event.owns_buffer()); + assert( !_event.owns_buffer() ); return *this; } @@ -312,13 +314,13 @@ size_t MidiModel::read(MidiRingBuffer& dst, nframes_t start, nframes_t nframes, dst.write(_read_iter->time() + stamp_offset - negative_stamp_offset, _read_iter->size(), _read_iter->buffer()); - /* + cerr << this << " MidiModel::read event @ " << _read_iter->time() << " type: " << hex << int(_read_iter->type()) << dec - << " note: " << int(_read_iter->note()) - << " velocity: " << int(_read_iter->velocity()) + //<< " note: " << int(_read_iter->note()) + //<< " velocity: " << int(_read_iter->velocity()) << endl; - */ + ++_read_iter; ++read_events; @@ -334,8 +336,9 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev, switch (iter.automation_list->parameter().type()) { case MidiCCAutomation: - if (ev.size() < 3) + if (ev.size() < 3) { ev.set_buffer((Byte*)malloc(3), true); + } assert(iter.automation_list); assert(iter.automation_list->parameter().channel() < 16); @@ -349,8 +352,9 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev, return true; case MidiPgmChangeAutomation: - if (ev.size() < 3) + if (ev.size() < 3) { ev.set_buffer((Byte*)malloc(3), true); + } assert(iter.automation_list); assert(iter.automation_list->parameter().channel() < 16); @@ -364,8 +368,9 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev, return true; case MidiPitchBenderAutomation: - if (ev.size() < 3) + if (ev.size() < 3) { ev.set_buffer((Byte*)malloc(3), true); + } assert(iter.automation_list); assert(iter.automation_list->parameter().channel() < 16); @@ -379,8 +384,9 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev, return true; case MidiChannelAftertouchAutomation: - if (ev.size() < 3) + if (ev.size() < 3) { ev.set_buffer((Byte*)malloc(3), true); + } assert(iter.automation_list); assert(iter.automation_list->parameter().channel() < 16); @@ -528,7 +534,8 @@ void MidiModel::append_note_on_unlocked(uint8_t chan, double time, assert(_writing); _edited = true; - _notes.push_back(boost::shared_ptr<Note>(new Note(chan, time, 0, note_num, velocity))); + boost::shared_ptr<Note> new_note(new Note(chan, time, 0, note_num, velocity)); + _notes.push_back(new_note); if (_note_mode == Sustained) { //cerr << "MM Sustained: Appending active note on " << (unsigned)(uint8_t)note_num << endl; _write_notes[chan].push_back(_notes.size() - 1); @@ -896,8 +903,9 @@ bool MidiModel::write_to(boost::shared_ptr<MidiSource> source) const NoteMode old_note_mode = _note_mode; _note_mode = Sustained; - for (const_iterator i = begin(); i != end(); ++i) + for (const_iterator i = begin(); i != end(); ++i) { source->append_event_unlocked(Frames, *i); + } _note_mode = old_note_mode; diff --git a/libs/ardour/note.cc b/libs/ardour/note.cc index 0ddd745242..ea1e7133af 100644 --- a/libs/ardour/note.cc +++ b/libs/ardour/note.cc @@ -19,6 +19,7 @@ */ #include <ardour/note.h> +#include <iostream> namespace ARDOUR { @@ -40,7 +41,8 @@ Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v) assert(duration() == d); assert(note() == n); assert(velocity() == v); - assert(_on_event.channel() == _off_event.channel()); + assert(_on_event.channel() == _off_event.channel()); + assert(channel() == chan); } @@ -69,6 +71,16 @@ Note::Note(const Note& copy) assert(channel() == copy.channel()); } +Note::~Note() +{ + std::cerr << "Note::~Note() Note time: " << time() + << " pitch: " << int(note()) + << " duration: " << duration() + << " end-time: " << end_time() + << " velocity: " << int(velocity()) + << std::endl; +} + const Note& Note::operator=(const Note& copy) diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 8c2ee6031f..4ab7a9b973 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -194,8 +194,15 @@ SMFSource::seek_to_footer_position() // lets check if there is a track end marker at the end of the data fseek(_fd, -4, SEEK_END); + //cerr << "SMFSource::seek_to_footer_position: At position: " << ftell(_fd); size_t read_bytes = fread(buffer, sizeof(uint8_t), 4, _fd); - //cerr << "SMFSource::seek_to_footer_position: read size: " << read_bytes << endl; + /*cerr << " read size: " << read_bytes << " buffer: "; + for (size_t i=0; i < read_bytes; ++i) { + printf("%x ", buffer[i]); + } + printf("\n"); + */ + if( (read_bytes == 4) && buffer[0] == 0x00 && buffer[1] == 0xFF && @@ -244,6 +251,7 @@ SMFSource::flush_footer() //cerr << path() << " SMF Flushing footer\n"; seek_to_footer_position(); write_footer(); + seek_to_footer_position(); return 0; } @@ -491,8 +499,8 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt) void SMFSource::append_event_unlocked(EventTimeUnit unit, const MIDI::Event& ev) { - /*printf("SMFSource: %s - append_event_unlocked chan = %u, time = %lf, size = %u, data = ", - name().c_str(), (unsigned)ev.channel(), ev.time(), ev.size()); */ + printf("SMFSource: %s - append_event_unlocked chan = %u, time = %lf, size = %u, data = ", + name().c_str(), (unsigned)ev.channel(), ev.time(), ev.size()); for (size_t i=0; i < ev.size(); ++i) { printf("%X ", ev.buffer()[i]); } |