summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/canvas-program-change.cc1
-rw-r--r--gtk2_ardour/midi_region_view.cc5
-rw-r--r--libs/ardour/ardour/midi_util.h3
-rw-r--r--libs/ardour/ardour/parameter.h2
-rw-r--r--libs/ardour/midi_model.cc28
5 files changed, 22 insertions, 17 deletions
diff --git a/gtk2_ardour/canvas-program-change.cc b/gtk2_ardour/canvas-program-change.cc
index 103bd7bb8d..ccaf333ef5 100644
--- a/gtk2_ardour/canvas-program-change.cc
+++ b/gtk2_ardour/canvas-program-change.cc
@@ -21,6 +21,7 @@ CanvasProgramChange::CanvasProgramChange(
_widget(0)
{
_text = new Text(*this);
+ assert(_text);
ostringstream pgm(ios::ate);
pgm << int(event->pgm_number());
_text->property_text() = pgm.str();
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 69f756f3ca..bc492b0e71 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -672,8 +672,9 @@ MidiRegionView::begin_write()
{
assert(!_active_notes);
_active_notes = new CanvasNote*[128];
- for (unsigned i=0; i < 128; ++i)
+ for (unsigned i=0; i < 128; ++i) {
_active_notes[i] = NULL;
+ }
}
@@ -765,6 +766,8 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
if (note->duration() == 0) {
+ assert(_active_notes);
+ assert(note->note() < 128);
_active_notes[note->note()] = ev_rect;
/* outline all but right edge */
ev_rect->property_outline_what() = (guint32) (0x1 & 0x4 & 0x8);
diff --git a/libs/ardour/ardour/midi_util.h b/libs/ardour/ardour/midi_util.h
index efcb6a7cd5..6bcc6278e1 100644
--- a/libs/ardour/ardour/midi_util.h
+++ b/libs/ardour/ardour/midi_util.h
@@ -31,7 +31,8 @@ namespace ARDOUR {
static inline int
midi_event_size(unsigned char status)
{
- if (status >= 0x80 && status <= 0xE0) {
+ // if we have a channel event
+ if (status >= 0x80 && status < 0xF0) {
status &= 0xF0; // mask off the channel
}
diff --git a/libs/ardour/ardour/parameter.h b/libs/ardour/ardour/parameter.h
index a602419e14..a795ee0eaa 100644
--- a/libs/ardour/ardour/parameter.h
+++ b/libs/ardour/ardour/parameter.h
@@ -59,7 +59,7 @@ public:
inline uint8_t channel() const { return _channel; }
inline bool operator==(const Parameter& id) const {
- return (_type == id._type && _id == id._id);
+ return (_type == id._type && _id == id._id && _channel == id._channel);
}
/** Arbitrary but fixed ordering (for use in e.g. std::map) */
diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc
index 8c6f569c5c..3cef80deb6 100644
--- a/libs/ardour/midi_model.cc
+++ b/libs/ardour/midi_model.cc
@@ -171,7 +171,7 @@ const MidiModel::const_iterator& MidiModel::const_iterator::operator++()
//cerr << "control_iter x:" << _control_iter->x << " y:" << _control_iter->y << endl;
if (ret) {
- cerr << "Incremented " << _control_iter->automation_list->parameter().id() << " to " << x << endl;
+ //cerr << "Incremented " << _control_iter->automation_list->parameter().id() << " to " << x << endl;
_control_iter->x = x;
_control_iter->y = y;
} else {
@@ -243,10 +243,11 @@ const MidiModel::const_iterator& MidiModel::const_iterator::operator++()
bool MidiModel::const_iterator::operator==(const const_iterator& other) const
{
- if (_is_end || other._is_end)
+ if (_is_end || other._is_end) {
return (_is_end == other._is_end);
- else
+ } else {
return (_event == other._event);
+ }
}
MidiModel::const_iterator& MidiModel::const_iterator::operator=(const const_iterator& other)
@@ -352,17 +353,16 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev,
return true;
case MidiPgmChangeAutomation:
- if (ev.size() < 3) {
- ev.set_buffer((Byte*)malloc(3), true);
+ if (ev.size() < 2) {
+ ev.set_buffer((Byte*)malloc(2), true);
}
assert(iter.automation_list);
assert(iter.automation_list->parameter().channel() < 16);
- assert(iter.automation_list->parameter().id() <= INT8_MAX);
+ assert(iter.automation_list->parameter().id() == 0);
assert(iter.y <= INT8_MAX);
ev.buffer()[0] = MIDI_CMD_PGM_CHANGE + iter.automation_list->parameter().channel();
ev.buffer()[1] = (Byte)iter.y;
- ev.buffer()[2] = 0;
ev.time() = iter.x;
ev.size() = 3;
return true;
@@ -374,7 +374,7 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev,
assert(iter.automation_list);
assert(iter.automation_list->parameter().channel() < 16);
- assert(iter.automation_list->parameter().id() <= INT8_MAX);
+ assert(iter.automation_list->parameter().id() == 0);
assert(iter.y < (1<<14));
ev.buffer()[0] = MIDI_CMD_BENDER + iter.automation_list->parameter().channel();
ev.buffer()[1] = ((Byte)iter.y) & 0x7F; // LSB
@@ -384,18 +384,17 @@ bool MidiModel::control_to_midi_event(MIDI::Event& ev,
return true;
case MidiChannelAftertouchAutomation:
- if (ev.size() < 3) {
- ev.set_buffer((Byte*)malloc(3), true);
+ if (ev.size() < 2) {
+ ev.set_buffer((Byte*)malloc(2), true);
}
assert(iter.automation_list);
assert(iter.automation_list->parameter().channel() < 16);
- assert(iter.automation_list->parameter().id() <= INT8_MAX);
+ assert(iter.automation_list->parameter().id() == 0);
assert(iter.y <= INT8_MAX);
ev.buffer()[0]
= MIDI_CMD_CHANNEL_PRESSURE + iter.automation_list->parameter().channel();
ev.buffer()[1] = (Byte)iter.y;
- ev.buffer()[2] = 0;
ev.time() = iter.x;
ev.size() = 3;
return true;
@@ -580,9 +579,10 @@ void MidiModel::append_note_off_unlocked(uint8_t chan, double time,
}
}
- if (!resolved)
+ if (!resolved) {
cerr << "MidiModel " << this << " spurious note off chan " << (int)chan
<< ", note " << (int)note_num << " @ " << time << endl;
+ }
}
void MidiModel::append_automation_event_unlocked(AutomationType type,
@@ -618,7 +618,7 @@ void MidiModel::append_automation_event_unlocked(AutomationType type,
Parameter param(type, id, chan);
boost::shared_ptr<AutomationControl> control = Automatable::control(param, true);
- control->list()->fast_simple_add(time, value);
+ control->list()->rt_add(time, value);
/*cerr << "control list size after fast simple add: " << control->list()->size() << endl;*/
}