, _source_port(0)
, _capture_transition_buf(0)
, _last_flush_frame(0)
+ , _note_mode(Sustained)
{
/* prevent any write sources from being created */
, _source_port(0)
, _capture_transition_buf(0)
, _last_flush_frame(0)
+ , _note_mode(Sustained)
{
in_set_state = true;
init (Recordable);
Glib::Mutex::Lock lm (state_lock);
}
+
+void
+MidiDiskstream::non_realtime_locate (nframes_t position)
+{
+ //cerr << "MDS: non_realtime_locate: " << position << endl;
+ assert(_write_source);
+ _write_source->set_timeline_position (position);
+ seek(position, true); // correct?
+}
+
+
void
MidiDiskstream::non_realtime_input_change ()
{
_source_port = _io->midi_input(0);
- /* I don't get it....
- const char **connections = _io->input(0)->get_connections ();
-
- if (connections == 0 || connections[0] == 0) {
-
- if (_source_port) {
- // _source_port->disable_metering ();
- }
-
- _source_port = 0;
-
- } else {
- _source_port = dynamic_cast<MidiPort*>(
- _session.engine().get_port_by_name (connections[0]) );
- }
-
- if (connections) {
- free (connections);
- }*/
+ // do... stuff?
}
int
assert( ! yn);
return -1;
}
+
+void
+MidiDiskstream::set_note_mode (NoteMode m)
+{
+ _note_mode = m;
+ midi_playlist()->set_note_mode(m);
+ if (_write_source && _write_source->model())
+ _write_source->model()->set_note_mode(m);
+}
void
MidiDiskstream::check_record_status (nframes_t transport_frame, nframes_t nframes, bool can_record)
size_t num_events = _source_port->get_midi_buffer().size();
size_t to_write = std::min(_capture_buf->write_space(), num_events);
+ MidiBuffer::iterator port_iter = _source_port->get_midi_buffer().begin();
+
for (size_t i=0; i < to_write; ++i) {
- MidiEvent& ev = _source_port->get_midi_buffer()[i];
- _capture_buf->write(ev.time + transport_frame, ev.size, ev.buffer);
+ const MidiEvent& ev = *port_iter;
+ _capture_buf->write(ev.time() + transport_frame, ev.size(), ev.buffer());
+ ++port_iter;
}
} else {
// XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
// Write into playback buffer here, and whatnot?
- cerr << "MDS FIXME: collect playback" << endl;
+ //cerr << "MDS FIXME: collect playback" << endl;
}
int
MidiDiskstream::overwrite_existing_buffers ()
{
+ cerr << "MDS: overwrite_existing_buffers() (does nothing)" << endl;
return 0;
}
{
Glib::Mutex::Lock lm (state_lock);
int ret = -1;
+
+ //cerr << "MDS: seek: " << frame << endl;
_playback_buf->reset();
_capture_buf->reset();
int
MidiDiskstream::internal_playback_seek (nframes_t distance)
{
+ cerr << "MDS: internal_playback_seek " << distance << endl;
+
first_recordable_frame += distance;
playback_sample += distance;
return 0;
}
- /* if there are 2+ chunks of disk i/o possible for
- this track, let the caller know so that it can arrange
- for us to be called again, ASAP.
- */
-
- // FIXME: using disk_io_chunk_frames as an event count, not good
- // count vs duration semantic differences are nonexistant for audio,
- // which makes translating for MIDI code confusing...
- if (_playback_buf->write_space() >= (_slaved?3:2) * disk_io_chunk_frames) {
- ret = 1;
- }
-
/* if we're running close to normal speed and there isn't enough
space to do disk_io_chunk_frames of I/O, then don't bother.
*/
if ((write_space < disk_io_chunk_frames) && fabs (_actual_speed) < 2.0f) {
- cerr << "No refill 1\n";
+ //cerr << "No refill 1\n";
return 0;
}
*/
if (_slaved && write_space < (_playback_buf->capacity() / 2)) {
- cerr << "No refill 2\n";
+ //cerr << "No refill 2\n";
return 0;
}
if (reversed) {
- cerr << "No refill 3 (reverse)\n";
+ //cerr << "No refill 3 (reverse)\n";
return 0;
}
return 0;
}
-#if 0
- // or this
- if (file_frame > max_frames - total_space) {
-
- /* to close to the end: read what we can, and zero fill the rest */
-
- zero_fill = total_space - (max_frames - file_frame);
- total_space = max_frames - file_frame;
-
- } else {
- zero_fill = 0;
- }
-#endif
-
- // At this point we:
+ // At this point we...
assert(_playback_buf->write_space() > 0); // ... have something to write to, and
assert(file_frame <= max_frames); // ... something to write
- // So (read it, then) write it:
-
nframes_t file_frame_tmp = file_frame;
nframes_t to_read = min(disk_io_chunk_frames, (max_frames - file_frame));
/* figure out the name for this take */
srcs.push_back (_write_source);
- _write_source->update_header (capture_info.front()->start, when, twhen);
+ _write_source->set_timeline_position (capture_info.front()->start);
_write_source->set_captured_for (_name);
string whole_file_region_name;
capture_start_frame = 0;
}
+void
+MidiDiskstream::transport_looped (nframes_t transport_frame)
+{
+ if (was_recording) {
+
+ // adjust the capture length knowing that the data will be recorded to disk
+ // only necessary after the first loop where we're recording
+ if (capture_info.size() == 0) {
+ capture_captured += _capture_offset;
+
+ if (_alignment_style == ExistingMaterial) {
+ capture_captured += _session.worst_output_latency();
+ } else {
+ capture_captured += _roll_delay;
+ }
+ }
+
+ finish_capture (true);
+
+ // the next region will start recording via the normal mechanism
+ // we'll set the start position to the current transport pos
+ // no latency adjustment or capture offset needs to be made, as that already happened the first time
+ capture_start_frame = transport_frame;
+ first_recordable_frame = transport_frame; // mild lie
+ last_recordable_frame = max_frames;
+ was_recording = true;
+ }
+}
+
void
MidiDiskstream::finish_capture (bool rec_monitors_input)
{
_source_port->request_monitor_input (!(Config->get_auto_input() && rolling));
}
+ // FIXME: Why is this necessary? Isn't needed for AudioDiskstream...
+ if (!_write_source)
+ use_new_write_source();
+
+ _write_source->mark_streaming_midi_write_started (_note_mode, _session.transport_frame());
+
RecordEnableChanged (); /* EMIT SIGNAL */
}
if (_write_source) {
- if (SMFSource::is_empty (_write_source->path())) {
+ if (_write_source->is_empty ()) {
_write_source->mark_for_remove ();
_write_source.reset();
} else {
if (_write_source && mark_write_complete) {
_write_source->mark_streaming_write_completed ();
}
+
use_new_write_source (0);
if (record_enabled()) {
dst.clear();
assert(dst.size() == 0);
- // I think this happens with reverse varispeed? maybe?
+ // Reverse. ... We just don't do reverse, ok? Back off.
if (end <= start) {
- cerr << "MDS: Reverse? Skipping" << endl;
return;
}