#include "ardour/midi_track.h"
#include "ardour/region_factory.h"
#include "ardour/smf_source.h"
+#include "ardour/session.h"
#include "ardour_ui.h"
#include "canvas-simplerect.h"
_note_lines->property_x2() = trackview().editor().frame_to_pixel (max_frames);
_note_lines->property_y2() = 0;
- _note_lines->signal_event().connect(bind(
- mem_fun(_trackview.editor(), &PublicEditor::canvas_stream_view_event),
+ _note_lines->signal_event().connect(sigc::bind(
+ sigc::mem_fun(_trackview.editor(), &PublicEditor::canvas_stream_view_event),
_note_lines, &_trackview));
_note_lines->lower_to_bottom();
- ColorsChanged.connect(mem_fun(*this, &MidiStreamView::draw_note_lines));
+ ColorsChanged.connect(sigc::mem_fun(*this, &MidiStreamView::draw_note_lines));
note_range_adjustment.set_page_size(_highest_note - _lowest_note);
note_range_adjustment.set_value(_lowest_note);
note_range_adjustment.signal_value_changed().connect(
- mem_fun(*this, &MidiStreamView::note_range_adjustment_changed));
+ sigc::mem_fun(*this, &MidiStreamView::note_range_adjustment_changed));
}
MidiStreamView::~MidiStreamView ()
display_region (region_view, wfd);
/* catch regionview going away */
- region->GoingAway.connect (bind (mem_fun (*this, &MidiStreamView::remove_region_view), region));
+ region->GoingAway.connect (*this, boost::bind (&MidiStreamView::remove_region_view, this, region), gui_context());
RegionViewAdded (region_view);
{
// cerr << _trackview.name() << " streamview SRB\n";
- if (_trackview.session().transport_rolling()) {
+ if (_trackview.session()->transport_rolling()) {
if (!rec_active &&
- _trackview.session().record_status() == Session::Recording &&
+ _trackview.session()->record_status() == Session::Recording &&
_trackview.get_diskstream()->record_enabled()) {
if (use_rec_regions && rec_regions.size() == rec_rects.size()) {
MidiRegion::SourceList sources;
- for (list<sigc::connection>::iterator prc = rec_data_ready_connections.begin(); prc != rec_data_ready_connections.end(); ++prc) {
- (*prc).disconnect();
- }
- rec_data_ready_connections.clear();
+ rec_data_ready_connections.drop_connections ();
- // FIXME
- boost::shared_ptr<MidiDiskstream> mds = boost::dynamic_pointer_cast<MidiDiskstream>(_trackview.get_diskstream());
- assert(mds);
+ boost::shared_ptr<MidiDiskstream> mds = _trackview.midi_track()->midi_diskstream();
sources.push_back(mds->write_source());
- rec_data_ready_connections.push_back (mds->write_source()->ViewDataRangeReady.connect (bind (mem_fun (*this, &MidiStreamView::rec_data_range_ready), boost::weak_ptr<Source>(mds->write_source()))));
+ mds->write_source()->ViewDataRangeReady.connect
+ (rec_data_ready_connections,
+ ui_bind (&MidiStreamView::rec_data_range_ready, this, _1, _2, boost::weak_ptr<Source>(mds->write_source())),
+ gui_context());
// handle multi
- jack_nframes_t start = 0;
+ nframes_t start = 0;
if (rec_regions.size() > 0) {
- start = rec_regions.back().first->position() + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1);
+ start = rec_regions.back().first->start()
+ + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1);
}
boost::shared_ptr<MidiRegion> region (boost::dynamic_pointer_cast<MidiRegion>
(RegionFactory::create (sources, start, 1 , "", 0, Region::DefaultFlags, false)));
+
assert(region);
region->block_property_changes ();
- region->set_position (_trackview.session().transport_frame(), this);
+ region->set_position (_trackview.session()->transport_frame(), this);
rec_regions.push_back (make_pair(region, (RegionView*)0));
// rec regions are destroyed in setup_rec_box
boost::shared_ptr<MidiTrack> mt = _trackview.midi_track(); /* we know what it is already */
boost::shared_ptr<MidiDiskstream> ds = mt->midi_diskstream();
- jack_nframes_t frame_pos = ds->current_capture_start ();
+ nframes_t frame_pos = ds->current_capture_start ();
gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos);
gdouble xend;
uint32_t fill_color;
RecBoxInfo recbox;
recbox.rectangle = rec_rect;
- recbox.start = _trackview.session().transport_frame();
+ recbox.start = _trackview.session()->transport_frame();
recbox.length = 0;
rec_rects.push_back (recbox);
screen_update_connection.disconnect();
- screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun (*this, &MidiStreamView::update_rec_box));
+ screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
+ sigc::mem_fun (*this, &MidiStreamView::update_rec_box));
rec_updating = true;
rec_active = true;
} else if (rec_active &&
- (_trackview.session().record_status() != Session::Recording ||
+ (_trackview.session()->record_status() != Session::Recording ||
!_trackview.get_diskstream()->record_enabled())) {
-
screen_update_connection.disconnect();
rec_active = false;
rec_updating = false;
-
}
} else {
/* disconnect rapid update */
screen_update_connection.disconnect();
-
- for (list<sigc::connection>::iterator prc = rec_data_ready_connections.begin(); prc != rec_data_ready_connections.end(); ++prc) {
- (*prc).disconnect();
- }
- rec_data_ready_connections.clear();
+ rec_data_ready_connections.drop_connections ();
rec_updating = false;
rec_active = false;
void
MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t start, nframes_t dur)
{
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &MidiStreamView::update_rec_regions), data, start, dur));
+ ENSURE_GUI_THREAD (*this, &MidiStreamView::update_rec_regions, data, start, dur)
if (use_rec_regions) {
uint32_t n = 0;
bool update_range = false;
- for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) {
+ for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin();
+ iter != rec_regions.end(); n++) {
- list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp;
-
- tmp = iter;
+ list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp = iter;
++tmp;
- boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion>(iter->first);
- if (!region || !iter->second) {
+ if (!canvas_item_visible (rec_rects[n].rectangle)) {
+ /* rect already hidden, this region is done */
iter = tmp;
continue;
}
- if (!canvas_item_visible (rec_rects[n].rectangle)) {
- /* rect already hidden, this region is done */
+ boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion>(iter->first);
+ if (!region) {
iter = tmp;
continue;
}
gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
rect->property_x2() = xend;
+ ARDOUR::BeatsFramesConverter tconv(_trackview.session()->tempo_map(), region->position());
+ const MidiModel::TimeType start_beats = tconv.from(start);
+
/* draw events */
MidiRegionView* mrv = (MidiRegionView*)iter->second;
- for (MidiModel::Notes::const_iterator i = data->notes().begin();
+
+ for (MidiModel::Notes::const_iterator i = data->note_lower_bound(start_beats);
i != data->notes().end(); ++i) {
const boost::shared_ptr<MidiRegionView::NoteType>& note = *i;
- if (note->length() > 0 && note->end_time() + region->position() > start)
- mrv->resolve_note(note->note(), note->end_time());
+ nframes_t note_start_frames = tconv.to(note->time());
+ nframes_t note_end_frames = tconv.to(note->end_time());
- if (note->time() + region->position() < start)
+ if (note->length() > 0 && note_end_frames + region->position() > start)
+ mrv->resolve_note(note->note(), note_end_frames);
+
+ if (note_start_frames + region->position() < start) {
continue;
+ }
- if (note->time() + region->position() > start + dur)
+ if (note_start_frames + region->position() > start + dur) {
break;
+ }
if (note->note() < _lowest_note) {
_lowest_note = note->note();
}
void
-MidiStreamView::rec_data_range_ready (jack_nframes_t start, jack_nframes_t dur, boost::weak_ptr<Source> weak_src)
+MidiStreamView::rec_data_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr<Source> weak_src)
{
// this is called from the butler thread for now
- ENSURE_GUI_THREAD(bind (mem_fun (*this, &MidiStreamView::rec_data_range_ready), start, dur, weak_src));
+ ENSURE_GUI_THREAD (*this, &MidiStreamView::rec_data_range_ready, start, cnt, weak_src)
boost::shared_ptr<SMFSource> src (boost::dynamic_pointer_cast<SMFSource>(weak_src.lock()));
- this->update_rec_regions (src->model(), start, dur);
+ if (!src) {
+ return;
+ }
+
+ if (start + cnt > last_rec_data_frame) {
+ last_rec_data_frame = start + cnt;
+ }
+
+ this->update_rec_regions (src->model(), start, cnt);
}
void