#include "ardour/midi_playlist.h"
#include "ardour/midi_port.h"
#include "ardour/midi_track.h"
+#include "ardour/parameter_types.h"
#include "ardour/port.h"
#include "ardour/processor.h"
#include "ardour/session.h"
boost::shared_ptr<Diskstream>
MidiTrack::create_diskstream ()
{
- MidiDiskstream::Flag dflags = MidiDiskstream::Flag (0);
-
- if (_flags & Auditioner) {
- dflags = MidiDiskstream::Flag (dflags | MidiDiskstream::Hidden);
- } else {
- dflags = MidiDiskstream::Flag (dflags | MidiDiskstream::Recordable);
- }
+ MidiDiskstream::Flag dflags = MidiDiskstream::Flag (MidiDiskstream::Recordable);
assert(_mode != Destructive);
* the last argument ("stop on overflow in destination") so that we'll
* ship the rest out next time.
*
- * the (nframes-1) argument puts all these events at the last
+ * the Port::port_offset() + (nframes-1) argument puts all these events at the last
* possible position of the output buffer, so that we do not
- * violate monotonicity when writing.
+ * violate monotonicity when writing. Port::port_offset() will
+ * be non-zero if we're in a split process cycle.
*/
-
- _immediate_events.read (buf, 0, 1, nframes-1, true);
+ _immediate_events.read (buf, 0, 1, Port::port_offset() + nframes - 1, true);
}
}
int
MidiTrack::export_stuff (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framecnt_t /*nframes*/,
- boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/, bool /*forexport*/)
+ boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/, bool /*for_export*/, bool /*for_freeze*/)
{
return -1;
}
cerr << "WARNING: Ignoring illegal immediate MIDI event" << endl;
return false;
}
- const uint32_t type = EventTypeMap::instance().midi_event_type(buf[0]);
- return (_immediate_events.write(0, type, size, buf) == size);
+ const uint32_t type = midi_parameter_type(buf[0]);
+ return (_immediate_events.write (0, type, size, buf) == size);
+}
+
+void
+MidiTrack::set_parameter_automation_state (Evoral::Parameter param, AutoState state)
+{
+ switch (param.type()) {
+ case MidiCCAutomation:
+ case MidiPgmChangeAutomation:
+ case MidiPitchBenderAutomation:
+ case MidiChannelPressureAutomation:
+ case MidiSystemExclusiveAutomation:
+ /* The track control for MIDI parameters is for immediate events to act
+ as a control surface, write/touch for them is not currently
+ supported. */
+ return;
+ default:
+ Automatable::set_parameter_automation_state(param, state);
+ }
}
void
MidiTrack::MidiControl::set_value(double val)
{
+ const Evoral::Parameter ¶meter = _list ? _list->parameter() : Control::parameter();
+
bool valid = false;
if (isinf(val)) {
cerr << "MIDIControl value is infinity" << endl;
} else if (isnan(val)) {
cerr << "MIDIControl value is NaN" << endl;
- } else if (val < _list->parameter().min()) {
- cerr << "MIDIControl value is < " << _list->parameter().min() << endl;
- } else if (val > _list->parameter().max()) {
- cerr << "MIDIControl value is > " << _list->parameter().max() << endl;
+ } else if (val < parameter.min()) {
+ cerr << "MIDIControl value is < " << parameter.min() << endl;
+ } else if (val > parameter.max()) {
+ cerr << "MIDIControl value is > " << parameter.max() << endl;
} else {
valid = true;
}
return;
}
- assert(val <= _list->parameter().max());
- if ( ! automation_playback()) {
+ assert(val <= parameter.max());
+ if ( ! _list || ! automation_playback()) {
size_t size = 3;
- uint8_t ev[3] = { _list->parameter().channel(), uint8_t (val), 0 };
- switch(_list->parameter().type()) {
+ uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };
+ switch(parameter.type()) {
case MidiCCAutomation:
ev[0] += MIDI_CMD_CONTROL;
- ev[1] = _list->parameter().id();
+ ev[1] = parameter.id();
ev[2] = int(val);
break;