#include "pbd/compose.h"
#include "pbd/error.h"
+#include "evoral/Beats.hpp"
#include "evoral/Control.hpp"
#include "evoral/ControlList.hpp"
#include "evoral/ControlSet.hpp"
#include "evoral/TypeMap.hpp"
#include "evoral/midi_util.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace PBD;
// Use the next note off iff it's earlier or the same time as the note on
if ((!_active_notes.empty())) {
- if (_type == NIL || _active_notes.top()->end_time() <= earliest_t) {
+ if (_type == NIL || _active_notes.top()->end_time().to_double() <= earliest_t.to_double()) {
_type = NOTE_OFF;
earliest_t = _active_notes.top()->end_time();
}
switch (_type) {
case NOTE_ON:
DEBUG_TRACE(DEBUG::Sequence, "iterator = note on\n");
- *_event = (*_note_iter)->on_event();
+ _event->assign ((*_note_iter)->on_event());
_active_notes.push(*_note_iter);
break;
case NOTE_OFF:
DEBUG_TRACE(DEBUG::Sequence, "iterator = note off\n");
assert(!_active_notes.empty());
- *_event = _active_notes.top()->off_event();
+ _event->assign (_active_notes.top()->off_event());
// We don't pop the active note until we increment past it
break;
case SYSEX:
DEBUG_TRACE(DEBUG::Sequence, "iterator = sysex\n");
- *_event = *(*_sysex_iter);
+ _event->assign (*(*_sysex_iter));
break;
case CONTROL:
DEBUG_TRACE(DEBUG::Sequence, "iterator = control\n");
break;
case PATCH_CHANGE:
DEBUG_TRACE(DEBUG::Sequence, "iterator = program change\n");
- *_event = (*_patch_change_iter)->message (_active_patch_change_message);
+ _event->assign ((*_patch_change_iter)->message (_active_patch_change_message));
break;
default:
_is_end = true;
|| ev.is_pgm_change()
|| ev.is_pitch_bender()
|| ev.is_channel_pressure()
+ || ev.is_poly_pressure()
|| ev.is_sysex()) ) {
cerr << "WARNING: Unknown event (type " << _type << "): " << hex
<< int(ev.buffer()[0]) << int(ev.buffer()[1]) << int(ev.buffer()[2]) << endl;
uint8_t midi_type = _type_map.parameter_midi_type(iter.list->parameter());
ev->set_event_type(_type_map.midi_event_type(midi_type));
+ ev->set_id(-1);
switch (midi_type) {
case MIDI_CMD_CONTROL:
assert(iter.list.get());
ev->buffer()[2] = (uint16_t(iter.y) >> 7) & 0x7F; // MSB
break;
+ case MIDI_CMD_NOTE_PRESSURE:
+ assert(iter.list.get());
+ assert(iter.list->parameter().channel() < 16);
+ assert(iter.list->parameter().id() <= INT8_MAX);
+ assert(iter.y <= INT8_MAX);
+
+ ev->set_time(Time(iter.x));
+ ev->realloc(3);
+ ev->buffer()[0] = MIDI_CMD_NOTE_PRESSURE + iter.list->parameter().channel();
+ ev->buffer()[1] = (uint8_t)iter.list->parameter().id();
+ ev->buffer()[2] = (uint8_t)iter.y;
+ break;
+
case MIDI_CMD_CHANNEL_PRESSURE:
assert(iter.list.get());
assert(iter.list->parameter().channel() < 16);
*/
typename Sequence<Time>::Notes::iterator i;
-
+
for (i = note_lower_bound(note->time()); i != _notes.end() && (*i)->time() == note->time(); ++i) {
if (*i == note) {
* in this scenario, we have no choice other than to linear
* search the list of notes and find the note by ID.
*/
-
+
for (i = _notes.begin(); i != _notes.end(); ++i) {
if ((*i)->id() == note->id()) {
-
+
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1\tID-based pass, erasing note #%2 %3 @ %4\n", this, (*i)->id(), (int)(*i)->note(), (*i)->time()));
_notes.erase (i);
-
+
if (note->note() == _lowest_note || note->note() == _highest_note) {
-
+
_lowest_note = 127;
_highest_note = 0;
-
+
for (typename Sequence<Time>::Notes::iterator ii = _notes.begin(); ii != _notes.end(); ++ii) {
if ((*ii)->note() < _lowest_note)
_lowest_note = (*ii)->note();
_highest_note = (*ii)->note();
}
}
-
+
erased = true;
id_matched = true;
break;
}
}
}
-
+
if (erased) {
Pitches& p (pitches (note->channel()));
-
+
typename Pitches::iterator j;
/* if we had to ID-match above, we can't expect to find it in
* notes by channel+time. We care only about its note number
* so the search_note has all other properties unset.
*/
-
+
NotePtr search_note (new Note<Time>(0, Time(), Time(), note->note(), 0));
for (j = p.lower_bound (search_note); j != p.end() && (*j)->note() == note->note(); ++j) {
-
+
if ((*j) == note) {
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1\terasing pitch %2 @ %3\n", this, (int)(*j)->note(), (*j)->time()));
p.erase (j);
}
_edited = true;
-
+
} else {
cerr << "Unable to find note to erase matching " << *note.get() << endmsg;
}
ev.time(), double ((0x7F & ev.pitch_bender_msb()) << 7
| (0x7F & ev.pitch_bender_lsb())),
evid);
+ } else if (ev.is_poly_pressure()) {
+ append_control_unlocked (Parameter (ev.event_type(), ev.channel(), ev.poly_note()), ev.time(), ev.poly_pressure(), evid);
} else if (ev.is_channel_pressure()) {
append_control_unlocked(
Parameter(ev.event_type(), ev.channel()),
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1 %2 @ %3 = %4 # controls: %5\n",
this, _type_map.to_symbol(param), time, value, _controls.size()));
boost::shared_ptr<Control> c = control(param, true);
- c->list()->add (time.to_double(), value);
+ c->list()->add (time.to_double(), value, true, false);
/* XXX control events should use IDs */
}