Fix MIDI monitoring while recording.

git-svn-id: svn://localhost/ardour2/branches/3.0@5043 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-05-04 21:26:46 +00:00
parent c892bc35c8
commit cefbb08c40
4 changed files with 23 additions and 22 deletions

View File

@ -80,8 +80,10 @@ class MidiDiskstream : public Diskstream
int set_state(const XMLNode& node);
void monitor_input (bool);
boost::shared_ptr<SMFSource> write_source () { return _write_source; }
MidiRingBuffer<nframes_t>* playback_buffer () { return _playback_buf; }
MidiRingBuffer<nframes_t>* capture_buffer () { return _capture_buf; }
boost::shared_ptr<SMFSource> write_source () { return _write_source; }
int set_destructive (bool yn); // doom!

View File

@ -772,10 +772,13 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can
} else {
memcpy ((char *) chaninfo->playback_wrap_buffer, chaninfo->playback_vector.buf[0],
chaninfo->playback_vector.len[0] * sizeof (Sample));
memcpy (chaninfo->playback_wrap_buffer + chaninfo->playback_vector.len[0], chaninfo->playback_vector.buf[1],
(necessary_samples - chaninfo->playback_vector.len[0]) * sizeof (Sample));
memcpy ((char *) chaninfo->playback_wrap_buffer,
chaninfo->playback_vector.buf[0],
chaninfo->playback_vector.len[0] * sizeof (Sample));
memcpy (chaninfo->playback_wrap_buffer + chaninfo->playback_vector.len[0],
chaninfo->playback_vector.buf[1],
(necessary_samples - chaninfo->playback_vector.len[0])
* sizeof (Sample));
chaninfo->current_playback_buffer = chaninfo->playback_wrap_buffer;
}

View File

@ -424,7 +424,7 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can_
nframes_t rec_nframes = 0;
bool nominally_recording;
bool re = record_enabled ();
bool collect_playback = false;
bool collect_playback = true;
/* if we've already processed the frames corresponding to this call,
just return. this allows multiple routes that are taking input
@ -537,27 +537,23 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can_
if (rec_nframes) {
/* XXX XXX XXX XXX XXX XXX XXX XXX */
/* data will be written to disk */
if (rec_nframes == nframes && rec_offset == 0) {
playback_distance = nframes;
} else {
collect_playback = true;
}
adjust_capture_position = rec_nframes;
} else if (nominally_recording) {
cerr << "B" << endl;
/* can't do actual capture yet - waiting for latency effects to finish before we start*/
playback_distance = nframes;
collect_playback = false;
} else {
collect_playback = true;
}
if (collect_playback) {
@ -574,10 +570,13 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can_
necessary_samples = nframes;
}
// XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
// Write into playback buffer here, and whatnot?
//cerr << "MDS FIXME: collect playback" << endl;
// Pump entire port buffer into playback buffer (FIXME: split cycles?)
MidiBuffer& buf = _source_port->get_midi_buffer(nframes);
for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) {
const Evoral::MIDIEvent<MidiBuffer::TimeType> ev(*i, false);
assert(ev.buffer());
_playback_buf->write(ev.time() + transport_frame, ev.type(), ev.size(), ev.buffer());
}
}
ret = 0;
@ -1416,9 +1415,7 @@ void
MidiDiskstream::monitor_input (bool yn)
{
if (_source_port)
_source_port->request_monitor_input (yn);
else
cerr << "MidiDiskstream NO SOURCE PORT TO MONITOR\n";
_source_port->ensure_monitor_input (yn);
}
void

View File

@ -494,7 +494,6 @@ MidiTrack::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame,
if ((dret = diskstream->process (transport_frame, nframes, can_record, rec_monitors_input)) != 0) {
silence (nframes);
return dret;
}