Fix MIDI rec regions.
git-svn-id: svn://localhost/ardour2/branches/3.0@5842 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
516048882c
commit
2c59ddede5
@ -470,22 +470,22 @@ AudioStreamView::setup_rec_box ()
|
||||
|
||||
SourceList sources;
|
||||
|
||||
for (list<sigc::connection>::iterator prc = rec_data_ready_connections.begin(); prc != rec_data_ready_connections.end(); ++prc) {
|
||||
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();
|
||||
|
||||
// FIXME
|
||||
boost::shared_ptr<AudioDiskstream> ads = boost::dynamic_pointer_cast<AudioDiskstream>(_trackview.get_diskstream());
|
||||
assert(ads);
|
||||
boost::shared_ptr<AudioDiskstream> ads = _trackview.audio_track()->audio_diskstream();
|
||||
|
||||
for (uint32_t n=0; n < ads->n_channels().n_audio(); ++n) {
|
||||
boost::shared_ptr<AudioFileSource> src = boost::static_pointer_cast<AudioFileSource> (ads->write_source (n));
|
||||
boost::shared_ptr<AudioFileSource> src = ads->write_source (n);
|
||||
if (src) {
|
||||
sources.push_back (src);
|
||||
|
||||
rec_data_ready_connections.push_back (src->PeakRangeReady.connect (bind
|
||||
(mem_fun (*this, &AudioStreamView::rec_peak_range_ready), boost::weak_ptr<Source>(src))));
|
||||
(mem_fun (*this, &AudioStreamView::rec_peak_range_ready),
|
||||
boost::weak_ptr<Source>(src))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,11 +493,12 @@ AudioStreamView::setup_rec_box ()
|
||||
|
||||
nframes_t start = 0;
|
||||
if (rec_regions.size() > 0) {
|
||||
start = rec_regions.back().first->start() + _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<AudioRegion> region (boost::dynamic_pointer_cast<AudioRegion>
|
||||
(RegionFactory::create (sources, start, 1 , "", 0, (Region::Flag)(Region::DefaultFlags), false)));
|
||||
boost::shared_ptr<AudioRegion> region (boost::dynamic_pointer_cast<AudioRegion>(
|
||||
RegionFactory::create (sources, start, 1, "", 0, Region::DefaultFlags, false)));
|
||||
assert(region);
|
||||
region->block_property_changes ();
|
||||
region->set_position (_trackview.session().transport_frame(), this);
|
||||
@ -550,7 +551,8 @@ AudioStreamView::setup_rec_box ()
|
||||
rec_rects.push_back (recbox);
|
||||
|
||||
screen_update_connection.disconnect();
|
||||
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun (*this, &AudioStreamView::update_rec_box));
|
||||
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
|
||||
mem_fun (*this, &AudioStreamView::update_rec_box));
|
||||
rec_updating = true;
|
||||
rec_active = true;
|
||||
|
||||
@ -571,7 +573,8 @@ AudioStreamView::setup_rec_box ()
|
||||
/* 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) {
|
||||
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();
|
||||
@ -629,7 +632,7 @@ AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::we
|
||||
|
||||
// this is called from the peak building thread
|
||||
|
||||
if (rec_data_ready_map.size() == 0 || start+cnt > last_rec_data_frame) {
|
||||
if (rec_data_ready_map.size() == 0 || start + cnt > last_rec_data_frame) {
|
||||
last_rec_data_frame = start + cnt;
|
||||
}
|
||||
|
||||
@ -647,11 +650,10 @@ AudioStreamView::update_rec_regions ()
|
||||
if (use_rec_regions) {
|
||||
uint32_t n = 0;
|
||||
|
||||
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;
|
||||
|
||||
if (!canvas_item_visible (rec_rects[n].rectangle)) {
|
||||
@ -662,6 +664,7 @@ AudioStreamView::update_rec_regions ()
|
||||
|
||||
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(iter->first);
|
||||
if (!region) {
|
||||
iter = tmp;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,6 @@ class AudioStreamView : public StreamView
|
||||
CrossfadeViewList crossfade_views;
|
||||
bool crossfades_visible;
|
||||
|
||||
std::list<sigc::connection> rec_data_ready_connections;
|
||||
nframes_t last_rec_data_frame;
|
||||
std::map<boost::shared_ptr<ARDOUR::Source>, bool> rec_data_ready_map;
|
||||
|
||||
bool outline_region;
|
||||
|
@ -394,28 +394,31 @@ MidiStreamView::setup_rec_box ()
|
||||
|
||||
MidiRegion::SourceList sources;
|
||||
|
||||
for (list<sigc::connection>::iterator prc = rec_data_ready_connections.begin(); prc != rec_data_ready_connections.end(); ++prc) {
|
||||
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();
|
||||
|
||||
// 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()))));
|
||||
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()))));
|
||||
|
||||
// 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);
|
||||
@ -430,7 +433,7 @@ MidiStreamView::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;
|
||||
@ -457,18 +460,17 @@ MidiStreamView::setup_rec_box ()
|
||||
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 (
|
||||
mem_fun (*this, &MidiStreamView::update_rec_box));
|
||||
rec_updating = true;
|
||||
rec_active = true;
|
||||
|
||||
} else if (rec_active &&
|
||||
(_trackview.session().record_status() != Session::Recording ||
|
||||
!_trackview.get_diskstream()->record_enabled())) {
|
||||
|
||||
screen_update_connection.disconnect();
|
||||
rec_active = false;
|
||||
rec_updating = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -480,7 +482,8 @@ MidiStreamView::setup_rec_box ()
|
||||
/* 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) {
|
||||
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();
|
||||
@ -527,21 +530,20 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||
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;
|
||||
}
|
||||
@ -572,21 +574,30 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||
gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
|
||||
rect->property_x2() = xend;
|
||||
|
||||
ARDOUR::BeatsFramesConverter tconv(_trackview.session(), region->position());
|
||||
|
||||
/* draw events */
|
||||
MidiRegionView* mrv = (MidiRegionView*)iter->second;
|
||||
|
||||
// FIXME: this is offensively slow (linear search)
|
||||
for (MidiModel::Notes::const_iterator i = data->notes().begin();
|
||||
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();
|
||||
@ -638,15 +649,23 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||
}
|
||||
|
||||
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(bind (mem_fun (*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
|
||||
|
@ -58,7 +58,7 @@ class MidiStreamView : public StreamView
|
||||
~MidiStreamView ();
|
||||
|
||||
void set_selected_regionviews (RegionSelection&);
|
||||
void get_selectables (jack_nframes_t start, jack_nframes_t end, std::list<Selectable* >&);
|
||||
void get_selectables (nframes_t start, nframes_t end, std::list<Selectable* >&);
|
||||
void get_inverted_selectables (Selection&, std::list<Selectable* >& results);
|
||||
|
||||
enum VisibleNoteRange {
|
||||
@ -104,14 +104,14 @@ class MidiStreamView : public StreamView
|
||||
void setup_rec_box ();
|
||||
|
||||
void rec_data_range_ready (
|
||||
jack_nframes_t start,
|
||||
jack_nframes_t dur,
|
||||
nframes_t start,
|
||||
nframes_t dur,
|
||||
boost::weak_ptr<ARDOUR::Source> src);
|
||||
|
||||
void update_rec_regions (
|
||||
boost::shared_ptr<ARDOUR::MidiModel> data,
|
||||
jack_nframes_t start,
|
||||
jack_nframes_t dur);
|
||||
nframes_t start,
|
||||
nframes_t dur);
|
||||
|
||||
RegionView* add_region_view_internal (
|
||||
boost::shared_ptr<ARDOUR::Region>,
|
||||
|
@ -167,7 +167,7 @@ protected:
|
||||
double height;
|
||||
|
||||
std::list<sigc::connection> rec_data_ready_connections;
|
||||
jack_nframes_t last_rec_data_frame;
|
||||
nframes_t last_rec_data_frame;
|
||||
|
||||
private:
|
||||
void update_coverage_frames ();
|
||||
|
@ -65,6 +65,8 @@ SMFSource::SMFSource (Session& s, const ustring& path, bool embedded, Source::Fl
|
||||
if (create(path)) {
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
_model = boost::shared_ptr<MidiModel>(new MidiModel(this)); // FIXME
|
||||
}
|
||||
|
||||
/** Constructor used for existing internal-to-session files. */
|
||||
@ -87,6 +89,8 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
|
||||
if (open(_path)) {
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
_model = boost::shared_ptr<MidiModel>(new MidiModel(this)); // FIXME
|
||||
}
|
||||
|
||||
SMFSource::~SMFSource ()
|
||||
|
Loading…
Reference in New Issue
Block a user