* formatting/style guide

* bugfix: midi_util.h only considered channel events up to E0, but had to be EF
* bugfix: parameter.h operator == should also compare channel (drobilla, correct me if I am wrong)
* added some assert() guards


git-svn-id: svn://localhost/ardour2/branches/3.0@3330 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-05-09 16:10:36 +00:00
parent 8d44391f4b
commit 4e745fc17c
5 changed files with 22 additions and 17 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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
}

View File

@ -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) */

View File

@ -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;*/
}