diff options
author | David Robillard <d@drobilla.net> | 2009-05-04 21:26:46 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-04 21:26:46 +0000 |
commit | cefbb08c408e9a564c9bd7417e8d5e758eceafa1 (patch) | |
tree | 0a9ecc983a538e73823121c9fa5b22fb1f9de99d /libs | |
parent | c892bc35c8048514a07499871a23eb94cbd101c0 (diff) |
Fix MIDI monitoring while recording.
git-svn-id: svn://localhost/ardour2/branches/3.0@5043 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/midi_diskstream.h | 6 | ||||
-rw-r--r-- | libs/ardour/audio_diskstream.cc | 11 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 27 | ||||
-rw-r--r-- | libs/ardour/midi_track.cc | 1 |
4 files changed, 23 insertions, 22 deletions
diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index 839e35ea5b..a7b4f5e120 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -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! diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index d424d81c11..5c73d826bf 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -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; } diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 5ae09aaeeb..a0ef073c3a 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -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 diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 8451d538bf..1fe15a16bf 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -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; } |