AddRouteDialog::group_changed ()
{
if (_session && route_group_combo.get_active_text () == _("New group...")) {
- RouteGroup* g = new RouteGroup (*_session, "", RouteGroup::Active);
+ RouteGroup* g = new RouteGroup (*_session, "");
+
+ PropertyList plist;
+ plist.add (Properties::active, true);
+ g->set_properties (plist);
RouteGroupDialog d (g, Gtk::Stock::NEW);
int const r = d.do_run ();
show_all();
name_changed ();
- bounds_changed (Change (StartChanged|LengthChanged|PositionChanged|Region::SyncOffsetChanged));
+ bounds_changed (PropertyChange (StartChanged|LengthChanged|PositionChanged|Region::SyncOffsetChanged));
gain_changed ();
_region->StateChanged.connect (state_connection, ui_bind (&AudioRegionEditor::region_changed, this, _1), gui_context());
}
void
-AudioRegionEditor::region_changed (PBD::Change what_changed)
+AudioRegionEditor::region_changed (PBD::PropertyChange what_changed)
{
if (what_changed & NameChanged) {
name_changed ();
}
- if (what_changed & Change (BoundsChanged|StartChanged|Region::SyncOffsetChanged)) {
+ if (what_changed & PropertyChange (BoundsChanged|StartChanged|Region::SyncOffsetChanged)) {
bounds_changed (what_changed);
}
}
void
-AudioRegionEditor::bounds_changed (Change what_changed)
+AudioRegionEditor::bounds_changed (PropertyChange what_changed)
{
- if ((what_changed & Change (PositionChanged|LengthChanged)) == Change (PositionChanged|LengthChanged)) {
+ if ((what_changed & PropertyChange (PositionChanged|LengthChanged)) == PropertyChange (PositionChanged|LengthChanged)) {
position_clock.set (_region->position(), true);
end_clock.set (_region->position() + _region->length() - 1, true);
length_clock.set (_region->length(), true);
- } else if (what_changed & Change (PositionChanged)) {
+ } else if (what_changed & PropertyChange (PositionChanged)) {
position_clock.set (_region->position(), true);
end_clock.set (_region->position() + _region->length() - 1, true);
- } else if (what_changed & Change (LengthChanged)) {
+ } else if (what_changed & PropertyChange (LengthChanged)) {
end_clock.set (_region->position() + _region->length() - 1, true);
length_clock.set (_region->length(), true);
}
bool
AudioRegionEditor::on_delete_event (GdkEventAny* ev)
{
- bounds_changed (Change (StartChanged|LengthChanged|PositionChanged|Region::SyncOffsetChanged));
+ bounds_changed (PropertyChange (StartChanged|LengthChanged|PositionChanged|Region::SyncOffsetChanged));
return RegionEditor::on_delete_event (ev);
}
PBD::ScopedConnection state_connection;
PBD::ScopedConnection audition_connection;
- void region_changed (PBD::Change);
- void bounds_changed (PBD::Change);
+ void region_changed (PBD::PropertyChange);
+ void bounds_changed (PBD::PropertyChange);
void name_changed ();
void gain_changed ();
}
void
-AudioRegionView::region_changed (Change what_changed)
+AudioRegionView::region_changed (PropertyChange what_changed)
{
ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed)
//cerr << "AudioRegionView::region_changed() called" << endl;
}
void
-AudioRegionView::region_resized (Change what_changed)
+AudioRegionView::region_resized (PropertyChange what_changed)
{
AudioGhostRegion* agr;
RegionView::region_resized(what_changed);
- if (what_changed & Change (StartChanged|LengthChanged)) {
+ if (what_changed & PropertyChange (StartChanged|LengthChanged)) {
for (uint32_t n = 0; n < waves.size(); ++n) {
waves[n]->property_region_start() = _region->start();
AudioRegionGainLine* get_gain_line() const { return gain_line; }
- void region_changed (PBD::Change);
+ void region_changed (PBD::PropertyChange);
void envelope_active_changed ();
GhostRegion* add_ghost (TimeAxisView&);
void fade_in_active_changed ();
void fade_out_active_changed ();
- void region_resized (PBD::Change);
+ void region_resized (PBD::PropertyChange);
void region_muted ();
void region_scale_amplitude_changed ();
void region_renamed ();
+ _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::DefaultFlags, false)));
+ PropertyList plist;
+
+ plist.add (Properties::start, start);
+ plist.add (Properties::length, 1);
+ plist.add (Properties::name, string());
+ plist.add (Properties::layer, 0);
+
+ boost::shared_ptr<AudioRegion> region (
+ boost::dynamic_pointer_cast<AudioRegion>(RegionFactory::create (sources, plist, false)));
+
assert(region);
region->block_property_changes ();
region->set_position (_trackview.session()->transport_frame(), this);
void
-AutomationRegionView::region_resized (PBD::Change what_changed)
+AutomationRegionView::region_resized (PBD::PropertyChange what_changed)
{
RegionView::region_resized(what_changed);
protected:
void create_line(boost::shared_ptr<ARDOUR::AutomationList> list);
bool set_position(nframes64_t pos, void* src, double* ignored);
- void region_resized (PBD::Change what_changed);
+ void region_resized (PBD::PropertyChange what_changed);
bool canvas_event(GdkEvent* ev);
void add_automation_event (GdkEvent* event, nframes_t when, double y);
void entered();
break;
case PROP_LENGTH_FUNCTION:
- waveview->length_function = g_value_get_pointer(value);
+ waveview->length_function = (gulong (*)(void*)) g_value_get_pointer(value);
redraw = TRUE;
break;
case PROP_SOURCEFILE_LENGTH_FUNCTION:
- waveview->sourcefile_length_function = g_value_get_pointer(value);
+ waveview->sourcefile_length_function = (gulong (*)(void*,double)) g_value_get_pointer(value);
redraw = TRUE;
break;
case PROP_PEAK_FUNCTION:
- waveview->peak_function = g_value_get_pointer(value);
+ waveview->peak_function =
+ (void (*)(void*,gulong,gulong,gulong,gpointer,guint32,double))
+ g_value_get_pointer(value);
redraw = TRUE;
break;
case PROP_GAIN_FUNCTION:
- waveview->gain_curve_function = g_value_get_pointer(value);
- redraw = TRUE;
+ waveview->gain_curve_function =
+ (void (*)(void *arg, double start, double end, float* vector, gint64 veclen))
+ g_value_get_pointer(value);
+ redraw = TRUE;
break;
case PROP_GAIN_SRC:
break;
case PROP_LENGTH_FUNCTION:
- g_value_set_pointer(value, waveview->length_function);
+ g_value_set_pointer(value, (void*) waveview->length_function);
break;
case PROP_SOURCEFILE_LENGTH_FUNCTION:
- g_value_set_pointer(value, waveview->sourcefile_length_function);
+ g_value_set_pointer(value, (void*) waveview->sourcefile_length_function);
break;
case PROP_PEAK_FUNCTION:
- g_value_set_pointer(value, waveview->peak_function);
+ g_value_set_pointer(value, (void*) waveview->peak_function);
break;
case PROP_GAIN_FUNCTION:
- g_value_set_pointer(value, waveview->gain_curve_function);
+ g_value_set_pointer(value, (void*) waveview->gain_curve_function);
break;
case PROP_GAIN_SRC:
void
-CrossfadeEditor::xfade_changed (Change)
+CrossfadeEditor::xfade_changed (PropertyChange)
{
set (xfade->fade_in(), In);
set (xfade->fade_out(), Out);
right_length = xfade->in()->length();
}
- boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), left_start_offset, left_length, "xfade out",
- 0, Region::DefaultFlags, false)));
- boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, right_length, "xfade in",
- 0, Region::DefaultFlags, false)));
-
- //apply a 20ms declicking fade at the start and end of auditioning
- left->set_fade_in_active(true);
- left->set_fade_in_length(_session->frame_rate() / 50);
- right->set_fade_out_active(true);
- right->set_fade_out_length(_session->frame_rate() / 50);
-
- pl.add_region (left, 0);
- pl.add_region (right, 1 + preroll);
+ PropertyList left_plist;
+ PropertyList right_plist;
+
+
+ left_plist.add (ARDOUR::Properties::start, left_start_offset);
+ left_plist.add (ARDOUR::Properties::length, left_length);
+ left_plist.add (ARDOUR::Properties::name, string ("xfade out"));
+ left_plist.add (ARDOUR::Properties::layer, 0);
+ left_plist.add (ARDOUR::Properties::fade_in_active, true);
+
+ right_plist.add (ARDOUR::Properties::start, 0);
+ right_plist.add (ARDOUR::Properties::length, right_length);
+ right_plist.add (ARDOUR::Properties::name, string("xfade in"));
+ right_plist.add (ARDOUR::Properties::layer, 0);
+ right_plist.add (ARDOUR::Properties::fade_out_active, true);
if (which == Left) {
- right->set_scale_amplitude (0.0);
+ right_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
} else if (which == Right) {
- left->set_scale_amplitude (0.0);
+ left_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
}
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->out(), left_plist, false)));
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->in(), right_plist, false)));
+
+ // apply a 20ms declicking fade at the start and end of auditioning
+ // XXX this should really be a property
+
+ left->set_fade_in_length (_session->frame_rate() / 50);
+ right->set_fade_out_length (_session->frame_rate() / 50);
+
+ pl.add_region (left, 0);
+ pl.add_region (right, 1 + preroll);
+
/* there is only one ... */
pl.foreach_crossfade (sigc::mem_fun (*this, &CrossfadeEditor::setup));
void
CrossfadeEditor::audition_left_dry ()
{
- boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), xfade->out()->length() - xfade->length(), xfade->length(), "xfade left",
- 0, Region::DefaultFlags, false)));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, xfade->out()->length() - xfade->length());
+ plist.add (ARDOUR::Properties::length, xfade->length());
+ plist.add (ARDOUR::Properties::name, string("xfade left"));
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->out(), plist, false)));
_session->audition_region (left);
}
void
CrossfadeEditor::audition_right_dry ()
{
- boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, xfade->length(), "xfade in",
- 0, Region::DefaultFlags, false)));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, xfade->length());
+ plist.add (ARDOUR::Properties::name, string ("xfade right"));
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->in(), plist, false)));
+
_session->audition_region (right);
}
void audition_right_dry ();
void audition_right ();
- void xfade_changed (PBD::Change);
+ void xfade_changed (PBD::PropertyChange);
void dump ();
};
group->signal_event().connect (sigc::bind (sigc::mem_fun (tv.editor(), &PublicEditor::canvas_crossfade_view_event), group, this));
- crossfade_changed (Change (~0));
+ crossfade_changed (PropertyChange (~0));
crossfade->StateChanged.connect (*this, ui_bind (&CrossfadeView::crossfade_changed, this, _1), gui_context());
ColorsChanged.connect (sigc::mem_fun (*this, &CrossfadeView::color_handler));
}
void
-CrossfadeView::crossfade_changed (Change what_changed)
+CrossfadeView::crossfade_changed (PropertyChange what_changed)
{
bool need_redraw_curves = false;
ArdourCanvas::Line *fade_out;
ArdourCanvas::Item *active_button;
- void crossfade_changed (PBD::Change);
+ void crossfade_changed (PBD::PropertyChange);
void active_changed ();
void redraw_curves ();
void color_handler ();
handle_new_duration ();
restore_ruler_visibility ();
- //tempo_map_changed (Change (0));
+ //tempo_map_changed (PropertyChange (0));
_session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
}
cew.apply ();
- xfade->StateChanged (Change (~0));
+ xfade->StateChanged (PropertyChange (~0));
}
PlaylistSelector&
begin_reversible_command (_("new playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
_session->playlists->get (playlists);
- mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit);
+ mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, ARDOUR::Properties::edit.id);
commit_reversible_command ();
}
begin_reversible_command (_("copy playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
_session->playlists->get (playlists);
- mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit);
+ mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, ARDOUR::Properties::edit.id);
commit_reversible_command ();
}
begin_reversible_command (_("clear playlists"));
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
_session->playlists->get (playlists);
- mapover_tracks (sigc::mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit);
+ mapover_tracks (sigc::mem_fun (*this, &Editor::mapped_clear_playlist), v, ARDOUR::Properties::edit.id);
commit_reversible_command ();
}
for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
RouteGroup* g = (*i)->get_time_axis_view().route_group ();
- if (g && g->active_property (RouteGroup::Edit)) {
+ if (g && g->is_active() && g->is_edit()) {
tracks.add (axis_views_from_routes (g->route_list()));
}
void location_changed (ARDOUR::Location *);
void location_flags_changed (ARDOUR::Location *, void *);
void refresh_location_display ();
- void refresh_location_display_s (PBD::Change);
+ void refresh_location_display_s (PBD::PropertyChange);
void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
void add_new_location (ARDOUR::Location *);
void location_gone (ARDOUR::Location *);
void sort_track_selection (TrackViewList* sel = 0);
- void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, ARDOUR::RouteGroup::Property) const;
- RegionSelection get_equivalent_regions (RegionSelection &, ARDOUR::RouteGroup::Property) const;
- void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, ARDOUR::RouteGroup::Property) const;
+ void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, PBD::PropertyID) const;
+ RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const;
+ void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
/* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
void draw_metric_marks (const ARDOUR::Metrics& metrics);
void compute_current_bbt_points (nframes_t left, nframes_t right);
- void tempo_map_changed (PBD::Change);
+ void tempo_map_changed (PBD::PropertyChange);
void redisplay_tempo (bool immediate_redraw);
void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-mouse"), _("Mouse"), (sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-selected-marker"), _("Marker"), (sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
- ActionManager::register_action (editor_actions, "cycle-edit-point", _("Change Edit Point"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), false));
- ActionManager::register_action (editor_actions, "cycle-edit-point-with-marker", _("Change Edit Point Including Marker"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), true));
+ ActionManager::register_action (editor_actions, "cycle-edit-point", _("PropertyChange Edit Point"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), false));
+ ActionManager::register_action (editor_actions, "cycle-edit-point-with-marker", _("PropertyChange Edit Point Including Marker"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), true));
if (!Profile->get_sae()) {
ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Splice));
}
region_name = region_name_from_path (paths.front(), (sources.size() > 1), false);
- boost::shared_ptr<Region> r = RegionFactory::create (sources, 0, sources[0]->length(pos), region_name, 0,
- Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, sources[0]->length (pos));
+ plist.add (ARDOUR::Properties::name, region_name);
+ plist.add (ARDOUR::Properties::layer, 0);
+ plist.add (ARDOUR::Properties::whole_file, true);
+ plist.add (ARDOUR::Properties::external, true);
+
+ boost::shared_ptr<Region> r = RegionFactory::create (sources, plist);
if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position(sources[0]->natural_position());
region_name = region_name_from_path ((*x)->path(), false, false, sources.size(), n);
- boost::shared_ptr<Region> r = RegionFactory::create (just_one, 0, (*x)->length(pos), region_name, 0,
- Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, (*x)->length (pos));
+ plist.add (ARDOUR::Properties::name, region_name);
+ plist.add (ARDOUR::Properties::layer, 0);
+ plist.add (ARDOUR::Properties::whole_file, true);
+ plist.add (ARDOUR::Properties::external, true);
+
+ boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position((*x)->natural_position());
}
void
-Editor::refresh_location_display_s (Change)
+Editor::refresh_location_display_s (PropertyChange)
{
ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display_s, ignored)
switch (item_type) {
case FadeInHandleItem:
{
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.id);
_drags->set (new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event);
return true;
}
case FadeOutHandleItem:
{
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.id);
_drags->set (new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event);
return true;
}
case RegionViewNameHighlight:
{
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.id);
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
return true;
break;
case RegionViewName:
{
/* rename happens on edit clicks */
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.id);
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, s.by_layer()), event);
return true;
break;
}
}
- rv.region_changed (Change (LengthChanged|PositionChanged|StartChanged));
+ rv.region_changed (PropertyChange (LengthChanged|PositionChanged|StartChanged));
}
void
region_right->trim_front(region->last_frame() + 1, this);
}
- rv.region_changed (Change (LengthChanged|PositionChanged|StartChanged));
+ rv.region_changed (PropertyChange (LengthChanged|PositionChanged|StartChanged));
}
else {
rv.region_changed (LengthChanged);
if (Config->get_edit_mode() == Splice) {
_drags->add (new RegionSpliceDrag (this, item, region_view, selection->regions.by_layer()));
} else {
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false));
}
_region_motion_group->raise_to_top ();
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, true));
}
return;
}
- RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), true, false));
begin_reversible_command (_("Drag region brush"));
internal_start = start - current->position();
_session->region_name (new_name, current->name(), true);
- boost::shared_ptr<Region> region (RegionFactory::create (current,
- internal_start, selection_cnt, new_name));
+
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, internal_start);
+ plist.add (ARDOUR::Properties::length, selection_cnt);
+ plist.add (ARDOUR::Properties::name, new_name);
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<Region> region (RegionFactory::create (current, plist));
}
}
internal_start = start - current->position();
_session->region_name (new_name, current->name(), true);
- new_regions.push_back (RegionFactory::create (current,
- internal_start, end - start + 1, new_name));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, internal_start);
+ plist.add (ARDOUR::Properties::length, end - start + 1);
+ plist.add (ARDOUR::Properties::name, new_name);
+
+ new_regions.push_back (RegionFactory::create (current, plist));
}
}
}
region->trim_end((nframes64_t) (next_region->first_frame() * speed), this);
- arv->region_changed (Change (LengthChanged));
+ arv->region_changed (PropertyChange (LengthChanged));
}
else {
}
region->trim_front((nframes64_t) ((next_region->last_frame() + 1) * speed), this);
- arv->region_changed (Change (LengthChanged|PositionChanged|StartChanged));
+ arv->region_changed (PropertyChange (LengthChanged|PositionChanged|StartChanged));
}
XMLNode &after = playlist->get_state();
void
Editor::reset_region_gain_envelopes ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::toggle_gain_envelope_visibility ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::toggle_gain_envelope_active ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::toggle_region_lock ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::set_region_lock_style (Region::PositionLockStyle ps)
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::toggle_region_mute ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
void
Editor::toggle_region_opaque ()
{
- RegionSelection rs = get_equivalent_regions (selection->regions, RouteGroup::Edit);
+ RegionSelection rs = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.id);
if (!_session || rs.empty()) {
return;
/* do NOT announce new regions 1 by one, just wait till they are all done */
- boost::shared_ptr<Region> nr = RegionFactory::create (r->sources(), file_start, len, new_name, 0, Region::DefaultFlags, false);
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, file_start);
+ plist.add (ARDOUR::Properties::length, len);
+ plist.add (ARDOUR::Properties::name, new_name);
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<Region> nr = RegionFactory::create (r->sources(), plist, false);
pl->add_region (nr, pos);
pos += len;
file_start = r->start() + (pos - r->position());
len = r->last_frame() - pos;
- nr = RegionFactory::create (r->sources(), file_start, len, new_name, 0, Region::DefaultFlags);
+ PropertyList plist2;
+
+ plist2.add (ARDOUR::Properties::start, file_start);
+ plist2.add (ARDOUR::Properties::length, len);
+ plist2.add (ARDOUR::Properties::name, new_name);
+ plist2.add (ARDOUR::Properties::layer, 0);
+
+ nr = RegionFactory::create (r->sources(), plist2);
pl->add_region (nr, pos);
break;
void
-EditorRegions::region_changed (Change what_changed, boost::weak_ptr<Region> region)
+EditorRegions::region_changed (PropertyChange what_changed, boost::weak_ptr<Region> region)
{
ENSURE_GUI_THREAD (*this, &EditorRegions::region_changed, what_changed, region)
Columns _columns;
- void region_changed (PBD::Change, boost::weak_ptr<ARDOUR::Region>);
+ void region_changed (PBD::PropertyChange, boost::weak_ptr<ARDOUR::Region>);
void selection_changed ();
sigc::connection _change_connection;
bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
ARDOUR::RouteGroup *
EditorRouteGroups::new_route_group () const
{
- RouteGroup* g = new RouteGroup (
- *_session,
- "",
- RouteGroup::Active,
- (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
- );
+ PropertyList plist;
+
+ plist.add (Properties::active, true);
+ plist.add (Properties::mute, true);
+ plist.add (Properties::solo, true);
+ plist.add (Properties::edit, true);
+
+ RouteGroup* g = new RouteGroup (*_session, "");
+
+ g->set_properties (plist);
RouteGroupDialog d (g, Gtk::Stock::NEW);
int const r = d.do_run ();
void
EditorRouteGroups::run_new_group_dialog (const RouteList& rl)
{
- RouteGroup* g = new RouteGroup (
- *_session,
- "",
- RouteGroup::Active,
- (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit | RouteGroup::RecEnable)
- );
+ PropertyList plist;
+
+ plist.add (Properties::active, true);
+ plist.add (Properties::mute, true);
+ plist.add (Properties::solo, true);
+ plist.add (Properties::recenable, true);
+ plist.add (Properties::edit, true);
+
+ RouteGroup* g = new RouteGroup (*_session, "");
+ g->set_properties (plist);
RouteGroupDialog d (g, Gtk::Stock::NEW);
int const r = d.do_run ();
}
}
- group->set_property (RouteGroup::Gain, (*iter)[_columns.gain]);
- group->set_property (RouteGroup::RecEnable, (*iter)[_columns.record]);
- group->set_property (RouteGroup::Mute, (*iter)[_columns.mute]);
- group->set_property (RouteGroup::Solo, (*iter)[_columns.solo]);
- group->set_property (RouteGroup::Select, (*iter)[_columns.select]);
- group->set_property (RouteGroup::Edit, (*iter)[_columns.edits]);
-
- string name = (*iter)[_columns.text];
-
- if (name != group->name()) {
- group->set_name (name);
- }
+ PropertyList plist;
+ bool val = (*iter)[_columns.gain];
+ plist.add (Properties::gain, val);
+ val = (*iter)[_columns.record];
+ plist.add (Properties::recenable, val);
+ val = (*iter)[_columns.mute];
+ plist.add (Properties::mute, val);
+ val = (*iter)[_columns.solo];
+ plist.add (Properties::solo, val);
+ val = (*iter)[_columns.select];
+ plist.add (Properties::select, val);
+ val = (*iter)[_columns.edits];
+ plist.add (Properties::edit, val);
+ plist.add (Properties::name, string ((*iter)[_columns.text]));
+
+ group->set_properties (plist);
}
void
TreeModel::Row row = *(_model->append());
row[_columns.is_visible] = !group->is_hidden();
- row[_columns.gain] = group->property(RouteGroup::Gain);
- row[_columns.record] = group->property(RouteGroup::RecEnable);
- row[_columns.mute] = group->property(RouteGroup::Mute);
- row[_columns.solo] = group->property(RouteGroup::Solo);
- row[_columns.select] = group->property(RouteGroup::Select);
- row[_columns.edits] = group->property(RouteGroup::Edit);
+ row[_columns.gain] = group->is_gain ();
+ row[_columns.record] = group->is_recenable();
+ row[_columns.mute] = group->is_mute ();
+ row[_columns.solo] = group->is_solo ();
+ row[_columns.select] = group->is_select ();
+ row[_columns.edits] = group->is_edit ();
_in_row_change = true;
if (group == (*iter)[_columns.routegroup]) {
(*iter)[_columns.is_visible] = !group->is_hidden();
(*iter)[_columns.text] = group->name();
- (*iter)[_columns.gain] = group->property(RouteGroup::Gain);
- (*iter)[_columns.record] = group->property(RouteGroup::RecEnable);
- (*iter)[_columns.mute] = group->property(RouteGroup::Mute);
- (*iter)[_columns.solo] = group->property(RouteGroup::Solo);
- (*iter)[_columns.select] = group->property(RouteGroup::Select);
- (*iter)[_columns.edits] = group->property(RouteGroup::Edit);
+ (*iter)[_columns.gain] = group->is_gain ();
+ (*iter)[_columns.record] = group->is_recenable ();
+ (*iter)[_columns.mute] = group->is_mute ();
+ (*iter)[_columns.solo] = group->is_solo ();
+ (*iter)[_columns.select] = group->is_select ();
+ (*iter)[_columns.edits] = group->is_edit ();
}
}
*/
void
-Editor::mapover_tracks (sigc::slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis, RouteGroup::Property prop) const
+Editor::mapover_tracks (sigc::slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis, PBD::PropertyID prop) const
{
RouteTimeAxisView* route_basis = dynamic_cast<RouteTimeAxisView*> (basis);
if (route_basis == 0) {
tracks.insert (route_basis);
RouteGroup* group = route_basis->route()->route_group();
- if (group && group->active_property (prop)) {
+ if (group && group->enabled_property (prop)) {
/* the basis is a member of an active route group, with the appropriate
properties; find other members */
}
void
-Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions, RouteGroup::Property prop) const
+Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions, PBD::PropertyID property) const
{
- mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview(), prop);
+ mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview(), property);
/* add clicked regionview since we skipped all other regions in the same track as the one it was in */
}
RegionSelection
-Editor::get_equivalent_regions (RegionSelection & basis, RouteGroup::Property prop) const
+Editor::get_equivalent_regions (RegionSelection & basis, PBD::PropertyID prop) const
{
RegionSelection equivalent;
if (press) {
if (selection->selected (clicked_routeview)) {
- get_equivalent_regions (clicked_regionview, all_equivalent_regions, RouteGroup::Select);
+ get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.id);
} else {
all_equivalent_regions.push_back (clicked_regionview);
}
case Selection::Set:
if (!selection->selected (clicked_regionview)) {
- get_equivalent_regions (clicked_regionview, all_equivalent_regions, RouteGroup::Select);
+ get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.id);
selection->set (all_equivalent_regions);
commit = true;
} else {
}
void
-Editor::tempo_map_changed (Change ignored)
+Editor::tempo_map_changed (PropertyChange ignored)
{
if (!_session) {
return;
*/
void change_line_width(double coord, double width);
- /** Change the color of a line.
+ /** PropertyChange the color of a line.
*/
void change_line_color(double coord, uint32_t color);
}
void
-MidiRegionView::region_resized (Change what_changed)
+MidiRegionView::region_resized (PropertyChange what_changed)
{
RegionView::region_resized(what_changed);
*/
void get_patch_key_at(double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key);
- /** Change the 'automation' data of old_program to new values which correspond to new_patch.
+ /** PropertyChange the 'automation' data of old_program to new values which correspond to new_patch.
* @param old_program the program change event which is to be altered
* @param new_patch the new lsb, msb and program number which are to be set
*/
*/
void change_velocity(ArdourCanvas::CanvasNoteEvent* ev, int8_t velocity, bool relative=false);
- /** Change the channel of the selection.
+ /** PropertyChange the channel of the selection.
* @param channel - the channel number of the new channel, zero-based
*/
void change_channel(uint8_t channel);
Gdk::Color& basic_color,
TimeAxisViewItem::Visibility);
- void region_resized (PBD::Change);
+ void region_resized (PBD::PropertyChange);
void set_flags (XMLNode *);
void store_flags ();
start = rec_regions.back().first->start()
+ _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1);
}
+
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, start);
+ plist.add (ARDOUR::Properties::length, 1);
+ plist.add (ARDOUR::Properties::name, string());
+ plist.add (ARDOUR::Properties::layer, 0);
boost::shared_ptr<MidiRegion> region (boost::dynamic_pointer_cast<MidiRegion>
- (RegionFactory::create (sources, start, 1 , "", 0, Region::DefaultFlags, false)));
+ (RegionFactory::create (sources, plist, false)));
assert(region);
region->block_property_changes ();
something about MIDI (!) would not expect to find them there.
*/
- add_channel_command_menu_item (automation_items, _("Program Change"), MidiPgmChangeAutomation, MIDI_CMD_PGM_CHANGE);
+ add_channel_command_menu_item (automation_items, _("Program PropertyChange"), MidiPgmChangeAutomation, MIDI_CMD_PGM_CHANGE);
add_channel_command_menu_item (automation_items, _("Bender"), MidiPitchBenderAutomation, MIDI_CMD_BENDER);
add_channel_command_menu_item (automation_items, _("Pressure"), MidiChannelPressureAutomation, MIDI_CMD_CHANNEL_PRESSURE);
real_editor->begin_reversible_command (_("create region"));
XMLNode &before = playlist()->get_state();
- nframes64_t start = pos;
+ framepos_t start = pos;
real_editor->snap_to (start, -1);
const Meter& m = _session->tempo_map().meter_at(start);
const Tempo& t = _session->tempo_map().tempo_at(start);
boost::shared_ptr<Source> src = _session->create_midi_source_for_session (*diskstream.get());
- boost::shared_ptr<Region> region = (RegionFactory::create (src, 0, (nframes_t) length,
- PBD::basename_nosuffix(src->name())));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, length);
+ plist.add (ARDOUR::Properties::name, PBD::basename_nosuffix(src->name()));
+
+ boost::shared_ptr<Region> region = (RegionFactory::create (src, plist));
playlist()->add_region (region, start);
XMLNode &after = playlist()->get_state();
case program:
if (show_hex) {
- s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x\n", "Program Change", (msg[0]&0xf)+1, (int) msg[1]);
+ s += snprintf (&buf[s], bufsize, "%16s chn %2d %02x\n", "Program PropertyChange", (msg[0]&0xf)+1, (int) msg[1]);
} else {
- s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d\n", "Program Change", (msg[0]&0xf)+1, (int) msg[1]);
+ s += snprintf (&buf[s], bufsize, "%16s chn %2d %-3d\n", "Program PropertyChange", (msg[0]&0xf)+1, (int) msg[1]);
}
break;
using namespace std;
using namespace Gtk;
using namespace ARDOUR;
+using namespace PBD;
MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
: GroupTabs (0),
ARDOUR::RouteGroup *
MixerGroupTabs::new_route_group () const
{
- RouteGroup* g = new RouteGroup (
- *_session,
- "",
- RouteGroup::Active,
- (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo | RouteGroup::RecEnable)
- );
+ PropertyList plist;
+
+ plist.add (Properties::active, true);
+ plist.add (Properties::mute, true);
+ plist.add (Properties::solo, true);
+ plist.add (Properties::gain, true);
+ plist.add (Properties::recenable, true);
+
+ RouteGroup* g = new RouteGroup (*_session, "");
+ g->set_properties (plist);
RouteGroupDialog d (g, Gtk::Stock::NEW);
int const r = d.do_run ();
if (group_menu == 0) {
- group_menu = new RouteGroupMenu (
- _session,
- (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
- );
+ PropertyList* plist = new PropertyList();
+ plist->add (Properties::gain, true);
+ plist->add (Properties::mute, true);
+ plist->add (Properties::solo, true);
+
+ group_menu = new RouteGroupMenu (_session, plist);
group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
}
void
Mixer_UI::new_route_group ()
{
- _session->add_route_group (new RouteGroup (*_session, "", RouteGroup::Active, (RouteGroup::Property) (RouteGroup::Gain |RouteGroup::Mute | RouteGroup::Solo)));
+ PropertyList plist;
+
+ plist.add (Properties::active, true);
+ plist.add (Properties::gain, true);
+ plist.add (Properties::mute, true);
+ plist.add (Properties::solo, true);
+
+ RouteGroup* g = new RouteGroup (*_session, "");
+ g->set_properties (plist);
+
+ _session->add_route_group (g);
}
void
virtual RouteTimeAxisView* get_route_view_by_id (PBD::ID& id) = 0;
- virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, ARDOUR::RouteGroup::Property) const = 0;
+ virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, PBD::PropertyID) const = 0;
sigc::signal<void> ZoomFocusChanged;
sigc::signal<void> ZoomChanged;
#include <gtkmm/stock.h>
#include "gtkmm2ext/utils.h"
+#include "pbd/convert.h"
#include "quantize_dialog.h"
#include "public_editor.h"
}
void
-RegionView::region_changed (Change what_changed)
+RegionView::region_changed (PropertyChange what_changed)
{
ENSURE_GUI_THREAD (*this, &RegionView::region_changed, what_changed)
}
void
-RegionView::region_resized (Change what_changed)
+RegionView::region_resized (PropertyChange what_changed)
{
double unit_length;
_time_converter.set_origin(_region->position());
}
- if (what_changed & Change (StartChanged|LengthChanged)) {
+ if (what_changed & PropertyChange (StartChanged|LengthChanged)) {
set_duration (_region->length(), 0);
virtual void show_region_editor () {}
virtual void hide_region_editor();
- virtual void region_changed (PBD::Change);
+ virtual void region_changed (PBD::PropertyChange);
virtual GhostRegion* add_ghost (TimeAxisView&) = 0;
void remove_ghost_in (TimeAxisView&);
bool recording,
TimeAxisViewItem::Visibility);
- virtual void region_resized (PBD::Change);
+ virtual void region_resized (PBD::PropertyChange);
virtual void region_muted ();
void region_locked ();
void region_opacity ();
using namespace Gtk;
using namespace ARDOUR;
using namespace std;
+using namespace PBD;
RouteGroupDialog::RouteGroupDialog (RouteGroup* g, StockID const & s)
: ArdourDialog (_("route group dialog")),
_name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK));
- _gain.set_active (_group->property (RouteGroup::Gain));
+ _gain.set_active (_group->is_gain());
_relative.set_active (_group->is_relative());
- _mute.set_active (_group->property (RouteGroup::Mute));
- _solo.set_active (_group->property (RouteGroup::Solo));
- _rec_enable.set_active (_group->property (RouteGroup::RecEnable));
- _select.set_active (_group->property (RouteGroup::Select));
- _edit.set_active (_group->property (RouteGroup::Edit));
+ _mute.set_active (_group->is_mute());
+ _solo.set_active (_group->is_solo());
+ _rec_enable.set_active (_group->is_recenable());
+ _select.set_active (_group->is_select());
+ _edit.set_active (_group->is_edit());
gain_toggled ();
int const r = run ();
if (r == Gtk::RESPONSE_OK || r == Gtk::RESPONSE_ACCEPT) {
- _group->set_property (RouteGroup::Gain, _gain.get_active ());
- _group->set_property (RouteGroup::Mute, _mute.get_active ());
- _group->set_property (RouteGroup::Solo, _solo.get_active ());
- _group->set_property (RouteGroup::RecEnable, _rec_enable.get_active ());
- _group->set_property (RouteGroup::Select, _select.get_active ());
- _group->set_property (RouteGroup::Edit, _edit.get_active ());
- _group->set_name (_name.get_text ()); // This emits changed signal
- _group->set_active (_active.get_active (), this);
- _group->set_relative (_relative.get_active(), this);
+
+ PropertyList plist;
+
+ plist.add (Properties::gain, _gain.get_active());
+ plist.add (Properties::recenable, _rec_enable.get_active());
+ plist.add (Properties::mute, _mute.get_active());
+ plist.add (Properties::solo, _solo.get_active ());
+ plist.add (Properties::select, _select.get_active());
+ plist.add (Properties::edit, _edit.get_active());
+ plist.add (Properties::relative, _relative.get_active());
+ plist.add (Properties::active, _active.get_active());
+ plist.add (Properties::name, string (_name.get_text()));
+
+ _group->set_properties (plist);
}
return r;
using namespace Gtk;
using namespace ARDOUR;
+using namespace PBD;
-RouteGroupMenu::RouteGroupMenu (Session* s, RouteGroup::Property p)
+RouteGroupMenu::RouteGroupMenu (Session* s, PropertyList* plist)
: SessionHandlePtr (s)
- , _default_properties (p)
+ , _default_properties (plist)
, _inhibit_group_selected (false)
, _selected_route_group (0)
{
rebuild (0);
}
+RouteGroupMenu::~RouteGroupMenu()
+{
+ delete _default_properties;
+}
+
void
RouteGroupMenu::rebuild (RouteGroup* curr)
{
return;
}
- RouteGroup* g = new RouteGroup (*_session, "", RouteGroup::Active, _default_properties);
+ RouteGroup* g = new RouteGroup (*_session, "");
+ g->set_properties (*_default_properties);
RouteGroupDialog d (g, Gtk::Stock::NEW);
int const r = d.do_run ();
class RouteGroupMenu : public Gtk::Menu, public ARDOUR::SessionHandlePtr
{
public:
- RouteGroupMenu (ARDOUR::Session*, ARDOUR::RouteGroup::Property);
+ RouteGroupMenu (ARDOUR::Session*, PBD::PropertyList*);
+ ~RouteGroupMenu();
void rebuild (ARDOUR::RouteGroup *);
void new_group ();
void set_group (ARDOUR::RouteGroup *);
- ARDOUR::RouteGroup::Property _default_properties;
+ PBD::PropertyList* _default_properties;
bool _inhibit_group_selected;
ARDOUR::RouteGroup* _selected_route_group;
};
_editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
- route_group_menu = new RouteGroupMenu (
- _session,
- (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
- );
-
+ PropertyList* plist = new PropertyList();
+
+ plist->add (ARDOUR::Properties::edit, true);
+ plist->add (ARDOUR::Properties::mute, true);
+ plist->add (ARDOUR::Properties::solo, true);
+
+ route_group_menu = new RouteGroupMenu (_session, plist);
route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
void init ();
void reset ();
- void queue_route_group_op (ARDOUR::RouteGroup::Property prop, void (ARDOUR::Session::*session_method)(boost::shared_ptr<ARDOUR::RouteList>, bool), bool yn);
void self_delete ();
private:
afs = boost::dynamic_pointer_cast<AudioFileSource> (srclist[0]);
string rname = region_name_from_path (afs->path(), false);
- r = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0,
- srclist[0]->length(srclist[0]->timeline_position()),
- rname, 0, Region::DefaultFlags, false));
+
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, srclist[0]->length(srclist[0]->timeline_position()));
+ plist.add (ARDOUR::Properties::name, rname);
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ r = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, plist, false));
_session->audition_region(r);
}
#include "rgb_macros.h"
#include "i18n.h"
+using namespace ARDOUR;
+
/** Construct Strip silence dialog box */
StripSilenceDialog::StripSilenceDialog (std::list<boost::shared_ptr<ARDOUR::AudioRegion> > const & regions)
: ArdourDialog (_("Strip Silence")), _wave_width (640), _wave_height (64)
i->silence_rects.clear ();
- std::list<std::pair<nframes_t, nframes_t> > const silence =
+ std::list<std::pair<frameoffset_t, framecnt_t> > const silence =
i->region->find_silence (dB_to_coefficient (threshold ()), minimum_length ());
-
- for (std::list<std::pair<nframes_t, nframes_t> >::const_iterator j = silence.begin(); j != silence.end(); ++j) {
+
+ for (std::list<std::pair<frameoffset_t, framecnt_t> >::const_iterator j = silence.begin(); j != silence.end(); ++j) {
ArdourCanvas::SimpleRect* r = new ArdourCanvas::SimpleRect (*(_canvas->root()));
r->property_x1() = j->first / i->samples_per_unit;
/* select anything in the same select-enabled route group */
ARDOUR::RouteGroup* rg = (*i)->route_group ();
- if (rg && rg->property (ARDOUR::RouteGroup::Select)) {
+ if (rg && rg->is_active() && rg->is_select ()) {
TrackViewList tr = _editor->axis_views_from_routes (rg->route_list ());
for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) {
if (!contains (*j)) {
return (microseconds_t) jack_get_time();
}
- extern PBD::Change StartChanged;
- extern PBD::Change LengthChanged;
- extern PBD::Change PositionChanged;
- extern PBD::Change NameChanged;
- extern PBD::Change BoundsChanged;
- extern PBD::Change FlagsChanged;
+ extern PBD::PropertyChange StartChanged;
+ extern PBD::PropertyChange LengthChanged;
+ extern PBD::PropertyChange PositionChanged;
+ extern PBD::PropertyChange NameChanged;
+ extern PBD::PropertyChange BoundsChanged;
static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
XMLNode& state (bool full_state);
void dump () const;
- bool region_changed (PBD::Change, boost::shared_ptr<Region>);
- void crossfade_changed (PBD::Change);
+ bool region_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
+ void crossfade_changed (PBD::PropertyChange);
void add_crossfade (boost::shared_ptr<Crossfade>);
void source_offset_changed (boost::shared_ptr<AudioRegion> region);
class XMLNode;
+
namespace ARDOUR {
+namespace Properties {
+ extern PBD::PropertyDescriptor<bool> envelope_active;
+ extern PBD::PropertyDescriptor<bool> default_fade_in;
+ extern PBD::PropertyDescriptor<bool> default_fade_out;
+ extern PBD::PropertyDescriptor<bool> fade_in_active;
+ extern PBD::PropertyDescriptor<bool> fade_out_active;
+ extern PBD::PropertyDescriptor<float> scale_amplitude;
+}
+
class Route;
class Playlist;
class Session;
class Filter;
class AudioSource;
+
class AudioRegion : public Region
{
public:
- static PBD::Change FadeInChanged;
- static PBD::Change FadeOutChanged;
- static PBD::Change FadeInActiveChanged;
- static PBD::Change FadeOutActiveChanged;
- static PBD::Change EnvelopeActiveChanged;
- static PBD::Change ScaleAmplitudeChanged;
- static PBD::Change EnvelopeChanged;
+ static void make_property_quarks ();
+
+ static PBD::PropertyChange FadeInChanged;
+ static PBD::PropertyChange FadeOutChanged;
+ static PBD::PropertyChange FadeInActiveChanged;
+ static PBD::PropertyChange FadeOutActiveChanged;
+ static PBD::PropertyChange EnvelopeActiveChanged;
+ static PBD::PropertyChange ScaleAmplitudeChanged;
+ static PBD::PropertyChange EnvelopeChanged;
~AudioRegion();
void normalize_to (float target_in_dB = 0.0f);
- bool envelope_active () const { return _flags & Region::EnvelopeActive; }
- bool fade_in_active () const { return _flags & Region::FadeIn; }
- bool fade_out_active () const { return _flags & Region::FadeOut; }
+ bool envelope_active () const { return _envelope_active; }
+ bool fade_in_active () const { return _fade_in_active; }
+ bool fade_out_active () const { return _fade_out_active; }
boost::shared_ptr<AutomationList> fade_in() { return _fade_in; }
boost::shared_ptr<AutomationList> fade_out() { return _fade_out; }
ReadOpsFades = 0x8
};
- virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const;
- virtual nframes_t read_with_ops (Sample*, sframes_t pos, nframes_t cnt, int channel, ReadOps rops) const;
- virtual nframes64_t readable_length() const { return length(); }
-
- virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
- sframes_t position,
- nframes_t cnt,
- uint32_t chan_n = 0,
- nframes_t read_frames = 0,
- nframes_t skip_frames = 0) const;
-
- virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
- sframes_t position, nframes_t cnt, uint32_t chan_n=0) const;
-
- virtual nframes_t read_raw_internal (Sample*, sframes_t, nframes_t, int channel) const;
+ virtual framecnt_t read (Sample*, framepos_t pos, framecnt_t cnt, int channel) const;
+ virtual framecnt_t read_with_ops (Sample*, framepos_t pos, framecnt_t cnt, int channel, ReadOps rops) const;
+ virtual framecnt_t readable_length() const { return length(); }
+
+ virtual framecnt_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
+ framepos_t position,
+ framecnt_t cnt,
+ uint32_t chan_n = 0,
+ framecnt_t read_frames = 0,
+ framecnt_t skip_frames = 0) const;
+
+ virtual framecnt_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
+ framepos_t position, framecnt_t cnt, uint32_t chan_n=0) const;
+
+ virtual framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int channel) const;
XMLNode& state (bool);
- int set_state (const XMLNode&, int version);
+ int set_state (const XMLNode&, int version);
- static void set_default_fade (float steepness, nframes_t len);
+ static void set_default_fade (float steepness, framecnt_t len);
bool fade_in_is_default () const;
bool fade_out_is_default () const;
void set_fade_in_active (bool yn);
void set_fade_in_shape (FadeShape);
- void set_fade_in_length (nframes_t);
- void set_fade_in (FadeShape, nframes_t);
+ void set_fade_in_length (framecnt_t);
+ void set_fade_in (FadeShape, framecnt_t);
void set_fade_in (boost::shared_ptr<AutomationList>);
void set_fade_out_active (bool yn);
void set_fade_out_shape (FadeShape);
- void set_fade_out_length (nframes_t);
- void set_fade_out (FadeShape, nframes_t);
+ void set_fade_out_length (framecnt_t);
+ void set_fade_out (FadeShape, framecnt_t);
void set_fade_out (boost::shared_ptr<AutomationList>);
void set_envelope_active (bool yn);
void resume_fade_out ();
int get_transients (AnalysisFeatureList&, bool force_new = false);
- std::list<std::pair<nframes_t, nframes_t> > find_silence (Sample, nframes_t) const;
+ std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t) const;
private:
friend class RegionFactory;
friend class Crossfade;
- AudioRegion (boost::shared_ptr<AudioSource>, nframes_t start, nframes_t length);
- AudioRegion (boost::shared_ptr<AudioSource>, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- AudioRegion (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- AudioRegion (boost::shared_ptr<const AudioRegion>, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- AudioRegion (boost::shared_ptr<const AudioRegion>, const SourceList&, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- AudioRegion (boost::shared_ptr<const AudioRegion>);
+ AudioRegion (boost::shared_ptr<AudioSource>);
+ AudioRegion (const SourceList &);
+ AudioRegion (boost::shared_ptr<const AudioRegion>, frameoffset_t offset = 0, bool offset_relative = true);
+ AudioRegion (boost::shared_ptr<const AudioRegion>, const SourceList&);
AudioRegion (boost::shared_ptr<AudioSource>, const XMLNode&);
AudioRegion (SourceList &, const XMLNode&);
private:
+ PBD::Property<bool> _envelope_active;
+ PBD::Property<bool> _default_fade_in;
+ PBD::Property<bool> _default_fade_out;
+ PBD::Property<bool> _fade_in_active;
+ PBD::Property<bool> _fade_out_active;
+ PBD::Property<gain_t> _scale_amplitude;
+
+ void register_properties ();
+ PBD::PropertyChange set_property (const PBD::PropertyBase& prop);
+ void post_set ();
+
void init ();
void set_default_fades ();
void set_default_fade_in ();
void recompute_gain_at_end ();
void recompute_gain_at_start ();
- nframes_t _read_at (const SourceList&, nframes_t limit,
- Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- sframes_t position, nframes_t cnt,
- uint32_t chan_n = 0,
- nframes_t read_frames = 0,
- nframes_t skip_frames = 0,
- ReadOps readops = ReadOps (~0)) const;
+ framecnt_t _read_at (const SourceList&, framecnt_t limit,
+ Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+ framepos_t position, framecnt_t cnt,
+ uint32_t chan_n = 0,
+ framecnt_t read_frames = 0,
+ framecnt_t skip_frames = 0,
+ ReadOps readops = ReadOps (~0)) const;
void recompute_at_start ();
void recompute_at_end ();
boost::shared_ptr<AutomationList> _fade_in;
boost::shared_ptr<AutomationList> _fade_out;
boost::shared_ptr<AutomationList> _envelope;
- gain_t _scale_amplitude;
- uint32_t _fade_in_disabled;
- uint32_t _fade_out_disabled;
+ uint32_t _fade_in_suspended;
+ uint32_t _fade_out_suspended;
protected:
/* default constructor for derived (compound) types */
- AudioRegion (Session& s, nframes_t, nframes_t, std::string name);
+ AudioRegion (Session& s, framepos_t, framecnt_t, std::string name);
- int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
+ int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal);
};
} /* namespace ARDOUR */
AudioSource (Session&, const XMLNode&);
virtual ~AudioSource ();
- nframes64_t readable_length() const { return _length; }
- uint32_t n_channels() const { return 1; }
+ framecnt_t readable_length() const { return _length; }
+ uint32_t n_channels() const { return 1; }
- sframes_t length (sframes_t pos) const;
- void update_length (sframes_t pos, sframes_t cnt);
+ framecnt_t length (framepos_t pos) const;
+ void update_length (framepos_t pos, framecnt_t cnt);
- virtual nframes_t available_peaks (double zoom) const;
+ virtual framecnt_t available_peaks (double zoom) const;
- virtual nframes_t read (Sample *dst, sframes_t start, nframes_t cnt, int channel=0) const;
- virtual nframes_t write (Sample *src, nframes_t cnt);
+ virtual framecnt_t read (Sample *dst, framepos_t start, framecnt_t cnt, int channel=0) const;
+ virtual framecnt_t write (Sample *src, framecnt_t cnt);
virtual float sample_rate () const = 0;
uint32_t read_data_count() const { return _read_data_count; }
uint32_t write_data_count() const { return _write_data_count; }
- int read_peaks (PeakData *peaks, nframes_t npeaks,
- sframes_t start, nframes_t cnt, double samples_per_visual_peak) const;
+ int read_peaks (PeakData *peaks, framecnt_t npeaks,
+ framepos_t start, framecnt_t cnt, double samples_per_visual_peak) const;
int build_peaks ();
bool peaks_ready (boost::function<void()> callWhenReady, PBD::Connection& connection_created_if_not_ready, PBD::EventLoop* event_loop) const;
mutable PBD::Signal0<void> PeaksReady;
- mutable PBD::Signal2<void,nframes_t,nframes_t> PeakRangeReady;
+ mutable PBD::Signal2<void,framepos_t,framepos_t> PeakRangeReady;
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
static bool _build_missing_peakfiles;
static bool _build_peakfiles;
- sframes_t _length;
+ framecnt_t _length;
bool _peaks_built;
mutable Glib::Mutex _peaks_ready_lock;
Glib::ustring peakpath;
int initialize_peakfile (bool newfile, Glib::ustring path);
int build_peaks_from_scratch ();
- int compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt,
+ int compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
bool force, bool intermediate_peaks_ready_signal);
void truncate_peakfile();
mutable off_t _peak_byte_max; // modified in compute_and_write_peak()
- virtual nframes_t read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const = 0;
- virtual nframes_t write_unlocked (Sample *dst, nframes_t cnt) = 0;
+ virtual framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const = 0;
+ virtual framecnt_t write_unlocked (Sample *dst, framecnt_t cnt) = 0;
virtual Glib::ustring peak_path(Glib::ustring audio_path) = 0;
virtual Glib::ustring find_broken_peakfile (Glib::ustring missing_peak_path,
Glib::ustring audio_path) = 0;
virtual int read_peaks_with_fpp (PeakData *peaks,
- nframes_t npeaks, sframes_t start, nframes_t cnt,
- double samples_per_visual_peak, nframes_t fpp) const;
-
- int compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt,
- bool force, bool intermediate_peaks_ready_signal, nframes_t frames_per_peak);
+ framecnt_t npeaks, framepos_t start, framecnt_t cnt,
+ double samples_per_visual_peak, framecnt_t fpp) const;
+
+ int compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
+ bool force, bool intermediate_peaks_ready_signal,
+ framecnt_t frames_per_peak);
private:
- int peakfile;
- nframes_t peak_leftover_cnt;
- nframes_t peak_leftover_size;
- Sample* peak_leftovers;
- nframes_t peak_leftover_frame;
+ int peakfile;
+ framecnt_t peak_leftover_cnt;
+ framecnt_t peak_leftover_size;
+ Sample* peak_leftovers;
+ framepos_t peak_leftover_frame;
};
}
/* constructor for "fixed" xfades at each end of an internal overlap */
Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out,
- nframes_t position,
- nframes_t initial_length,
- AnchorPoint);
+ framepos_t position,
+ framecnt_t initial_length,
+ AnchorPoint);
/* constructor for xfade between two regions that are overlapped in any way
except the "internal" case.
boost::shared_ptr<ARDOUR::AudioRegion> in() const { return _in; }
boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
- nframes_t read_at (Sample *buf, Sample *mixdown_buffer,
- float *gain_buffer, sframes_t position, nframes_t cnt,
- uint32_t chan_n,
- nframes_t read_frames = 0,
- nframes_t skip_frames = 0) const;
+ framecnt_t read_at (Sample *buf, Sample *mixdown_buffer,
+ float *gain_buffer, framepos_t position, framecnt_t cnt,
+ uint32_t chan_n,
+ framecnt_t read_frames = 0,
+ framecnt_t skip_frames = 0) const;
bool refresh ();
return (_in == a && _out == b) || (_in == b && _out == a);
}
- nframes_t overlap_length() const;
+ framecnt_t overlap_length() const;
PBD::Signal1<void,boost::shared_ptr<Region> > Invalidated;
- PBD::Signal1<void,PBD::Change> StateChanged;
+ PBD::Signal1<void,PBD::PropertyChange> StateChanged;
- bool covers (nframes_t frame) const {
+ bool covers (framecnt_t frame) const {
return _position <= frame && frame < _position + _length;
}
- OverlapType coverage (nframes_t start, nframes_t end) const;
+ OverlapType coverage (framepos_t start, framepos_t end) const;
- static void set_buffer_size (nframes_t);
+ static void set_buffer_size (framecnt_t);
bool active () const { return _active; }
void set_active (bool yn);
AutomationList& fade_in() { return _fade_in; }
AutomationList& fade_out() { return _fade_out; }
- nframes_t set_xfade_length (nframes_t);
+ framecnt_t set_xfade_length (framecnt_t);
bool is_dependent() const { return true; }
bool depends_on (boost::shared_ptr<Region> other) const {
return other == _in || other == _out;
}
- static nframes_t short_xfade_length() { return _short_xfade_length; }
- static void set_short_xfade_length (nframes_t n);
+ static framecnt_t short_xfade_length() { return _short_xfade_length; }
+ static void set_short_xfade_length (framecnt_t n);
- static PBD::Change ActiveChanged;
- static PBD::Change FollowOverlapChanged;
+ static PBD::PropertyChange ActiveChanged;
+ static PBD::PropertyChange FollowOverlapChanged;
private:
friend struct CrossfadeComparePtr;
friend class AudioPlaylist;
- static nframes_t _short_xfade_length;
+ static framecnt_t _short_xfade_length;
boost::shared_ptr<ARDOUR::AudioRegion> _in;
boost::shared_ptr<ARDOUR::AudioRegion> _out;
bool update ();
protected:
- nframes_t read_raw_internal (Sample*, sframes_t, nframes_t, int) const;
+ framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int) const;
};
SessionEvents = 0x800,
MidiIO = 0x1000,
MackieControl = 0x2000,
- MidiClock = 0x4000
+ MidiClock = 0x4000,
+ Properties = 0x8000
};
}
void remove_region_from_last_capture (boost::weak_ptr<Region> wregion);
void move_processor_automation (boost::weak_ptr<Processor>,
- std::list< Evoral::RangeMove<nframes_t> > const &);
+ std::list<Evoral::RangeMove<framepos_t> > const &);
PBD::Signal0<void> RecordEnableChanged;
PBD::Signal0<void> SpeedChanged;
/* XXX fix this redundancy ... */
- virtual void playlist_changed (PBD::Change);
+ virtual void playlist_changed (PBD::PropertyChange);
virtual void playlist_deleted (boost::weak_ptr<Playlist>);
- virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<nframes_t> > const &);
+ virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<framepos_t> > const &);
virtual void transport_stopped (struct tm&, time_t, bool abort) = 0;
virtual void transport_looped (nframes_t transport_frame) = 0;
PBD::Signal0<void> changed;
PBD::Signal1<void,Location*> added;
PBD::Signal1<void,Location*> removed;
- PBD::Signal1<void,PBD::Change> StateChanged;
+ PBD::Signal1<void,PBD::PropertyChange> StateChanged;
template<class T> void apply (T& obj, void (T::*method)(LocationList&)) {
Glib::Mutex::Lock lm (lock);
};
- /** Change note properties.
+ /** PropertyChange note properties.
* More efficient than DeltaCommand and has the important property that
* it leaves the objects in the MidiModel (Notes) the same, thus
* enabling selection and other state to persist across command
private:
void dump () const;
- bool region_changed (PBD::Change, boost::shared_ptr<Region>);
+ bool region_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
NoteMode _note_mode;
boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
/* Stub Readable interface */
- virtual nframes_t read (Sample*, sframes_t /*pos*/, nframes_t /*cnt*/, int /*channel*/) const { return 0; }
- virtual sframes_t readable_length() const { return length(); }
-
- nframes_t read_at (Evoral::EventSink<nframes_t>& dst,
- sframes_t position,
- nframes_t dur,
- uint32_t chan_n = 0,
- NoteMode mode = Sustained,
- MidiStateTracker* tracker = 0) const;
-
- nframes_t master_read_at (MidiRingBuffer<nframes_t>& dst,
- sframes_t position,
- nframes_t dur,
- uint32_t chan_n = 0,
- NoteMode mode = Sustained) const;
+ virtual framecnt_t read (Sample*, framepos_t /*pos*/, framecnt_t /*cnt*/, int /*channel*/) const { return 0; }
+ virtual framecnt_t readable_length() const { return length(); }
+
+ framecnt_t read_at (Evoral::EventSink<nframes_t>& dst,
+ framepos_t position,
+ framecnt_t dur,
+ uint32_t chan_n = 0,
+ NoteMode mode = Sustained,
+ MidiStateTracker* tracker = 0) const;
+
+ framepos_t master_read_at (MidiRingBuffer<nframes_t>& dst,
+ framepos_t position,
+ framecnt_t dur,
+ uint32_t chan_n = 0,
+ NoteMode mode = Sustained) const;
XMLNode& state (bool);
int set_state (const XMLNode&, int version);
-
+
int separate_by_channel (ARDOUR::Session&, std::vector< boost::shared_ptr<Region> >&) const;
/* automation */
-
+
boost::shared_ptr<Evoral::Control>
control(const Evoral::Parameter& id, bool create=false) {
return model()->control(id, create);
private:
friend class RegionFactory;
- MidiRegion (boost::shared_ptr<MidiSource>, nframes_t start, nframes_t length);
- MidiRegion (boost::shared_ptr<MidiSource>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- MidiRegion (const SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- MidiRegion (boost::shared_ptr<const MidiRegion>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
- MidiRegion (boost::shared_ptr<const MidiRegion>);
+ MidiRegion (boost::shared_ptr<MidiSource>);
+ MidiRegion (const SourceList&);
+ MidiRegion (boost::shared_ptr<const MidiRegion>, frameoffset_t offset = 0, bool offset_relative = true);
MidiRegion (boost::shared_ptr<MidiSource>, const XMLNode&);
MidiRegion (const SourceList &, const XMLNode&);
private:
- nframes_t _read_at (const SourceList&, Evoral::EventSink<nframes_t>& dst,
- sframes_t position,
- nframes_t dur,
- uint32_t chan_n = 0,
- NoteMode mode = Sustained,
- MidiStateTracker* tracker = 0) const;
+ framecnt_t _read_at (const SourceList&, Evoral::EventSink<nframes_t>& dst,
+ framepos_t position,
+ framecnt_t dur,
+ uint32_t chan_n = 0,
+ NoteMode mode = Sustained,
+ MidiStateTracker* tracker = 0) const;
void recompute_at_start ();
void recompute_at_end ();
- void set_position_internal (nframes_t pos, bool allow_bbt_recompute);
+ void set_position_internal (framepos_t pos, bool allow_bbt_recompute);
void switch_source(boost::shared_ptr<Source> source);
-
- protected:
-
- int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
};
} /* namespace ARDOUR */
Playlist (Session&, const XMLNode&, DataType type, bool hidden = false);
Playlist (Session&, std::string name, DataType type, bool hidden = false);
Playlist (boost::shared_ptr<const Playlist>, std::string name, bool hidden = false);
- Playlist (boost::shared_ptr<const Playlist>, nframes_t start, nframes_t cnt, std::string name, bool hidden = false);
+ Playlist (boost::shared_ptr<const Playlist>, framepos_t start, framecnt_t cnt, std::string name, bool hidden = false);
virtual ~Playlist ();
bool hidden() const { return _hidden; }
bool empty() const;
uint32_t n_regions() const;
- nframes_t get_maximum_extent () const;
+ framecnt_t get_maximum_extent () const;
layer_t top_layer() const;
EditMode get_edit_mode() const { return _edit_mode; }
/* Editing operations */
- void add_region (boost::shared_ptr<Region>, nframes_t position, float times = 1, bool auto_partition = false);
+ void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false);
void remove_region (boost::shared_ptr<Region>);
void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
- void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, nframes_t pos);
- void split_region (boost::shared_ptr<Region>, nframes_t position);
- void split (nframes64_t at);
- void shift (nframes64_t at, nframes64_t distance, bool move_intersected, bool ignore_music_glue);
- void partition (nframes_t start, nframes_t end, bool cut = false);
- void duplicate (boost::shared_ptr<Region>, nframes_t position, float times);
- void nudge_after (nframes_t start, nframes_t distance, bool forwards);
+ void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, framepos_t pos);
+ void split_region (boost::shared_ptr<Region>, framepos_t position);
+ void split (framepos_t at);
+ void shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue);
+ void partition (framepos_t start, framepos_t end, bool cut = false);
+ void duplicate (boost::shared_ptr<Region>, framepos_t position, float times);
+ void nudge_after (framepos_t start, framecnt_t distance, bool forwards);
void shuffle (boost::shared_ptr<Region>, int dir);
void update_after_tempo_map_change ();
boost::shared_ptr<Playlist> cut (std::list<AudioRange>&, bool result_is_hidden = true);
boost::shared_ptr<Playlist> copy (std::list<AudioRange>&, bool result_is_hidden = true);
- int paste (boost::shared_ptr<Playlist>, nframes_t position, float times);
+ int paste (boost::shared_ptr<Playlist>, framepos_t position, float times);
const RegionList& region_list () const { return regions; }
- RegionList* regions_at (nframes_t frame);
- RegionList* regions_touched (nframes_t start, nframes_t end);
- RegionList* regions_to_read (nframes_t start, nframes_t end);
+ RegionList* regions_at (framepos_t frame);
+ RegionList* regions_touched (framepos_t start, framepos_t end);
+ RegionList* regions_to_read (framepos_t start, framepos_t end);
boost::shared_ptr<Region> find_region (const PBD::ID&) const;
- boost::shared_ptr<Region> top_region_at (nframes_t frame);
- boost::shared_ptr<Region> top_unmuted_region_at (nframes_t frame);
- boost::shared_ptr<Region> find_next_region (nframes_t frame, RegionPoint point, int dir);
- nframes64_t find_next_region_boundary (nframes64_t frame, int dir);
+ boost::shared_ptr<Region> top_region_at (framepos_t frame);
+ boost::shared_ptr<Region> top_unmuted_region_at (framepos_t frame);
+ boost::shared_ptr<Region> find_next_region (framepos_t frame, RegionPoint point, int dir);
+ framepos_t find_next_region_boundary (framepos_t frame, int dir);
bool region_is_shuffle_constrained (boost::shared_ptr<Region>);
- bool has_region_at (nframes64_t const) const;
+ bool has_region_at (framepos_t const) const;
- nframes64_t find_next_transient (nframes64_t position, int dir);
+ framepos_t find_next_transient (framepos_t position, int dir);
void foreach_region (boost::function<void (boost::shared_ptr<Region>)>);
PBD::Signal0<void> NameChanged;
PBD::Signal0<void> LengthChanged;
PBD::Signal0<void> LayeringChanged;
- PBD::Signal1<void,std::list< Evoral::RangeMove<nframes_t> > const &> RangesMoved;
+ PBD::Signal1<void,std::list< Evoral::RangeMove<framepos_t> > const &> RangesMoved;
static std::string bump_name (std::string old_name, Session&);
bool pending_contents_change;
bool pending_layering;
bool pending_length;
- std::list< Evoral::RangeMove<nframes_t> > pending_range_moves;
+ std::list< Evoral::RangeMove<framepos_t> > pending_range_moves;
bool save_on_thaw;
std::string last_save_reason;
uint32_t in_set_state;
uint32_t _read_data_count;
PBD::ID _orig_diskstream_id;
uint64_t layer_op_counter;
- nframes_t freeze_length;
+ framecnt_t freeze_length;
bool auto_partition;
/** true if relayering should be done using region's current layers and their `pending explicit relayer'
void notify_length_changed ();
void notify_layering_changed ();
void notify_contents_changed ();
- void notify_state_changed (PBD::Change);
+ void notify_state_changed (PBD::PropertyChange);
void notify_region_moved (boost::shared_ptr<Region>);
void mark_session_dirty();
- void region_changed_proxy (PBD::Change, boost::weak_ptr<Region>);
- virtual bool region_changed (PBD::Change, boost::shared_ptr<Region>);
+ void region_changed_proxy (PBD::PropertyChange, boost::weak_ptr<Region>);
+ virtual bool region_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
- void region_bounds_changed (PBD::Change, boost::shared_ptr<Region>);
+ void region_bounds_changed (PBD::PropertyChange, boost::shared_ptr<Region>);
void region_deleted (boost::shared_ptr<Region>);
void sort_regions ();
- void possibly_splice (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude = boost::shared_ptr<Region>());
- void possibly_splice_unlocked(nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude = boost::shared_ptr<Region>());
+ void possibly_splice (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude = boost::shared_ptr<Region>());
+ void possibly_splice_unlocked(framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude = boost::shared_ptr<Region>());
- void core_splice (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude);
- void splice_locked (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude);
- void splice_unlocked (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude);
+ void core_splice (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude);
+ void splice_locked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude);
+ void splice_unlocked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude);
virtual void finalize_split_region (boost::shared_ptr<Region> /*original*/, boost::shared_ptr<Region> /*left*/, boost::shared_ptr<Region> /*right*/) {}
boost::shared_ptr<Region> region_by_id (PBD::ID);
- bool add_region_internal (boost::shared_ptr<Region>, nframes_t position);
+ bool add_region_internal (boost::shared_ptr<Region>, framepos_t position);
int remove_region_internal (boost::shared_ptr<Region>);
- RegionList *find_regions_at (nframes_t frame);
+ RegionList *find_regions_at (framepos_t frame);
void copy_regions (RegionList&) const;
- void partition_internal (nframes_t start, nframes_t end, bool cutting, RegionList& thawlist);
+ void partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist);
- nframes_t _get_maximum_extent() const;
+ framecnt_t _get_maximum_extent() const;
- boost::shared_ptr<Playlist> cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(nframes_t, nframes_t, bool),
- std::list<AudioRange>& ranges, bool result_is_hidden);
- boost::shared_ptr<Playlist> cut (nframes_t start, nframes_t cnt, bool result_is_hidden);
- boost::shared_ptr<Playlist> copy (nframes_t start, nframes_t cnt, bool result_is_hidden);
+ boost::shared_ptr<Playlist> cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t, framecnt_t, bool),
+ std::list<AudioRange>& ranges, bool result_is_hidden);
+ boost::shared_ptr<Playlist> cut (framepos_t start, framecnt_t cnt, bool result_is_hidden);
+ boost::shared_ptr<Playlist> copy (framepos_t start, framecnt_t cnt, bool result_is_hidden);
int move_region_to_layer (layer_t, boost::shared_ptr<Region> r, int dir);
void relayer ();
void timestamp_layer_op (boost::shared_ptr<Region>);
- void _split_region (boost::shared_ptr<Region>, nframes_t position);
+ void _split_region (boost::shared_ptr<Region>, framepos_t position);
};
} /* namespace ARDOUR */
Readable () {}
virtual ~Readable() {}
- virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const = 0;
- virtual sframes_t readable_length() const = 0;
+ virtual framecnt_t read (Sample*, framepos_t pos, framecnt_t cnt, int channel) const = 0;
+ virtual framecnt_t readable_length() const = 0;
virtual uint32_t n_channels () const = 0;
};
class XMLNode;
+
namespace ARDOUR {
+namespace Properties {
+ extern PBD::PropertyDescriptor<bool> muted;
+ extern PBD::PropertyDescriptor<bool> opaque;
+ extern PBD::PropertyDescriptor<bool> locked;
+ extern PBD::PropertyDescriptor<bool> automatic;
+ extern PBD::PropertyDescriptor<bool> whole_file;
+ extern PBD::PropertyDescriptor<bool> import;
+ extern PBD::PropertyDescriptor<bool> external;
+ extern PBD::PropertyDescriptor<bool> sync_marked;
+ extern PBD::PropertyDescriptor<bool> left_of_split;
+ extern PBD::PropertyDescriptor<bool> right_of_split;
+ extern PBD::PropertyDescriptor<bool> hidden;
+ extern PBD::PropertyDescriptor<bool> position_locked;
+ extern PBD::PropertyDescriptor<framepos_t> start;
+ extern PBD::PropertyDescriptor<framecnt_t> length;
+ extern PBD::PropertyDescriptor<framepos_t> position;
+ extern PBD::PropertyDescriptor<framecnt_t> sync_position;
+ extern PBD::PropertyDescriptor<layer_t> layer;
+ extern PBD::PropertyDescriptor<framepos_t> ancestral_start;
+ extern PBD::PropertyDescriptor<framecnt_t> ancestral_length;
+ extern PBD::PropertyDescriptor<float> stretch;
+ extern PBD::PropertyDescriptor<float> shift;
+};
+
class Playlist;
class Filter;
class ExportSpecification;
EditChangesID = 2
};
+
class Region
: public SessionObject
, public boost::enable_shared_from_this<Region>
public:
typedef std::vector<boost::shared_ptr<Source> > SourceList;
- enum Flag {
- Muted = 0x1,
- Opaque = 0x2,
- EnvelopeActive = 0x4,
- DefaultFadeIn = 0x8,
- DefaultFadeOut = 0x10,
- Locked = 0x20,
- Automatic = 0x40,
- WholeFile = 0x80,
- FadeIn = 0x100,
- FadeOut = 0x200,
- Copied = 0x400,
- Import = 0x800,
- External = 0x1000,
- SyncMarked = 0x2000,
- LeftOfSplit = 0x4000,
- RightOfSplit = 0x8000,
- Hidden = 0x10000,
- DoNotSendPropertyChanges = 0x20000,
- PositionLocked = 0x40000,
- //
- range_guarantoor = USHRT_MAX
- };
-
+ static void make_property_quarks ();
+
enum PositionLockStyle {
AudioTime,
MusicTime
};
- static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut);
-
- static PBD::Change FadeChanged;
- static PBD::Change SyncOffsetChanged;
- static PBD::Change MuteChanged;
- static PBD::Change OpacityChanged;
- static PBD::Change LockChanged;
- static PBD::Change LayerChanged;
- static PBD::Change HiddenChanged;
+ static PBD::PropertyChange FadeChanged;
+ static PBD::PropertyChange SyncOffsetChanged;
+ static PBD::PropertyChange MuteChanged;
+ static PBD::PropertyChange OpacityChanged;
+ static PBD::PropertyChange LockChanged;
+ static PBD::PropertyChange LayerChanged;
+ static PBD::PropertyChange HiddenChanged;
- PBD::Signal1<void,PBD::Change> StateChanged;
+ PBD::Signal1<void,PBD::PropertyChange> StateChanged;
static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > RegionPropertyChanged;
- void unlock_property_changes () { _flags = Flag (_flags & ~DoNotSendPropertyChanges); }
- void block_property_changes () { _flags = Flag (_flags | DoNotSendPropertyChanges); }
+ void unlock_property_changes () { _no_property_changes = false; }
+ void block_property_changes () { _no_property_changes = true; }
+
virtual ~Region();
-
+
/** Note: changing the name of a Region does not constitute an edit */
bool set_name (const std::string& str);
const DataType& data_type() const { return _type; }
/** How the region parameters play together:
- * <PRE>
- * |------------------------------------------------------------------- track
- * |..........[------------------].....| region
- * |-----------------------------| _position
- * |------------------| _length
- * |----------| _start
- * </PRE>
+ *
+ * POSITION: first frame of the region along the timeline
+ * START: first frame of the region within its source(s)
+ * LENGTH: number of frames the region represents
*/
- nframes_t position () const { return _position; }
- nframes_t start () const { return _start; }
- nframes_t length() const { return _length; }
- layer_t layer () const { return _layer; }
+ sframes_t position () const { return _position; }
+ sframes_t start () const { return _start; }
+ framecnt_t length() const { return _length; }
+ layer_t layer () const { return _layer; }
- sframes_t source_length(uint32_t n) const;
+ framecnt_t source_length(uint32_t n) const;
/* these two are valid ONLY during a StateChanged signal handler */
- nframes_t last_position() const { return _last_position; }
- nframes_t last_length() const { return _last_length; }
+ sframes_t last_position() const { return _last_position; }
+ framecnt_t last_length() const { return _last_length; }
- nframes64_t ancestral_start () const { return _ancestral_start; }
- nframes64_t ancestral_length () const { return _ancestral_length; }
+ sframes_t ancestral_start () const { return _ancestral_start; }
+ framecnt_t ancestral_length () const { return _ancestral_length; }
float stretch() const { return _stretch; }
float shift() const { return _shift; }
void set_ancestral_data (nframes64_t start, nframes64_t length, float stretch, float shift);
- nframes_t sync_offset(int& dir) const;
- nframes_t sync_position() const;
- nframes_t sync_point () const;
-
- nframes_t adjust_to_sync (nframes_t) const;
+ frameoffset_t sync_offset(int& dir) const;
+ framepos_t sync_position() const;
+ framepos_t sync_point () const;
+
+ framepos_t adjust_to_sync (framepos_t) const;
/* first_frame() is an alias; last_frame() just hides some math */
- nframes_t first_frame() const { return _position; }
- nframes_t last_frame() const { return _position + _length - 1; }
-
- Flag flags() const { return _flags; }
- bool hidden() const { return _flags & Hidden; }
- bool muted() const { return _flags & Muted; }
- bool opaque () const { return _flags & Opaque; }
- bool locked() const { return _flags & Locked; }
- bool position_locked() const { return _flags & PositionLocked; }
- bool automatic() const { return _flags & Automatic; }
- bool whole_file() const { return _flags & WholeFile ; }
- bool captured() const { return !(_flags & (Region::Flag (Region::Import|Region::External))); }
- bool can_move() const { return !(_flags & (Locked|PositionLocked)); }
+ framepos_t first_frame() const { return _position; }
+ framepos_t last_frame() const { return _position + _length - 1; }
+
+ bool hidden() const { return _hidden; }
+ bool muted() const { return _muted; }
+ bool opaque () const { return _opaque; }
+ bool locked() const { return _locked; }
+ bool position_locked() const { return _position_locked; }
+ bool automatic() const { return _automatic; }
+ bool whole_file() const { return _whole_file; }
+ bool captured() const { return !(_import || _external); }
+ bool can_move() const { return !_position_locked; }
+ bool sync_marked() const { return _sync_marked; }
+ bool external() const { return _external; }
+ bool import() const { return _import; }
PositionLockStyle positional_lock_style() const { return _positional_lock_style; }
void set_position_lock_style (PositionLockStyle ps);
void freeze ();
void thaw ();
- bool covers (nframes_t frame) const {
+ bool covers (framepos_t frame) const {
return first_frame() <= frame && frame <= last_frame();
}
- OverlapType coverage (nframes_t start, nframes_t end) const {
+ OverlapType coverage (framepos_t start, framepos_t end) const {
return ARDOUR::coverage (first_frame(), last_frame(), start, end);
}
/* EDITING OPERATIONS */
- void set_length (nframes_t, void *src);
- void set_start (nframes_t, void *src);
- void set_position (nframes_t, void *src);
- void set_position_on_top (nframes_t, void *src);
- void special_set_position (nframes_t);
+ void set_length (framecnt_t, void *src);
+ void set_start (framepos_t, void *src);
+ void set_position (framepos_t, void *src);
+ void set_position_on_top (framepos_t, void *src);
+ void special_set_position (framepos_t);
void update_position_after_tempo_map_change ();
- void nudge_position (nframes64_t, void *src);
+ void nudge_position (frameoffset_t, void *src);
bool at_natural_position () const;
void move_to_natural_position (void *src);
- void trim_start (nframes_t new_position, void *src);
- void trim_front (nframes_t new_position, void *src);
- void trim_end (nframes_t new_position, void *src);
- void trim_to (nframes_t position, nframes_t length, void *src);
+ void trim_start (framepos_t new_position, void *src);
+ void trim_front (framepos_t new_position, void *src);
+ void trim_end (framepos_t new_position, void *src);
+ void trim_to (framepos_t position, framecnt_t length, void *src);
void set_layer (layer_t l); /* ONLY Playlist can call this */
void raise ();
void raise_to_top ();
void lower_to_bottom ();
- void set_sync_position (nframes_t n);
+ void set_sync_position (framepos_t n);
void clear_sync_position ();
void set_hidden (bool yn);
void set_muted (bool yn);
+ void set_whole_file (bool yn);
+ void set_automatic (bool yn);
void set_opaque (bool yn);
void set_locked (bool yn);
void set_position_locked (bool yn);
int apply (Filter&);
- virtual uint32_t read_data_count() const { return _read_data_count; }
+ virtual uint64_t read_data_count() const { return _read_data_count; }
boost::shared_ptr<ARDOUR::Playlist> playlist() const { return _playlist.lock(); }
virtual void set_playlist (boost::weak_ptr<ARDOUR::Playlist>);
XMLNode& get_state ();
virtual XMLNode& state (bool);
virtual int set_state (const XMLNode&, int version);
- virtual int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
virtual boost::shared_ptr<Region> get_parent() const;
protected:
friend class RegionFactory;
- Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length,
- const std::string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
- Region (const SourceList& srcs, nframes_t start, nframes_t length,
- const std::string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
-
- Region (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Flag flags = DefaultFlags);
- Region (boost::shared_ptr<const Region>, nframes_t length, const std::string& name, layer_t = 0, Flag flags = DefaultFlags);
+ /** Construct a region from a single source */
+ Region (boost::shared_ptr<Source> src);
+ /** Construct a region from multiple sources*/
+ Region (const SourceList& srcs);
+ /** Construct a region from another region, at an offset within that region */
+ Region (boost::shared_ptr<const Region>, frameoffset_t start_offset = 0, bool start_relative = true);
+ /** Construct a region as a copy of another region, but with different sources */
+ Region (boost::shared_ptr<const Region>, const SourceList&);
+ /** normal Region copy constructor */
Region (boost::shared_ptr<const Region>);
+
+ /** Construct a region from 1 source and XML state */
Region (boost::shared_ptr<Source> src, const XMLNode&);
+ /** Construct a region from multiple sources and XML state */
Region (const SourceList& srcs, const XMLNode&);
- Region (Session& s, nframes_t start, nframes_t length, const std::string& name, DataType, layer_t = 0, Flag flags = DefaultFlags);
+ /** Constructor for derived types only */
+ Region (Session& s, framepos_t start, framecnt_t length, const std::string& name, DataType);
protected:
- void copy_stuff (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const std::string& name, layer_t, Flag flags);
-
- XMLNode& get_short_state (); /* used only by Session */
-
- void send_change (PBD::Change);
+ void send_change (PBD::PropertyChange);
- void trim_to_internal (nframes_t position, nframes_t length, void *src);
- virtual void set_position_internal (nframes_t pos, bool allow_bbt_recompute);
+ void trim_to_internal (framepos_t position, framecnt_t length, void *src);
+ virtual void set_position_internal (framepos_t pos, bool allow_bbt_recompute);
- bool copied() const { return _flags & Copied; }
void maybe_uncopy ();
void first_edit ();
- bool verify_start (nframes_t);
- bool verify_start_and_length (nframes_t, nframes_t&);
- bool verify_start_mutable (nframes_t&_start);
- bool verify_length (nframes_t);
+ bool verify_start (framepos_t);
+ bool verify_start_and_length (framepos_t, framecnt_t&);
+ bool verify_start_mutable (framepos_t&_start);
+ bool verify_length (framecnt_t);
virtual void recompute_at_start () = 0;
virtual void recompute_at_end () = 0;
-
+
DataType _type;
- PBD::EnumState<Flag> _flags;
- PBD::State<nframes_t> _start;
- PBD::State<nframes_t> _length;
- nframes_t _last_length;
- PBD::State<nframes_t> _position;
- nframes_t _last_position;
+ bool _no_property_changes;
+
+ PBD::Property<bool> _muted;
+ PBD::Property<bool> _opaque;
+ PBD::Property<bool> _locked;
+ PBD::Property<bool> _automatic;
+ PBD::Property<bool> _whole_file;
+ PBD::Property<bool> _import;
+ PBD::Property<bool> _external;
+ PBD::Property<bool> _sync_marked;
+ PBD::Property<bool> _left_of_split;
+ PBD::Property<bool> _right_of_split;
+ PBD::Property<bool> _hidden;
+ PBD::Property<bool> _position_locked;
+ PBD::Property<framepos_t> _start;
+ PBD::Property<framecnt_t> _length;
+ PBD::Property<framepos_t> _position;
+ PBD::Property<framepos_t> _sync_position;
+ PBD::Property<layer_t> _layer;
+ PBD::Property<framepos_t> _ancestral_start;
+ PBD::Property<framecnt_t> _ancestral_length;
+ PBD::Property<float> _stretch;
+ PBD::Property<float> _shift;
+
+ framecnt_t _last_length;
+ framepos_t _last_position;
PositionLockStyle _positional_lock_style;
- PBD::State<nframes_t> _sync_position;
- PBD::State<layer_t> _layer;
mutable RegionEditState _first_edit;
int _frozen;
- PBD::State<nframes64_t> _ancestral_start;
- PBD::State<nframes64_t> _ancestral_length;
- PBD::State<float> _stretch;
- PBD::State<float> _shift;
BBT_Time _bbt_time;
AnalysisFeatureList _transients;
bool _valid_transients;
- mutable uint32_t _read_data_count; ///< modified in read()
- PBD::Change _pending_changed;
+ mutable uint64_t _read_data_count; ///< modified in read()
+ PBD::PropertyChange _pending_changed;
uint64_t _last_layer_op; ///< timestamp
Glib::Mutex _lock;
SourceList _sources;
boost::weak_ptr<ARDOUR::Playlist> _playlist;
-private:
+ virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal);
- void register_states ();
+ PBD::PropertyChange set_property (const PBD::PropertyBase&);
+ void register_properties ();
+
+private:
void use_sources (SourceList const &);
};
/** This is emitted only when a new id is assigned. Therefore,
in a pure Region copy, it will not be emitted.
- It must be emitted by derived classes, not Region
+ It must be emitted using a derived instance of Region, not Region
itself, to permit dynamic_cast<> to be used to
infer the type of Region.
*/
static PBD::Signal1<void,boost::shared_ptr<Region> > CheckNewRegion;
- static boost::shared_ptr<Region> create (boost::shared_ptr<const Region>);
-
- /* note: both of the first two should use const shared_ptr as well, but
- gcc 4.1 doesn't seem to be able to disambiguate them if they do.
- */
-
- static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, nframes_t start,
- nframes_t length, const std::string& name,
- layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- static boost::shared_ptr<Region> create (boost::shared_ptr<AudioRegion>, nframes_t start,
- nframes_t length, const std::string& name,
- layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, const SourceList&, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
- static boost::shared_ptr<Region> create (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
+ /** create a "pure copy" of Region @param other */
+ static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other);
+
+ /** create a region from a single Source */
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Source>,
+ const PBD::PropertyList&, bool announce = true);
+ /** create a region from a multiple sources */
+ static boost::shared_ptr<Region> create (const SourceList &,
+ const PBD::PropertyList&, bool announce = true);
+ /** create a copy of @other starting at zero within @param other's sources */
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other,
+ const PBD::PropertyList&, bool announce = true);
+ /** create a copy of @other starting at @param offset within @param other */
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, frameoffset_t offset,
+ const PBD::PropertyList&, bool announce = true);
+ /** create a "copy" of @param other but using a different set of sources @param srcs */
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs,
+ const PBD::PropertyList&, bool announce = true);
+
+ /** create a region with no sources, using XML state */
static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
- static boost::shared_ptr<Region> create (SourceList &, const XMLNode&);
+ /** create a region with specified sources @param srcs and XML state */
+ static boost::shared_ptr<Region> create (SourceList& srcs, const XMLNode&);
private:
static std::map<PBD::ID,boost::weak_ptr<Region> > region_map;
#include <set>
#include <string>
#include <stdint.h>
-#include "pbd/signals.h"
+#include "pbd/signals.h"
#include "pbd/stateful.h"
#include "pbd/signals.h"
#include "ardour/types.h"
+#include "ardour/session_object.h"
namespace ARDOUR {
+namespace Properties {
+ extern PBD::PropertyDescriptor<bool> relative;
+ extern PBD::PropertyDescriptor<bool> active;
+ extern PBD::PropertyDescriptor<bool> gain;
+ extern PBD::PropertyDescriptor<bool> mute;
+ extern PBD::PropertyDescriptor<bool> solo;
+ extern PBD::PropertyDescriptor<bool> recenable;
+ extern PBD::PropertyDescriptor<bool> select;
+ extern PBD::PropertyDescriptor<bool> edit;
+ /* we use this, but its declared in region.cc */
+ extern PBD::PropertyDescriptor<bool> hidden;
+};
+
class Route;
class Track;
class AudioTrack;
class Session;
-class RouteGroup : public PBD::Stateful, public PBD::ScopedConnectionList {
-public:
- enum Flag {
- Relative = 0x1,
- Active = 0x2,
- Hidden = 0x4
- };
-
- enum Property {
- Gain = 0x1,
- Mute = 0x2,
- Solo = 0x4,
- RecEnable = 0x8,
- Select = 0x10,
- Edit = 0x20
- };
-
- RouteGroup (Session& s, const std::string &n, Flag f = Flag(0), Property p = Property(0));
+class RouteGroup : public SessionObject
+{
+ public:
+ static void make_property_quarks();
+
+ RouteGroup (Session& s, const std::string &n);
~RouteGroup ();
- const std::string& name() { return _name; }
- void set_name (std::string str);
+ bool is_active () const { return _active.val(); }
+ bool is_relative () const { return _relative.val(); }
+ bool is_hidden () const { return _hidden.val(); }
+ bool is_gain () const { return _gain.val(); }
+ bool is_mute () const { return _mute.val(); }
+ bool is_solo () const { return _solo.val(); }
+ bool is_recenable () const { return _recenable.val(); }
+ bool is_select () const { return _select.val(); }
+ bool is_edit () const { return _edit.val(); }
- bool is_active () const { return _flags & Active; }
- bool is_relative () const { return _flags & Relative; }
- bool is_hidden () const { return _flags & Hidden; }
bool empty() const {return routes->empty();}
size_t size() const { return routes->size();}
void set_relative (bool yn, void *src);
void set_hidden (bool yn, void *src);
- bool property (Property p) const {
- return ((_properties & p) == p);
- }
-
- bool active_property (Property p) const {
- return is_active() && property (p);
- }
+ void set_gain (bool yn);
+ void set_mute (bool yn);
+ void set_solo (bool yn);
+ void set_recenable (bool yn);
+ void set_select (bool yn);
+ void set_edit (bool yn);
- void set_property (Property p, bool v) {
- _properties = (Property) (_properties & ~p);
- if (v) {
- _properties = (Property) (_properties | p);
- }
- }
+ bool enabled_property (PBD::PropertyID);
int add (boost::shared_ptr<Route>);
int remove (boost::shared_ptr<Route>);
PBD::Signal0<void> changed;
PBD::Signal1<void,void*> FlagsChanged;
+ static PBD::PropertyChange FlagsChange;
+ static PBD::PropertyChange PropertiesChange;
+
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
private:
- Session& _session;
boost::shared_ptr<RouteList> routes;
boost::shared_ptr<Route> subgroup_bus;
- std::string _name;
- Flag _flags;
- Property _properties;
+
+ PBD::Property<bool> _relative;
+ PBD::Property<bool> _active;
+ PBD::Property<bool> _hidden;
+ PBD::Property<bool> _gain;
+ PBD::Property<bool> _mute;
+ PBD::Property<bool> _solo;
+ PBD::Property<bool> _recenable;
+ PBD::Property<bool> _select;
+ PBD::Property<bool> _edit;
void remove_when_going_away (boost::weak_ptr<Route>);
int set_state_2X (const XMLNode&, int);
void xrun_recovery ();
TempoMap *_tempo_map;
- void tempo_map_changed (PBD::Change);
+ void tempo_map_changed (PBD::PropertyChange);
/* edit/mix groups */
RegionList regions;
void add_region (boost::shared_ptr<Region>);
- void region_changed (PBD::Change, boost::weak_ptr<Region>);
+ void region_changed (PBD::PropertyChange, boost::weak_ptr<Region>);
void remove_region (boost::weak_ptr<Region>);
int load_regions (const XMLNode& node);
/*
- Copyright (C) 2000-2007 Paul Davis
+ Copyright (C) 2000-2010 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "pbd/statefuldestructible.h"
#include "pbd/signals.h"
+#include "ardour/ardour.h"
#include "ardour/session_handle.h"
#include "i18n.h"
namespace ARDOUR {
+namespace Properties {
+ extern PBD::PropertyDescriptor<std::string> name;
+}
+
class Session;
/** A named object associated with a Session. Objects derived from this class are
class SessionObject : public SessionHandleRef, public PBD::StatefulDestructible
{
public:
+ static void make_property_quarks ();
+
SessionObject (Session& session, const std::string& name)
: SessionHandleRef (session)
- , _name (X_("name"), PBD::Change (0), name)
+ , _name (Properties::name, PBD::PropertyChange (0), name)
{
- add_state (_name);
+ add_property (_name);
}
Session& session() const { return _session; }
std::string name() const { return _name; }
+ PBD::PropertyChange set_property (const PBD::PropertyBase& prop);
+
virtual bool set_name (const std::string& str) {
if (_name != str) {
_name = str;
PBD::Signal0<void> NameChanged;
protected:
- PBD::State<std::string> _name;
+ PBD::Property<std::string> _name;
};
} // namespace ARDOUR
protected:
friend class SourceFactory;
- SilentFileSource (Session& s, const XMLNode& x, nframes_t len, float srate)
+ SilentFileSource (Session& s, const XMLNode& x, framecnt_t len, float srate)
: Source (s, x)
, AudioFileSource (s, x, false)
, _sample_rate(srate)
_length = len;
}
- nframes_t read_unlocked (Sample *dst, sframes_t /*start*/, nframes_t cnt) const {
+ framecnt_t read_unlocked (Sample *dst, framepos_t /*start*/, framecnt_t cnt) const {
memset (dst, 0, sizeof (Sample) * cnt);
return cnt;
}
- nframes_t write_unlocked (Sample */*dst*/, nframes_t /*cnt*/) { return 0; }
-
+ framecnt_t write_unlocked (Sample */*dst*/, framecnt_t /*cnt*/) { return 0; }
+
void set_header_timeline_position () {}
- int read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t /*start*/, nframes_t /*cnt*/,
- double /*samples_per_unit*/, nframes_t /*fpp*/) const {
+ int read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t /*start*/, framecnt_t /*cnt*/,
+ double /*samples_per_unit*/, framecnt_t /*fpp*/) const {
memset (peaks, 0, sizeof (PeakData) * npeaks);
return 0;
}
protected:
void set_header_timeline_position ();
- nframes_t read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const;
- nframes_t write_unlocked (Sample *dst, nframes_t cnt);
-
- nframes_t write_float (Sample* data, sframes_t pos, nframes_t cnt);
+ framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
+ framecnt_t write_unlocked (Sample *dst, framecnt_t cnt);
+ framecnt_t write_float (Sample* data, framepos_t pos, framecnt_t cnt);
private:
SNDFILE *sf;
void init_sndfile ();
int open();
- int setup_broadcast_info (sframes_t when, struct tm&, time_t);
+ int setup_broadcast_info (framepos_t when, struct tm&, time_t);
/* destructive */
- static nframes_t xfade_frames;
+ static framecnt_t xfade_frames;
static gain_t* out_coefficient;
static gain_t* in_coefficient;
bool _capture_start;
bool _capture_end;
- sframes_t capture_start_frame;
- sframes_t file_pos; // unit is frames
- nframes_t xfade_out_count;
- nframes_t xfade_in_count;
+ framepos_t capture_start_frame;
+ framepos_t file_pos; // unit is frames
+ framecnt_t xfade_out_count;
+ framecnt_t xfade_in_count;
Sample* xfade_buf;
-
- nframes_t crossfade (Sample* data, nframes_t cnt, int dir);
- void set_timeline_position (int64_t);
- nframes_t destructive_write_unlocked (Sample *dst, nframes_t cnt);
- nframes_t nondestructive_write_unlocked (Sample *dst, nframes_t cnt);
+
+ framecnt_t crossfade (Sample* data, framecnt_t cnt, int dir);
+ void set_timeline_position (framepos_t);
+ framecnt_t destructive_write_unlocked (Sample *dst, framecnt_t cnt);
+ framecnt_t nondestructive_write_unlocked (Sample *dst, framecnt_t cnt);
void handle_header_position_change ();
PBD::ScopedConnection header_position_connection;
};
time_t timestamp() const { return _timestamp; }
void stamp (time_t when) { _timestamp = when; }
- virtual sframes_t length (sframes_t pos) const = 0;
- virtual void update_length (sframes_t pos, sframes_t cnt) = 0;
+ virtual framecnt_t length (framepos_t pos) const = 0;
+ virtual void update_length (framepos_t pos, framecnt_t cnt) = 0;
virtual const Glib::ustring& path() const = 0;
- virtual nframes64_t natural_position() const { return 0; }
+ virtual framepos_t natural_position() const { return 0; }
void mark_for_remove();
nframes_t frame_rate () const { return _frame_rate; }
- PBD::Signal1<void,PBD::Change> StateChanged;
+ PBD::Signal1<void,PBD::PropertyChange> StateChanged;
private:
static Tempo _default_tempo;
* don't want to pay for extremely long session times they don't need...
*/
typedef int64_t sframes_t;
+ typedef int64_t framepos_t;
+ /* any offset from a framepos_t, measured in audio frames */
+ typedef int64_t frameoffset_t;
+ /* any count of audio frames */
+ typedef int64_t framecnt_t;
enum IOChange {
NoChange = 0,
/* a single full-sized region */
- boost::shared_ptr<Region> region (RegionFactory::create (srcs, 0, max_frames - srcs.front()->natural_position(), _name));
+ PropertyList plist;
+ plist.add (Properties::name, _name.val());
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, max_frames - max_frames - srcs.front()->natural_position());
+
+ boost::shared_ptr<Region> region (RegionFactory::create (srcs, plist));
_playlist->add_region (region, srcs.front()->natural_position());
}
*/
try {
- boost::shared_ptr<Region> rx (RegionFactory::create (srcs,
- c->front()->write_source->last_capture_start_frame(), total_capture,
- whole_file_region_name, 0,
- Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
+ PropertyList plist;
+
+ plist.add (Properties::start, c->front()->write_source->last_capture_start_frame());
+ plist.add (Properties::length, total_capture);
+ plist.add (Properties::name, whole_file_region_name);
+
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
+ rx->set_automatic (true);
+ rx->set_whole_file (true);
region = boost::dynamic_pointer_cast<AudioRegion> (rx);
region->special_set_position (capture_info.front()->start);
// cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add region " << region_name << endl;
try {
- boost::shared_ptr<Region> rx (RegionFactory::create (srcs, buffer_position, (*ci)->frames, region_name));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, buffer_position);
+ plist.add (Properties::length, (*ci)->frames);
+ plist.add (Properties::name, region_name);
+
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
region = boost::dynamic_pointer_cast<AudioRegion> (rx);
}
boost::shared_ptr<AudioRegion> region;
try {
- region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (
- pending_sources, 0, first_fs->length(first_fs->timeline_position()),
- region_name_from_path (first_fs->name(), true), 0,
- Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, first_fs->length (first_fs->timeline_position()));
+ plist.add (Properties::name, region_name_from_path (first_fs->name(), true));
+
+ region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (pending_sources, plist));
+
+ region->set_automatic (true);
+ region->set_whole_file (true);
region->special_set_position (0);
}
return -1;
}
- try {
- region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (
- pending_sources, 0, first_fs->length(first_fs->timeline_position()),
- region_name_from_path (first_fs->name(), true)));
- }
-
- catch (failed_constructor& err) {
- error << string_compose (_("%1: cannot create region from pending capture sources"),
- _name)
- << endmsg;
-
- return -1;
- }
-
_playlist->add_region (region, position);
return 0;
audio engineering.
*/
- xfade_length = min ((nframes_t) 720, top->length());
+ xfade_length = min ((framecnt_t) 720, top->length());
if (top_region_at (top->first_frame()) == top) {
} else {
touched_regions = regions_touched (top->first_frame(),
- top->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
+ top->first_frame() + min ((framecnt_t) _session.config.get_short_xfade_seconds() * _session.frame_rate(),
top->length()));
if (touched_regions->size() <= 2) {
xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active()));
} else {
touched_regions = regions_touched (bottom->first_frame(),
- bottom->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
+ bottom->first_frame() + min ((framecnt_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
bottom->length()));
if (touched_regions->size() <= 2) {
xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active()));
}
void
-AudioPlaylist::crossfade_changed (Change)
+AudioPlaylist::crossfade_changed (PropertyChange)
{
if (in_flush || in_set_state) {
return;
}
bool
-AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
+AudioPlaylist::region_changed (PropertyChange what_changed, boost::shared_ptr<Region> region)
{
if (in_flush || in_set_state) {
return false;
}
- Change our_interests = Change (AudioRegion::FadeInChanged|
+ PropertyChange our_interests = PropertyChange (AudioRegion::FadeInChanged|
AudioRegion::FadeOutChanged|
AudioRegion::FadeInActiveChanged|
AudioRegion::FadeOutActiveChanged|
/* create a new region from all filesources, keep it private */
- boost::shared_ptr<Region> region (RegionFactory::create (srcs, 0,
- srcs[0]->length(srcs[0]->timeline_position()),
- region_name, 0,
- (Region::Flag) (Region::WholeFile|Region::DefaultFlags),
- false));
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, srcs[0]->length(srcs[0]->timeline_position()));
+ plist.add (Properties::name, region_name);
+ plist.add (Properties::whole_file, true);
+
+ boost::shared_ptr<Region> region (RegionFactory::create (srcs, plist, false));
new_playlist->set_orig_diskstream_id (diskstream->id());
new_playlist->add_region (region, _session.current_start_frame());
#include "evoral/Curve.hpp"
#include "ardour/audioregion.h"
+#include "ardour/debug.h"
#include "ardour/session.h"
#include "ardour/gain.h"
#include "ardour/dB.h"
using namespace ARDOUR;
using namespace PBD;
-/* a Session will reset these to its chosen defaults by calling AudioRegion::set_default_fade() */
+namespace ARDOUR {
+ namespace Properties {
+ PBD::PropertyDescriptor<bool> envelope_active;
+ PBD::PropertyDescriptor<bool> default_fade_in;
+ PBD::PropertyDescriptor<bool> default_fade_out;
+ PBD::PropertyDescriptor<bool> fade_in_active;
+ PBD::PropertyDescriptor<bool> fade_out_active;
+ PBD::PropertyDescriptor<float> scale_amplitude;
+ }
+}
-Change AudioRegion::FadeInChanged = PBD::new_change();
-Change AudioRegion::FadeOutChanged = PBD::new_change();
-Change AudioRegion::FadeInActiveChanged = PBD::new_change();
-Change AudioRegion::FadeOutActiveChanged = PBD::new_change();
-Change AudioRegion::EnvelopeActiveChanged = PBD::new_change();
-Change AudioRegion::ScaleAmplitudeChanged = PBD::new_change();
-Change AudioRegion::EnvelopeChanged = PBD::new_change();
+void
+AudioRegion::make_property_quarks ()
+{
+ Properties::envelope_active.id = g_quark_from_static_string (X_("envelope-active"));
+ Properties::default_fade_in.id = g_quark_from_static_string (X_("default-fade-in"));
+ Properties::default_fade_out.id = g_quark_from_static_string (X_("default-fade-out"));
+ Properties::fade_in_active.id = g_quark_from_static_string (X_("fade-in-active"));
+ Properties::fade_out_active.id = g_quark_from_static_string (X_("fade-out-active"));
+ Properties::scale_amplitude.id = g_quark_from_static_string (X_("scale-amplitude"));
+}
+
+void
+AudioRegion::register_properties ()
+{
+ /* no need to register parent class properties */
+
+ add_property (_envelope_active);
+ add_property (_default_fade_in);
+ add_property (_default_fade_out);
+ add_property (_fade_in_active);
+ add_property (_fade_out_active);
+ add_property (_scale_amplitude);
+}
+
+#define AUDIOREGION_STATE_DEFAULT \
+ _envelope_active (Properties::envelope_active, EnvelopeActiveChanged, false) \
+ , _default_fade_in (Properties::default_fade_in, FadeInChanged, true) \
+ , _default_fade_out (Properties::default_fade_out, FadeOutChanged, true) \
+ , _fade_in_active (Properties::fade_in_active, FadeInActiveChanged, true) \
+ , _fade_out_active (Properties::fade_out_active, FadeOutActiveChanged, true) \
+ , _scale_amplitude (Properties::scale_amplitude, ScaleAmplitudeChanged, 1.0)
+
+#define AUDIOREGION_COPY_STATE(other) \
+ _envelope_active (other->_envelope_active) \
+ , _default_fade_in (other->_default_fade_in) \
+ , _default_fade_out (other->_default_fade_out) \
+ , _fade_in_active (other->_fade_in_active) \
+ , _fade_out_active (other->_fade_out_active) \
+ , _scale_amplitude (other->_scale_amplitude)
+
+PropertyChange AudioRegion::FadeInChanged = PBD::new_change();
+PropertyChange AudioRegion::FadeOutChanged = PBD::new_change();
+PropertyChange AudioRegion::FadeInActiveChanged = PBD::new_change();
+PropertyChange AudioRegion::FadeOutActiveChanged = PBD::new_change();
+PropertyChange AudioRegion::EnvelopeActiveChanged = PBD::new_change();
+PropertyChange AudioRegion::ScaleAmplitudeChanged = PBD::new_change();
+PropertyChange AudioRegion::EnvelopeChanged = PBD::new_change();
+
+/* a Session will reset these to its chosen defaults by calling AudioRegion::set_default_fade() */
void
AudioRegion::init ()
{
- _scale_amplitude = 1.0;
+ register_properties ();
set_default_fades ();
set_default_envelope ();
listen_to_my_curves ();
connect_to_analysis_changed ();
+ connect_to_header_position_offset_changed ();
}
/** Constructor for use by derived types only */
-AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string name)
- : Region (s, start, length, name, DataType::AUDIO)
- , _automatable(s)
+AudioRegion::AudioRegion (Session& s, framepos_t start, framecnt_t len, std::string name)
+ : Region (s, start, len, name, DataType::AUDIO)
+ , AUDIOREGION_STATE_DEFAULT
+ , _automatable (s)
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
init ();
assert (_sources.size() == _master_sources.size());
}
/** Basic AudioRegion constructor (one channel) */
-AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, nframes_t length)
- : Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::AUDIO, 0, Region::Flag(Region::DefaultFlags|Region::External))
+AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src)
+ : Region (boost::static_pointer_cast<Source>(src))
+ , AUDIOREGION_STATE_DEFAULT
, _automatable(src->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
- boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
- if (afs) {
- afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this));
- }
-
init ();
- assert (_sources.size() == _master_sources.size());
-}
-
-/* Basic AudioRegion constructor (one channel) */
-AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (src, start, length, name, DataType::AUDIO, layer, flags)
- , _automatable(src->session())
- , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
- , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
- , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
-{
- boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
- if (afs) {
- afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this));
- }
+
+ /* XXX why is this set here ? - set in a property list given to RegionFactory */
+ _external = true;
- init ();
assert (_sources.size() == _master_sources.size());
}
/** Basic AudioRegion constructor (many channels) */
-AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (srcs, start, length, name, DataType::AUDIO, layer, flags)
+AudioRegion::AudioRegion (const SourceList& srcs)
+ : Region (srcs)
+ , AUDIOREGION_STATE_DEFAULT
, _automatable(srcs[0]->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
init ();
- connect_to_analysis_changed ();
- assert (_sources.size() == _master_sources.size());
-}
-
-/** Create a new AudioRegion, that is part of an existing one */
-AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (other, offset, length, name, layer, flags)
- , _automatable(other->session())
- , _fade_in (new AutomationList(*other->_fade_in))
- , _fade_out (new AutomationList(*other->_fade_out))
- , _envelope (new AutomationList(*other->_envelope, offset, offset + length))
-{
- connect_to_header_position_offset_changed ();
-
- /* return to default fades if the existing ones are too long */
-
- if (_flags & LeftOfSplit) {
- if (_fade_in->back()->when >= _length) {
- set_default_fade_in ();
- } else {
- _fade_in_disabled = other->_fade_in_disabled;
- }
- set_default_fade_out ();
- _flags = Flag (_flags & ~Region::LeftOfSplit);
- }
-
- if (_flags & RightOfSplit) {
- if (_fade_out->back()->when >= _length) {
- set_default_fade_out ();
- } else {
- _fade_out_disabled = other->_fade_out_disabled;
- }
- set_default_fade_in ();
- _flags = Flag (_flags & ~Region::RightOfSplit);
- }
-
- _scale_amplitude = other->_scale_amplitude;
-
- assert(_type == DataType::AUDIO);
-
- listen_to_my_curves ();
- connect_to_analysis_changed ();
-
assert (_sources.size() == _master_sources.size());
}
-AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
- : Region (other)
+AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes64_t offset, bool offset_relative)
+ : Region (other, offset, offset_relative)
+ , AUDIOREGION_COPY_STATE (other)
, _automatable (other->session())
, _fade_in (new AutomationList (*other->_fade_in))
, _fade_out (new AutomationList (*other->_fade_out))
- , _envelope (new AutomationList (*other->_envelope))
+ /* XXX is this guaranteed to work for all values of offset+offset_relative? */
+ , _envelope (new AutomationList (*other->_envelope, _start, _start + _length))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
- assert(_type == DataType::AUDIO);
- _scale_amplitude = other->_scale_amplitude;
-
+ /* don't use init here, because we got fade in/out from the other region
+ */
+ register_properties ();
listen_to_my_curves ();
connect_to_analysis_changed ();
+ connect_to_header_position_offset_changed ();
+ assert(_type == DataType::AUDIO);
assert (_sources.size() == _master_sources.size());
}
-AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const SourceList& /*srcs*/,
- nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (other, length, name, layer, flags)
+AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const SourceList& srcs)
+ : Region (boost::static_pointer_cast<const Region>(other), srcs)
+ , AUDIOREGION_COPY_STATE (other)
, _automatable (other->session())
, _fade_in (new AutomationList (*other->_fade_in))
, _fade_out (new AutomationList (*other->_fade_out))
, _envelope (new AutomationList (*other->_envelope))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
/* make-a-sort-of-copy-with-different-sources constructor (used by audio filter) */
- for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
-
- boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> ((*i));
- if (afs) {
- afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this));
- }
- }
-
- _scale_amplitude = other->_scale_amplitude;
-
- _fade_in_disabled = 0;
- _fade_out_disabled = 0;
+ register_properties ();
listen_to_my_curves ();
connect_to_analysis_changed ();
+ connect_to_header_position_offset_changed ();
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& node)
: Region (src, node)
+ , AUDIOREGION_STATE_DEFAULT
, _automatable(src->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
{
- boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
- if (afs) {
- afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this));
- }
-
init ();
if (set_state (node, Stateful::loading_state_version)) {
}
assert(_type == DataType::AUDIO);
- connect_to_analysis_changed ();
-
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
: Region (srcs, node)
+ , AUDIOREGION_STATE_DEFAULT
, _automatable(srcs[0]->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
+ , _fade_in_suspended (0)
+ , _fade_out_suspended (0)
{
init ();
{
}
+void
+AudioRegion::post_set ()
+{
+ if (!_sync_marked) {
+ _sync_position = _start;
+ }
+
+ /* return to default fades if the existing ones are too long */
+
+ if (_left_of_split) {
+ if (_fade_in->back()->when >= _length) {
+ set_default_fade_in ();
+ }
+ set_default_fade_out ();
+ _left_of_split = false;
+ }
+
+ if (_right_of_split) {
+ if (_fade_out->back()->when >= _length) {
+ set_default_fade_out ();
+ }
+
+ set_default_fade_in ();
+ _right_of_split = false;
+ }
+}
+
void
AudioRegion::connect_to_analysis_changed ()
{
void
AudioRegion::listen_to_my_curves ()
{
- cerr << _name << ": listeing my own curves\n";
-
_envelope->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::envelope_changed, this));
_fade_in->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_in_changed, this));
_fade_out->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_out_changed, this));
AudioRegion::set_envelope_active (bool yn)
{
if (envelope_active() != yn) {
- if (yn) {
- _flags = Flag (_flags|EnvelopeActive);
- } else {
- _flags = Flag (_flags & ~EnvelopeActive);
- }
+ _envelope_active = yn;
send_change (EnvelopeActiveChanged);
}
}
if (audio_source(chan_n)->read_peaks (buf, npeaks, offset, cnt, samples_per_unit)) {
return 0;
} else {
- if (_scale_amplitude != 1.0) {
+ if (_scale_amplitude != 1.0f) {
for (nframes_t n = 0; n < npeaks; ++n) {
buf[n].max *= _scale_amplitude;
buf[n].min *= _scale_amplitude;
}
}
-nframes_t
-AudioRegion::read (Sample* buf, sframes_t timeline_position, nframes_t cnt, int channel) const
+framecnt_t
+AudioRegion::read (Sample* buf, framepos_t timeline_position, framecnt_t cnt, int channel) const
{
/* raw read, no fades, no gain, nada */
return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, 0, 0, ReadOps (0));
}
-nframes_t
-AudioRegion::read_with_ops (Sample* buf, sframes_t file_position, nframes_t cnt, int channel, ReadOps rops) const
+framecnt_t
+AudioRegion::read_with_ops (Sample* buf, framepos_t file_position, framecnt_t cnt, int channel, ReadOps rops) const
{
return _read_at (_sources, _length, buf, 0, 0, file_position, cnt, channel, 0, 0, rops);
}
-nframes_t
+framecnt_t
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- sframes_t file_position, nframes_t cnt, uint32_t chan_n,
- nframes_t read_frames, nframes_t skip_frames) const
+ framepos_t file_position, framecnt_t cnt, uint32_t chan_n,
+ framecnt_t read_frames, framecnt_t skip_frames) const
{
/* regular diskstream/butler read complete with fades etc */
return _read_at (_sources, _length, buf, mixdown_buffer, gain_buffer,
file_position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
}
-nframes_t
+framecnt_t
AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- sframes_t position, nframes_t cnt, uint32_t chan_n) const
+ framepos_t position, framecnt_t cnt, uint32_t chan_n) const
{
/* do not read gain/scaling/fades and do not count this disk i/o in statistics */
buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0, ReadOps (0));
}
-nframes_t
-AudioRegion::_read_at (const SourceList& /*srcs*/, nframes_t limit,
- Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- sframes_t position, nframes_t cnt,
- uint32_t chan_n,
- nframes_t /*read_frames*/,
- nframes_t /*skip_frames*/,
- ReadOps rops) const
+framecnt_t
+AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
+ Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+ framepos_t position,
+ framecnt_t cnt,
+ uint32_t chan_n,
+ framecnt_t /*read_frames*/,
+ framecnt_t /*skip_frames*/,
+ ReadOps rops) const
{
- nframes_t internal_offset;
- nframes_t buf_offset;
- nframes_t to_read;
+ frameoffset_t internal_offset;
+ frameoffset_t buf_offset;
+ framecnt_t to_read;
bool raw = (rops == ReadOpsNone);
if (muted() && !raw) {
/* fade in */
- if ((_flags & FadeIn) && _session.config.get_use_region_fades()) {
+ if (_fade_in_active && _session.config.get_use_region_fades()) {
nframes_t fade_in_length = (nframes_t) _fade_in->back()->when;
/* fade out */
- if ((_flags & FadeOut) && _session.config.get_use_region_fades()) {
+ if (_fade_out_active && _session.config.get_use_region_fades()) {
/* see if some part of this read is within the fade out */
char buf2[64];
LocaleGuard lg (X_("POSIX"));
- snprintf (buf, sizeof(buf), "%.12g", _scale_amplitude);
- node.add_property ("scale-gain", buf);
// XXX these should move into Region
node.add_property ("channels", buf);
if (full) {
-
- child = node.add_child (X_("FadeIn"));
-
- if ((_flags & DefaultFadeIn)) {
- child->add_property (X_("default"), X_("yes"));
- } else {
- child->add_child_nocopy (_fade_in->get_state ());
- }
-
- child->add_property (X_("active"), fade_in_active () ? X_("yes") : X_("no"));
-
- child = node.add_child (X_("FadeOut"));
-
- if ((_flags & DefaultFadeOut)) {
- child->add_property (X_("default"), X_("yes"));
- } else {
- child->add_child_nocopy (_fade_out->get_state ());
- }
-
- child->add_property (X_("active"), fade_out_active () ? X_("yes") : X_("no"));
+ Stateful::add_properties (node);
}
child = node.add_child ("Envelope");
}
int
-AudioRegion::set_live_state (const XMLNode& node, int version, Change& what_changed, bool send)
+AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_changed, bool send)
{
const XMLNodeList& nlist = node.children();
const XMLProperty *prop;
boost::shared_ptr<Playlist> the_playlist (_playlist.lock());
freeze ();
+
if (the_playlist) {
the_playlist->freeze ();
}
- Region::set_live_state (node, version, what_changed, false);
- cerr << "After region SLS, wc = " << what_changed << endl;
+ /* this will set all our State members and stuff controlled by the Region.
+ It should NOT send any changed signals - that is our responsibility.
+ */
- if ((prop = node.property ("flags")) != 0) {
- _flags = Flag (_flags & ~Region::LeftOfSplit);
- _flags = Flag (_flags & ~Region::RightOfSplit);
- }
-
- /* find out if any flags changed that we signal about */
+ Region::_set_state (node, version, what_changed, false);
if ((prop = node.property ("scale-gain")) != 0) {
float a = atof (prop->value().c_str());
if (a != _scale_amplitude) {
_scale_amplitude = a;
- what_changed = Change (what_changed|ScaleAmplitudeChanged);
+ what_changed = PropertyChange (what_changed|ScaleAmplitudeChanged);
cerr << _name << " amp changed\n";
}
}
- /* Now find envelope description and other misc child items */
+ /* Now find envelope description and other related child items */
_envelope->freeze ();
for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
-#if 0
XMLNode *child;
XMLProperty *prop;
cerr << _name << " fadeout changd\n";
}
-#endif
}
_envelope->thaw ();
return 0;
}
+PropertyChange
+AudioRegion::set_property (const PropertyBase& prop)
+{
+ PropertyChange c = PropertyChange (0);
+
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("audio region %1 set property %2\n", _name.val(), prop.property_name()));
+
+ if (prop == Properties::envelope_active.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _envelope_active) {
+ _envelope_active = val;
+ c = EnvelopeActiveChanged;
+ }
+ } else if (prop == Properties::default_fade_in.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _default_fade_in) {
+ _default_fade_in = val;
+ c = FadeInChanged;
+ }
+ } else if (prop == Properties::default_fade_out.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _default_fade_out) {
+ _default_fade_out = val;
+ c = FadeOutChanged;
+ }
+ } else if (prop == Properties::fade_in_active.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _fade_in_active) {
+ _fade_in_active = val;
+ c = FadeInActiveChanged;
+ }
+ } else if (prop == Properties::fade_out_active.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _fade_out_active) {
+ _fade_out_active = val;
+ c = FadeOutChanged;
+ }
+ } else if (prop == Properties::scale_amplitude.id) {
+ gain_t val = dynamic_cast<const PropertyTemplate<gain_t>*>(&prop)->val();
+ if (val != _scale_amplitude) {
+ _scale_amplitude = val;
+ c = ScaleAmplitudeChanged;
+ }
+ } else {
+ return Region::set_property (prop);
+ }
+
+ return c;
+}
+
int
AudioRegion::set_state (const XMLNode& node, int version)
{
- /* Region::set_state() calls the virtual set_live_state(),
- which will get us back to AudioRegion::set_live_state()
- to handle the relevant stuff.
- */
-
- return Region::set_state (node, version);
+ PropertyChange what_changed;
+ return _set_state (node, version, what_changed, true);
}
void
}
void
-AudioRegion::set_fade_in (FadeShape shape, nframes_t len)
+AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
{
_fade_in->freeze ();
_fade_in->clear ();
}
void
-AudioRegion::set_fade_out (FadeShape shape, nframes_t len)
+AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
{
_fade_out->freeze ();
_fade_out->clear ();
}
void
-AudioRegion::set_fade_in_length (nframes_t len)
+AudioRegion::set_fade_in_length (framecnt_t len)
{
if (len > _length) {
len = _length - 1;
bool changed = _fade_in->extend_to (len);
if (changed) {
- _flags = Flag (_flags & ~DefaultFadeIn);
+ _default_fade_in = false;
send_change (FadeInChanged);
}
}
void
-AudioRegion::set_fade_out_length (nframes_t len)
+AudioRegion::set_fade_out_length (framecnt_t len)
{
if (len > _length) {
len = _length - 1;
bool changed = _fade_out->extend_to (len);
if (changed) {
- _flags = Flag (_flags & ~DefaultFadeOut);
+ _default_fade_out = false;
send_change (FadeOutChanged);
}
}
void
AudioRegion::set_fade_in_active (bool yn)
{
- if (yn == (_flags & FadeIn)) {
+ if (yn == _fade_in_active) {
return;
}
- if (yn) {
- _flags = Flag (_flags|FadeIn);
- } else {
- _flags = Flag (_flags & ~FadeIn);
- }
+ _fade_in_active = yn;
send_change (FadeInActiveChanged);
}
void
AudioRegion::set_fade_out_active (bool yn)
{
- if (yn == (_flags & FadeOut)) {
+ if (yn == _fade_out_active) {
return;
}
- if (yn) {
- _flags = Flag (_flags | FadeOut);
- } else {
- _flags = Flag (_flags & ~FadeOut);
- }
-
+ _fade_out_active = yn;
send_change (FadeOutActiveChanged);
}
void
AudioRegion::set_default_fade_in ()
{
- _fade_in_disabled = 0;
+ _fade_in_suspended = 0;
set_fade_in (Linear, 64);
}
void
AudioRegion::set_default_fade_out ()
{
- _fade_out_disabled = 0;
+ _fade_out_suspended = 0;
set_fade_out (Linear, 64);
}
"whole file" even if it covers the entire source file(s).
*/
- Flag f = Flag (_flags & ~WholeFile);
+ PropertyList plist;
+
+ plist.add (Properties::start, _start.val());
+ plist.add (Properties::length, _length.val());
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, _layer.val());
- v.push_back(RegionFactory::create (srcs, _start, _length, new_name, _layer, f));
+ v.push_back(RegionFactory::create (srcs, plist));
+ v.back()->set_whole_file (false);
++n;
}
return 0;
}
-nframes_t
-AudioRegion::read_raw_internal (Sample* buf, sframes_t pos, nframes_t cnt, int channel) const
+framecnt_t
+AudioRegion::read_raw_internal (Sample* buf, framepos_t pos, framecnt_t cnt, int channel) const
{
return audio_source()->read (buf, pos, cnt, channel);
}
void
AudioRegion::normalize_to (float target_dB)
{
- const nframes_t blocksize = 64 * 1024;
+ const framecnt_t blocksize = 64 * 1024;
Sample buf[blocksize];
- nframes_t fpos;
- nframes_t fend;
- nframes_t to_read;
+ framepos_t fpos;
+ framepos_t fend;
+ framecnt_t to_read;
double maxamp = 0;
gain_t target = dB_to_coefficient (target_dB);
void
AudioRegion::suspend_fade_in ()
{
- if (++_fade_in_disabled == 1) {
+ if (++_fade_in_suspended == 1) {
if (fade_in_is_default()) {
set_fade_in_active (false);
}
void
AudioRegion::resume_fade_in ()
{
- if (--_fade_in_disabled == 0 && _fade_in_disabled) {
+ if (--_fade_in_suspended == 0 && _fade_in_suspended) {
set_fade_in_active (true);
}
}
void
AudioRegion::suspend_fade_out ()
{
- if (++_fade_out_disabled == 1) {
+ if (++_fade_out_suspended == 1) {
if (fade_out_is_default()) {
set_fade_out_active (false);
}
void
AudioRegion::resume_fade_out ()
{
- if (--_fade_out_disabled == 0 &&_fade_out_disabled) {
+ if (--_fade_out_suspended == 0 &&_fade_out_suspended) {
set_fade_out_active (true);
}
}
* @return Silent periods; first of pair is the offset within the region, second is the length of the period
*/
-std::list<std::pair<nframes_t, nframes_t> >
-AudioRegion::find_silence (Sample threshold, nframes_t min_length) const
+std::list<std::pair<frameoffset_t, framecnt_t> >
+AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
{
- nframes_t const block_size = 64 * 1024;
+ framecnt_t const block_size = 64 * 1024;
Sample loudest[block_size];
Sample buf[block_size];
- nframes_t pos = _start;
- nframes_t const end = _start + _length - 1;
+ framepos_t pos = _start;
+ framepos_t const end = _start + _length - 1;
- std::list<std::pair<nframes_t, nframes_t> > silent_periods;
+ std::list<std::pair<frameoffset_t, framecnt_t> > silent_periods;
bool in_silence = false;
- nframes_t silence_start = 0;
+ frameoffset_t silence_start = 0;
bool silence;
while (pos < end) {
for (uint32_t n = 0; n < n_channels(); ++n) {
read_raw_internal (buf, pos, block_size, n);
- for (nframes_t i = 0; i < block_size; ++i) {
+ for (framecnt_t i = 0; i < block_size; ++i) {
loudest[i] = max (loudest[i], abs (buf[i]));
}
}
/* now look for silence */
- for (nframes_t i = 0; i < block_size; ++i) {
+ for (framecnt_t i = 0; i < block_size; ++i) {
silence = abs (loudest[i]) < threshold;
if (silence && !in_silence) {
/* non-silence to silence */
}
+
extern "C" {
int region_read_peaks_from_c (void *arg, uint32_t npeaks, uint32_t start, uint32_t cnt, intptr_t data, uint32_t n_chan, double samples_per_unit)
{
- return ((AudioRegion *) arg)->read_peaks ((PeakData *) data, (nframes_t) npeaks, (nframes_t) start, (nframes_t) cnt, n_chan,samples_per_unit);
+ return ((AudioRegion *) arg)->read_peaks ((PeakData *) data, (framecnt_t) npeaks, (framepos_t) start, (framecnt_t) cnt, n_chan,samples_per_unit);
}
uint32_t region_length_from_c (void *arg)
return 0;
}
-nframes_t
-AudioSource::read (Sample *dst, sframes_t start, nframes_t cnt, int /*channel*/) const
+framecnt_t
+AudioSource::read (Sample *dst, framepos_t start, framecnt_t cnt, int /*channel*/) const
{
Glib::Mutex::Lock lm (_lock);
return read_unlocked (dst, start, cnt);
}
-nframes_t
-AudioSource::write (Sample *dst, nframes_t cnt)
+framecnt_t
+AudioSource::write (Sample *dst, framecnt_t cnt)
{
Glib::Mutex::Lock lm (_lock);
/* any write makes the fill not removable */
}
int
-AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, sframes_t start, nframes_t cnt, double samples_per_visual_peak) const
+AudioSource::read_peaks (PeakData *peaks, framecnt_t npeaks, framepos_t start, framecnt_t cnt, double samples_per_visual_peak) const
{
return read_peaks_with_fpp (peaks, npeaks, start, cnt, samples_per_visual_peak, _FPP);
}
*/
int
-AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t start, nframes_t cnt,
- double samples_per_visual_peak, nframes_t samples_per_file_peak) const
+AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t start, framecnt_t cnt,
+ double samples_per_visual_peak, framecnt_t samples_per_file_peak) const
{
Glib::Mutex::Lock lm (_lock);
double scale;
PeakData::PeakDatum xmin;
int32_t to_read;
uint32_t nread;
- nframes_t zero_fill = 0;
+ framecnt_t zero_fill = 0;
int ret = -1;
PeakData* staging = 0;
Sample* raw_staging = 0;
if (cnt > _length - start) {
// cerr << "too close to end @ " << _length << " given " << start << " + " << cnt << endl;
cnt = _length - start;
- nframes_t old = npeaks;
- npeaks = min ((nframes_t) floor (cnt / samples_per_visual_peak), npeaks);
+ framecnt_t old = npeaks;
+ npeaks = min ((framecnt_t) floor (cnt / samples_per_visual_peak), npeaks);
zero_fill = old - npeaks;
}
return -1;
}
- for (nframes_t i = 0; i < npeaks; ++i) {
+ for (framecnt_t i = 0; i < npeaks; ++i) {
peaks[i].max = raw_staging[i];
peaks[i].min = raw_staging[i];
}
}
- nframes_t tnp;
+ framecnt_t tnp;
if (scale < 1.0) {
to avoid confusion, I'll refer to the requested peaks as visual_peaks and the peakfile peaks as stored_peaks
*/
- const uint32_t chunksize = (uint32_t) min (expected_peaks, 65536.0);
-
+ const framecnt_t chunksize = (framecnt_t) min (expected_peaks, 65536.0);
+
staging = new PeakData[chunksize];
/* compute the rounded up frame position */
- nframes_t current_frame = start;
- nframes_t current_stored_peak = (nframes_t) ceil (current_frame / (double) samples_per_file_peak);
- uint32_t next_visual_peak = (uint32_t) ceil (current_frame / samples_per_visual_peak);
- double next_visual_peak_frame = next_visual_peak * samples_per_visual_peak;
- uint32_t stored_peak_before_next_visual_peak = (nframes_t) next_visual_peak_frame / samples_per_file_peak;
- uint32_t nvisual_peaks = 0;
- uint32_t stored_peaks_read = 0;
- uint32_t i = 0;
+ framepos_t current_frame = start;
+ framepos_t current_stored_peak = (framepos_t) ceil (current_frame / (double) samples_per_file_peak);
+ framepos_t next_visual_peak = (framepos_t) ceil (current_frame / samples_per_visual_peak);
+ double next_visual_peak_frame = next_visual_peak * samples_per_visual_peak;
+ framepos_t stored_peak_before_next_visual_peak = (framepos_t) next_visual_peak_frame / samples_per_file_peak;
+ framecnt_t nvisual_peaks = 0;
+ framecnt_t stored_peaks_read = 0;
+ framecnt_t i = 0;
/* handle the case where the initial visual peak is on a pixel boundary */
if (i == stored_peaks_read) {
uint32_t start_byte = current_stored_peak * sizeof(PeakData);
- tnp = min ((nframes_t)(_length/samples_per_file_peak - current_stored_peak), (nframes_t) expected_peaks);
+ tnp = min ((framecnt_t)(_length/samples_per_file_peak - current_stored_peak), (framecnt_t) expected_peaks);
to_read = min (chunksize, tnp);
#ifdef DEBUG_READ_PEAKS
data on the fly.
*/
- nframes_t frames_read = 0;
- nframes_t current_frame = start;
- nframes_t i = 0;
- nframes_t nvisual_peaks = 0;
- nframes_t chunksize = (nframes_t) min (cnt, (nframes_t) 4096);
+ framecnt_t frames_read = 0;
+ framepos_t current_frame = start;
+ framecnt_t i = 0;
+ framecnt_t nvisual_peaks = 0;
+ framecnt_t chunksize = (framecnt_t) min (cnt, (framecnt_t) 4096);
raw_staging = new Sample[chunksize];
- nframes_t frame_pos = start;
+ framepos_t frame_pos = start;
double pixel_pos = floor (frame_pos / samples_per_visual_peak);
double next_pixel_pos = ceil (frame_pos / samples_per_visual_peak);
double pixels_per_frame = 1.0 / samples_per_visual_peak;
if (i == frames_read) {
- to_read = min (chunksize, nframes_t(_length - current_frame));
+ to_read = min (chunksize, (framecnt_t)(_length - current_frame));
if (to_read == 0) {
/* XXX ARGH .. out by one error ... need to figure out why this happens
int
AudioSource::build_peaks_from_scratch ()
{
- nframes_t current_frame;
- nframes_t cnt;
+ framepos_t current_frame;
+ framecnt_t cnt;
Sample* buf = 0;
- nframes_t frames_read;
- nframes_t frames_to_read;
- const nframes_t bufsize = 65536; // 256kB per disk read for mono data is about ideal
+ framecnt_t frames_read;
+ framecnt_t frames_to_read;
+ const framecnt_t bufsize = 65536; // 256kB per disk read for mono data is about ideal
int ret = -1;
}
int
-AudioSource::compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt,
- bool force, bool intermediate_peaks_ready)
+AudioSource::compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
+ bool force, bool intermediate_peaks_ready)
{
return compute_and_write_peaks (buf, first_frame, cnt, force, intermediate_peaks_ready, _FPP);
}
int
-AudioSource::compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt,
- bool force, bool intermediate_peaks_ready, nframes_t fpp)
+AudioSource::compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
+ bool force, bool intermediate_peaks_ready, framecnt_t fpp)
{
Sample* buf2 = 0;
- nframes_t to_do;
+ framecnt_t to_do;
uint32_t peaks_computed;
PeakData* peakbuf = 0;
int ret = -1;
- nframes_t current_frame;
- nframes_t frames_done;
+ framepos_t current_frame;
+ framecnt_t frames_done;
const size_t blocksize = (128 * 1024);
off_t first_peak_byte;
break;
}
- nframes_t this_time = min (fpp, to_do);
+ framecnt_t this_time = min (fpp, to_do);
peakbuf[peaks_computed].max = buf[0];
peakbuf[peaks_computed].min = buf[0];
}
}
-nframes_t
+framecnt_t
AudioSource::available_peaks (double zoom_factor) const
{
if (zoom_factor < _FPP) {
using namespace ARDOUR;
using namespace PBD;
-nframes_t Crossfade::_short_xfade_length = 0;
-Change Crossfade::ActiveChanged = new_change();
-Change Crossfade::FollowOverlapChanged = new_change();
+framecnt_t Crossfade::_short_xfade_length = 0;
+PropertyChange Crossfade::ActiveChanged = new_change();
+PropertyChange Crossfade::FollowOverlapChanged = new_change();
/* XXX if and when we ever implement parallel processing of the process()
callback, these will need to be handled on a per-thread basis.
Sample* Crossfade::crossfade_buffer_in = 0;
void
-Crossfade::set_buffer_size (nframes_t sz)
+Crossfade::set_buffer_size (framecnt_t sz)
{
delete [] crossfade_buffer_out;
crossfade_buffer_out = 0;
}
Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<AudioRegion> out,
- nframes_t length,
- nframes_t position,
+ framecnt_t length,
+ framepos_t position,
AnchorPoint ap)
: AudioRegion (in->session(), position, length, in->name() + string ("<>") + out->name()),
_fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB
}
Crossfade::Crossfade (boost::shared_ptr<Crossfade> orig, boost::shared_ptr<AudioRegion> newin, boost::shared_ptr<AudioRegion> newout)
- : AudioRegion (boost::dynamic_pointer_cast<const AudioRegion> (orig)),
- _fade_in (orig->_fade_in),
- _fade_out (orig->_fade_out)
+ : AudioRegion (boost::dynamic_pointer_cast<const AudioRegion> (orig), 0, true)
+ , _fade_in (orig->_fade_in)
+ , _fade_out (orig->_fade_out)
{
_active = orig->_active;
_in_update = orig->_in_update;
layer_relation = (int32_t) (_in->layer() - _out->layer());
}
-nframes_t
-Crossfade::read_raw_internal (Sample* /*buf*/, sframes_t /*start*/, nframes_t cnt, int /*channel*/) const
+framecnt_t
+Crossfade::read_raw_internal (Sample* buf, framecnt_t start, framecnt_t cnt, int channel) const
{
- // FIXME: Why is this disabled?
-#if 0
Sample* mixdown = new Sample[cnt];
float* gain = new float[cnt];
- nframes_t ret;
-
- ret = read_at (buf, mixdown, gain, start, cnt, chan_n, cnt);
+ framecnt_t ret;
+
+ ret = read_at (buf, mixdown, gain, start, cnt, channel, cnt);
delete [] mixdown;
delete [] gain;
return ret;
-#endif
- return cnt;
}
-nframes_t
+framecnt_t
Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
- float *gain_buffer, sframes_t start, nframes_t cnt, uint32_t chan_n,
- nframes_t read_frames, nframes_t skip_frames) const
+ float *gain_buffer, framepos_t start, framecnt_t cnt, uint32_t chan_n,
+ framecnt_t read_frames, framecnt_t skip_frames) const
{
- nframes_t offset;
- nframes_t to_write;
+ frameoffset_t offset;
+ framecnt_t to_write;
if (!_active) {
return 0;
start = _position;
buf += offset;
- to_write = min (_length.val(), cnt);
+ to_write = min (_length.val(), (nframes64_t) cnt);
} else {
- to_write = min (nframes_t(_length - (start - _position)), cnt);
+ to_write = min ((_length - (start - _position)), cnt);
}
position and length, and so we know precisely how much data they could return.
*/
- for (nframes_t n = 0; n < to_write; ++n) {
+ for (framecnt_t n = 0; n < to_write; ++n) {
buf[n] = (crossfade_buffer_out[n] * fov[n]) + (crossfade_buffer_in[n] * fiv[n]);
}
}
OverlapType
-Crossfade::coverage (nframes_t start, nframes_t end) const
+Crossfade::coverage (framepos_t start, framepos_t end) const
{
- nframes_t my_end = _position + _length;
+ framepos_t my_end = _position + _length;
if ((start >= _position) && (end <= my_end)) {
return OverlapInternal;
bool
Crossfade::update ()
{
- nframes_t newlen;
+ framecnt_t newlen;
if (_follow_overlap) {
newlen = _out->first_frame() + _out->length() - _in->first_frame();
{
boost::shared_ptr<AudioRegion> top;
boost::shared_ptr<AudioRegion> bottom;
- nframes_t short_xfade_length;
+ framecnt_t short_xfade_length;
short_xfade_length = _short_xfade_length;
node->add_property ("active", (_active ? "yes" : "no"));
node->add_property ("follow-overlap", (_follow_overlap ? "yes" : "no"));
node->add_property ("fixed", (_fixed ? "yes" : "no"));
- snprintf (buf, sizeof(buf), "%" PRIu32, _length.val());
+ snprintf (buf, sizeof(buf), "%" PRId64, _length.val());
node->add_property ("length", buf);
snprintf (buf, sizeof(buf), "%" PRIu32, (uint32_t) _anchor_point);
node->add_property ("anchor-point", buf);
- snprintf (buf, sizeof(buf), "%" PRIu32, (uint32_t) _position);
+ snprintf (buf, sizeof(buf), "%" PRId64, _position.val());
node->add_property ("position", buf);
child = node->add_child ("FadeIn");
pnode = new XMLNode ("point");
- snprintf (buf, sizeof (buf), "%" PRIu32, (nframes_t) floor ((*ii)->when));
+ snprintf (buf, sizeof (buf), "%" PRId64, (framepos_t) floor ((*ii)->when));
pnode->add_property ("x", buf);
snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf);
pnode = new XMLNode ("point");
- snprintf (buf, sizeof (buf), "%" PRIu32, (nframes_t) floor ((*ii)->when));
+ snprintf (buf, sizeof (buf), "%" PRId64, (framepos_t) floor ((*ii)->when));
pnode->add_property ("x", buf);
snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf);
XMLNode* fo;
const XMLProperty* prop;
LocaleGuard lg (X_("POSIX"));
- Change what_changed = Change (0);
- nframes_t val;
+ PropertyChange what_changed = PropertyChange (0);
+ framepos_t val;
if ((prop = node.property ("position")) != 0) {
- sscanf (prop->value().c_str(), "%" PRIu32, &val);
+ sscanf (prop->value().c_str(), "%" PRId64, &val);
if (val != _position) {
_position = val;
- what_changed = Change (what_changed | PositionChanged);
+ what_changed = PropertyChange (what_changed | PositionChanged);
}
} else {
warning << _("old-style crossfade information - no position information") << endmsg;
bool x = string_is_affirmative (prop->value());
if (x != _active) {
_active = x;
- what_changed = Change (what_changed | ActiveChanged);
+ what_changed = PropertyChange (what_changed | ActiveChanged);
}
} else {
_active = true;
if ((prop = node.property ("length")) != 0) {
- sscanf (prop->value().c_str(), "%" PRIu32, &val);
+ sscanf (prop->value().c_str(), "%" PRId64, &val);
if (val != _length) {
- _length = atol (prop->value().c_str());
- what_changed = Change (what_changed | LengthChanged);
+ _length = val;
+ what_changed = PropertyChange (what_changed | LengthChanged);
}
} else {
for (i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == "point") {
- nframes_t x;
+ framepos_t x;
float y;
prop = (*i)->property ("x");
- sscanf (prop->value().c_str(), "%" PRIu32, &x);
+ sscanf (prop->value().c_str(), "%" PRId64, &x);
prop = (*i)->property ("y");
sscanf (prop->value().c_str(), "%f", &y);
for (i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == "point") {
- nframes_t x;
+ framepos_t x;
float y;
XMLProperty* prop;
prop = (*i)->property ("x");
- sscanf (prop->value().c_str(), "%" PRIu32, &x);
+ sscanf (prop->value().c_str(), "%" PRId64, &x);
prop = (*i)->property ("y");
sscanf (prop->value().c_str(), "%f", &y);
StateChanged (FollowOverlapChanged);
}
-nframes_t
-Crossfade::set_xfade_length (nframes_t len)
+framecnt_t
+Crossfade::set_xfade_length (framecnt_t len)
{
- nframes_t limit = 0;
+ framecnt_t limit = 0;
switch (_anchor_point) {
case StartOfIn:
return len;
}
-nframes_t
+framecnt_t
Crossfade::overlap_length () const
{
if (_fixed) {
}
void
-Crossfade::set_short_xfade_length (nframes_t n)
+Crossfade::set_short_xfade_length (framecnt_t n)
{
_short_xfade_length = n;
}
bits |= ARDOUR::DEBUG::MidiIO;
} else if (strncasecmp (p, "midiclock", strlen (p)) == 0) {
bits |= ARDOUR::DEBUG::MidiClock;
+ } else if (strncasecmp (p, "properties", strlen (p)) == 0) {
+ bits |= ARDOUR::DEBUG::Properties;
}
p = strtok_r (0, ",", &sp);
cerr << "\tMidiIO" << endl;
cerr << "\tLatencyCompensation" << endl;
cerr << "\tMidiClock" << endl;
+ cerr << "\tProperties" << endl;
}
}
void
-Diskstream::playlist_changed (Change)
+Diskstream::playlist_changed (PropertyChange)
{
playlist_modified ();
}
}
void
-Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<nframes_t> > const & movements_frames)
+Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const & movements_frames)
{
if (!_route || Config->get_automation_follows_regions () == false) {
return;
list< Evoral::RangeMove<double> > movements;
- for (list< Evoral::RangeMove<nframes_t> >::const_iterator i = movements_frames.begin();
+ for (list< Evoral::RangeMove<framepos_t> >::const_iterator i = movements_frames.begin();
i != movements_frames.end();
++i) {
}
void
-Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evoral::RangeMove<nframes_t> > const & movements_frames)
+Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evoral::RangeMove<framepos_t> > const & movements_frames)
{
boost::shared_ptr<Processor> processor (p.lock ());
if (!processor) {
}
list< Evoral::RangeMove<double> > movements;
- for (list< Evoral::RangeMove<nframes_t> >::const_iterator i = movements_frames.begin();
+ for (list< Evoral::RangeMove<framepos_t> >::const_iterator i = movements_frames.begin();
i != movements_frames.end(); ++i) {
movements.push_back(Evoral::RangeMove<double>(i->from, i->length, i->to));
}
#include "ardour/midi_track.h"
#include "ardour/mute_master.h"
#include "ardour/panner.h"
-#include "ardour/region_command.h"
#include "ardour/route_group.h"
#include "ardour/session.h"
#include "ardour/track.h"
Source::Flag _Source_Flag;
Diskstream::Flag _Diskstream_Flag;
Location::Flags _Location_Flags;
- RouteGroup::Flag _RouteGroup_Flag;
- RouteGroup::Property _RouteGroup_Property;
- Region::Flag _Region_Flag;
Region::PositionLockStyle _Region_PositionLockStyle;
Track::FreezeState _Track_FreezeState;
AutomationList::InterpolationStyle _AutomationList_InterpolationStyle;
Session::PostTransportWork _Session_PostTransportWork;
Session::SlaveState _Session_SlaveState;
MTC_Status _MIDI_MTC_Status;
- RegionCommand::Property _RegionCommandProperty;
#define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
REGISTER_CLASS_ENUM (Location, IsStart);
REGISTER_BITS (_Location_Flags);
- REGISTER_CLASS_ENUM (RouteGroup, Relative);
- REGISTER_CLASS_ENUM (RouteGroup, Active);
- REGISTER_CLASS_ENUM (RouteGroup, Hidden);
- REGISTER_BITS (_RouteGroup_Flag);
-
- REGISTER_CLASS_ENUM (RouteGroup, Gain);
- REGISTER_CLASS_ENUM (RouteGroup, Mute);
- REGISTER_CLASS_ENUM (RouteGroup, Solo);
- REGISTER_CLASS_ENUM (RouteGroup, RecEnable);
- REGISTER_CLASS_ENUM (RouteGroup, Select);
- REGISTER_CLASS_ENUM (RouteGroup, Edit);
- REGISTER_BITS (_RouteGroup_Property);
-
REGISTER_CLASS_ENUM (Panner, SameDirection);
REGISTER_CLASS_ENUM (Panner, OppositeDirection);
REGISTER (_Panner_LinkDirection);
- REGISTER_CLASS_ENUM (Region, Muted);
- REGISTER_CLASS_ENUM (Region, Opaque);
- REGISTER_CLASS_ENUM (Region, EnvelopeActive);
- REGISTER_CLASS_ENUM (Region, DefaultFadeIn);
- REGISTER_CLASS_ENUM (Region, DefaultFadeOut);
- REGISTER_CLASS_ENUM (Region, Locked);
- REGISTER_CLASS_ENUM (Region, PositionLocked);
- REGISTER_CLASS_ENUM (Region, Automatic);
- REGISTER_CLASS_ENUM (Region, WholeFile);
- REGISTER_CLASS_ENUM (Region, FadeIn);
- REGISTER_CLASS_ENUM (Region, FadeOut);
- REGISTER_CLASS_ENUM (Region, Copied);
- REGISTER_CLASS_ENUM (Region, Import);
- REGISTER_CLASS_ENUM (Region, External);
- REGISTER_CLASS_ENUM (Region, SyncMarked);
- REGISTER_CLASS_ENUM (Region, LeftOfSplit);
- REGISTER_CLASS_ENUM (Region, RightOfSplit);
- REGISTER_CLASS_ENUM (Region, Hidden);
- REGISTER_CLASS_ENUM (Region, DoNotSendPropertyChanges);
- REGISTER_BITS (_Region_Flag);
-
REGISTER_CLASS_ENUM (Region, AudioTime);
REGISTER_CLASS_ENUM (Region, MusicTime);
REGISTER_BITS (_Region_PositionLockStyle);
REGISTER_ENUM(Legato);
REGISTER_ENUM(Groove);
REGISTER(_QuantizeType);
-
- REGISTER_CLASS_ENUM (RegionCommand, Name);
- REGISTER_CLASS_ENUM (RegionCommand, PositionLockStyle);
- REGISTER_CLASS_ENUM (RegionCommand, Length);
- REGISTER_CLASS_ENUM (RegionCommand, Start);
- REGISTER_CLASS_ENUM (RegionCommand, Position);
- REGISTER_CLASS_ENUM (RegionCommand, PositionOnTop);
- REGISTER_CLASS_ENUM (RegionCommand, Layer);
- REGISTER_CLASS_ENUM (RegionCommand, SyncPosition);
- REGISTER_CLASS_ENUM (RegionCommand, Hidden);
- REGISTER_CLASS_ENUM (RegionCommand, Muted);
- REGISTER_CLASS_ENUM (RegionCommand, Opaque);
- REGISTER_CLASS_ENUM (RegionCommand, Locked);
- REGISTER_CLASS_ENUM (RegionCommand, PositionLocked);
- REGISTER_CLASS_ENUM (RegionCommand, ScaleAmplitude);
- REGISTER_CLASS_ENUM (RegionCommand, FadeInActive);
- REGISTER_CLASS_ENUM (RegionCommand, FadeInShape);
- REGISTER_CLASS_ENUM (RegionCommand, FadeInLength);
- REGISTER_CLASS_ENUM (RegionCommand, FadeIn);
- REGISTER_CLASS_ENUM (RegionCommand, FadeOutActive);
- REGISTER_CLASS_ENUM (RegionCommand, FadeOutShape);
- REGISTER_CLASS_ENUM (RegionCommand, FadeOutLength);
- REGISTER_CLASS_ENUM (RegionCommand, FadeOut);
- REGISTER_CLASS_ENUM (RegionCommand, EnvelopActive);
- REGISTER_CLASS_ENUM (RegionCommand, DefaultEnvelope);
- REGISTER(_RegionCommandProperty);
}
} /* namespace ARDOUR */
}
results.clear ();
- boost::shared_ptr<Region> r = RegionFactory::create (nsrcs, 0, region->length(), region_name, 0,
- Region::Flag (Region::WholeFile|Region::DefaultFlags));
- r->set_position (region->position(), 0);
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, region->length());
+ plist.add (Properties::name, region_name);
+ plist.add (Properties::whole_file, true);
+ plist.add (Properties::position, region->position());
+
+ boost::shared_ptr<Region> r = RegionFactory::create (nsrcs, plist);
boost::shared_ptr<AudioRegion> audio_region = boost::dynamic_pointer_cast<AudioRegion> (region);
boost::shared_ptr<AudioRegion> audio_r = boost::dynamic_pointer_cast<AudioRegion> (r);
#include "ardour/ardour.h"
#include "ardour/audio_library.h"
#include "ardour/audioengine.h"
+#include "ardour/audioregion.h"
#include "ardour/audiosource.h"
#include "ardour/control_protocol_manager.h"
#include "ardour/debug.h"
#include "ardour/mix.h"
#include "ardour/plugin_manager.h"
#include "ardour/profile.h"
+#include "ardour/region.h"
#include "ardour/rc_configuration.h"
+#include "ardour/route_group.h"
#include "ardour/runtime_functions.h"
#include "ardour/session.h"
#include "ardour/session_event.h"
MIDI::Port *ARDOUR::default_midi_port = 0;
MIDI::Port *ARDOUR::default_midi_clock_port = 0;
-PBD::Change ARDOUR::StartChanged = PBD::new_change ();
-PBD::Change ARDOUR::LengthChanged = PBD::new_change ();
-PBD::Change ARDOUR::PositionChanged = PBD::new_change ();
-PBD::Change ARDOUR::NameChanged = PBD::new_change ();
-PBD::Change ARDOUR::BoundsChanged = Change (0); // see init(), below
-PBD::Change ARDOUR::FlagsChanged = PBD::new_change ();
+PropertyChange ARDOUR::StartChanged = PBD::new_change ();
+PropertyChange ARDOUR::LengthChanged = PBD::new_change ();
+PropertyChange ARDOUR::PositionChanged = PBD::new_change ();
+PropertyChange ARDOUR::NameChanged = PBD::new_change ();
+PropertyChange ARDOUR::BoundsChanged = PropertyChange (0); // see init(), below
compute_peak_t ARDOUR::compute_peak = 0;
find_peaks_t ARDOUR::find_peaks = 0;
PBD::ID::init ();
SessionEvent::init_event_pool ();
+ SessionObject::make_property_quarks ();
+ Region::make_property_quarks ();
+ AudioRegion::make_property_quarks ();
+ RouteGroup::make_property_quarks ();
/* provide a state version for the few cases that need it and are not
driven by reading state from disk (e.g. undo/redo)
/* singleton - first object is "it" */
new PluginManager ();
- BoundsChanged = Change (StartChanged|PositionChanged|LengthChanged);
+ BoundsChanged = PropertyChange (StartChanged|PositionChanged|LengthChanged);
return 0;
}
o << trace_prefix
<< "Channel "
<< (msg[0]&0xF)+1
- << " Program Change ProgNum "
+ << " Program PropertyChange ProgNum "
<< (int) msg[1]
<< endl;
break;
*/
try {
- boost::shared_ptr<Region> rx (RegionFactory::create (srcs, 0,
- total_capture, whole_file_region_name, 0,
- Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
+ PropertyList plist;
+
+ plist.add (Properties::name, whole_file_region_name);
+ plist.add (Properties::whole_file, true);
+ plist.add (Properties::automatic, true);
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, total_capture);
+ plist.add (Properties::layer, 0);
+
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
region = boost::dynamic_pointer_cast<MidiRegion> (rx);
region->special_set_position (capture_info.front()->start);
// cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add a region\n";
try {
- boost::shared_ptr<Region> rx (RegionFactory::create (srcs, buffer_position, (*ci)->frames, region_name));
+ PropertyList plist;
+
+ plist.add (Properties::start, buffer_position);
+ plist.add (Properties::length, (*ci)->frames);
+ plist.add (Properties::name, region_name);
+
+ boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
region = boost::dynamic_pointer_cast<MidiRegion> (rx);
}
bool
-MidiPlaylist::region_changed (PBD::Change what_changed, boost::shared_ptr<Region> region)
+MidiPlaylist::region_changed (PBD::PropertyChange what_changed, boost::shared_ptr<Region> region)
{
if (in_flush || in_set_state) {
return false;
// Feeling rather uninterested today, but thanks for the heads up anyway!
- PBD::Change our_interests = PBD::Change (/*MidiRegion::FadeInChanged|
+ PBD::PropertyChange our_interests = PBD::PropertyChange (/*MidiRegion::FadeInChanged|
MidiRegion::FadeOutChanged|
MidiRegion::FadeInActiveChanged|
MidiRegion::FadeOutActiveChanged|
using namespace PBD;
/** Basic MidiRegion constructor (one channel) */
-MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nframes_t length)
- : Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::MIDI, 0, Region::Flag(Region::DefaultFlags|Region::External))
-{
- assert(_name.val().find("/") == string::npos);
- midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
-}
-
-/* Basic MidiRegion constructor (one channel) */
-MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (src, start, length, name, DataType::MIDI, layer, flags)
+MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src)
+ : Region (src)
{
assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
/* Basic MidiRegion constructor (many channels) */
-MidiRegion::MidiRegion (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (srcs, start, length, name, DataType::MIDI, layer, flags)
+MidiRegion::MidiRegion (const SourceList& srcs)
+ : Region (srcs)
{
assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
/** Create a new MidiRegion, that is part of an existing one */
-MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
- : Region (other, offset, length, name, layer, flags)
-{
- assert(_name.val().find("/") == string::npos);
- midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
-}
-
-MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
- : Region (other)
+MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset, bool offset_relative)
+ : Region (other, offset, offset_relative)
{
assert(_name.val().find("/") == string::npos);
midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1));
}
void
-MidiRegion::set_position_internal (nframes_t pos, bool allow_bbt_recompute)
+MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
{
BeatsFramesConverter old_converter(_session.tempo_map(), _position - _start);
double length_beats = old_converter.from(_length);
set_length(new_converter.to(length_beats), 0);
}
-nframes_t
-MidiRegion::read_at (Evoral::EventSink<nframes_t>& out, sframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode, MidiStateTracker* tracker) const
+framecnt_t
+MidiRegion::read_at (Evoral::EventSink<nframes_t>& out, framepos_t position, framecnt_t dur, uint32_t chan_n, NoteMode mode, MidiStateTracker* tracker) const
{
return _read_at (_sources, out, position, dur, chan_n, mode, tracker);
}
-nframes_t
-MidiRegion::master_read_at (MidiRingBuffer<nframes_t>& out, sframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const
+framecnt_t
+MidiRegion::master_read_at (MidiRingBuffer<nframes_t>& out, framepos_t position, framecnt_t dur, uint32_t chan_n, NoteMode mode) const
{
return _read_at (_master_sources, out, position, dur, chan_n, mode); /* no tracker */
}
-nframes_t
-MidiRegion::_read_at (const SourceList& /*srcs*/, Evoral::EventSink<nframes_t>& dst, sframes_t position, nframes_t dur, uint32_t chan_n,
+framecnt_t
+MidiRegion::_read_at (const SourceList& /*srcs*/, Evoral::EventSink<nframes_t>& dst, framepos_t position, framecnt_t dur, uint32_t chan_n,
NoteMode mode, MidiStateTracker* tracker) const
{
- nframes_t internal_offset = 0;
- nframes_t src_offset = 0;
- nframes_t to_read = 0;
+ frameoffset_t internal_offset = 0;
+ frameoffset_t src_offset = 0;
+ framecnt_t to_read = 0;
/* precondition: caller has verified that we cover the desired section */
boost::shared_ptr<MidiSource> src = midi_source(chan_n);
src->set_note_mode(mode);
- nframes_t output_buffer_position = 0;
- nframes_t negative_output_buffer_position = 0;
+ framepos_t output_buffer_position = 0;
+ framepos_t negative_output_buffer_position = 0;
if (_position >= _start) {
// handle resizing of beginnings of regions correctly
output_buffer_position = _position - _start;
return node;
}
-int
-MidiRegion::set_live_state (const XMLNode& node, int version, Change& what_changed, bool send)
-{
- const XMLProperty *prop;
- LocaleGuard lg (X_("POSIX"));
-
- Region::set_live_state (node, version, what_changed, false);
-
- uint32_t old_flags = _flags;
-
- if ((prop = node.property ("flags")) != 0) {
- _flags = Flag (string_2_enum (prop->value(), _flags));
-
- //_flags = Flag (strtol (prop->value().c_str(), (char **) 0, 16));
-
- _flags = Flag (_flags & ~Region::LeftOfSplit);
- _flags = Flag (_flags & ~Region::RightOfSplit);
- }
-
- if ((old_flags ^ _flags) & Muted) {
- what_changed = Change (what_changed|MuteChanged);
- }
- if ((old_flags ^ _flags) & Opaque) {
- what_changed = Change (what_changed|OpacityChanged);
- }
- if ((old_flags ^ _flags) & Locked) {
- what_changed = Change (what_changed|LockChanged);
- }
-
- if (send) {
- send_change (what_changed);
- }
-
- return 0;
-}
-
int
MidiRegion::set_state (const XMLNode& node, int version)
{
- /* Region::set_state() calls the virtual set_live_state(),
- which will get us back to AudioRegion::set_live_state()
- to handle the relevant stuff.
- */
-
return Region::set_state (node, version);
}
freeze_length = other->freeze_length;
}
-Playlist::Playlist (boost::shared_ptr<const Playlist> other, nframes_t start, nframes_t cnt, string str, bool hide)
+Playlist::Playlist (boost::shared_ptr<const Playlist> other, framepos_t start, framecnt_t cnt, string str, bool hide)
: SessionObject(other->_session, str)
, _type(other->_type)
, _orig_diskstream_id(other->_orig_diskstream_id)
{
RegionLock rlock2 (const_cast<Playlist*> (other.get()));
- nframes_t end = start + cnt - 1;
+ framepos_t end = start + cnt - 1;
init (hide);
boost::shared_ptr<Region> region;
boost::shared_ptr<Region> new_region;
- nframes_t offset = 0;
- nframes_t position = 0;
- nframes_t len = 0;
+ frameoffset_t offset = 0;
+ framepos_t position = 0;
+ framecnt_t len = 0;
string new_name;
OverlapType overlap;
_session.region_name (new_name, region->name(), false);
- new_region = RegionFactory::RegionFactory::create (region, offset, len, new_name, region->layer(), region->flags());
+ PropertyList plist;
+
+ plist.add (Properties::start, offset);
+ plist.add (Properties::length, len);
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, region->layer());
+
+ new_region = RegionFactory::RegionFactory::create (region, plist);
add_region_internal (new_region, position);
}
void
Playlist::notify_region_moved (boost::shared_ptr<Region> r)
{
- Evoral::RangeMove<nframes_t> const move (r->last_position (), r->length (), r->position ());
+ Evoral::RangeMove<framepos_t> const move (r->last_position (), r->length (), r->position ());
if (holding_state ()) {
} else {
- list< Evoral::RangeMove<nframes_t> > m;
+ list< Evoral::RangeMove<framepos_t> > m;
m.push_back (move);
RangesMoved (m);
}
set<boost::shared_ptr<Region> >::iterator s;
uint32_t regions_changed = false;
bool check_length = false;
- nframes64_t old_length = 0;
+ framecnt_t old_length = 0;
if (in_flush) {
return;
*************************************************************/
void
-Playlist::add_region (boost::shared_ptr<Region> region, nframes_t position, float times, bool auto_partition)
+Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition)
{
RegionLock rlock (this);
times = fabs (times);
int itimes = (int) floor (times);
- nframes_t pos = position;
+ framepos_t pos = position;
if (times == 1 && auto_partition){
- partition(pos, (nframes_t) (pos + region->length()), true);
+ partition(pos, (pos + region->length()), true);
}
if (itimes >= 1) {
pos += region->length();
}
- nframes_t length = 0;
+ framecnt_t length = 0;
if (floor (times) != times) {
- length = (nframes_t) floor (region->length() * (times - floor (times)));
+ length = (framecnt_t) floor (region->length() * (times - floor (times)));
string name;
_session.region_name (name, region->name(), false);
- boost::shared_ptr<Region> sub = RegionFactory::create (region, 0, length, name, region->layer(), region->flags());
- add_region_internal (sub, pos);
+
+ {
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, length);
+ plist.add (Properties::name, name);
+ plist.add (Properties::layer, region->layer());
+
+ boost::shared_ptr<Region> sub = RegionFactory::create (region, plist);
+ add_region_internal (sub, pos);
+ }
}
possibly_splice_unlocked (position, (pos + length) - position, boost::shared_ptr<Region>());
}
bool
-Playlist::add_region_internal (boost::shared_ptr<Region> region, nframes_t position)
+Playlist::add_region_internal (boost::shared_ptr<Region> region, framepos_t position)
{
if (region->data_type() != _type){
return false;
RegionSortByPosition cmp;
- nframes_t old_length = 0;
+ framecnt_t old_length = 0;
if (!holding_state()) {
old_length = _get_maximum_extent();
}
void
-Playlist::replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, nframes_t pos)
+Playlist::replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, framepos_t pos)
{
RegionLock rlock (this);
_splicing = old_sp;
- possibly_splice_unlocked (pos, (nframes64_t) old->length() - (nframes64_t) newr->length());
+ possibly_splice_unlocked (pos, old->length() - newr->length());
}
void
Playlist::remove_region_internal (boost::shared_ptr<Region> region)
{
RegionList::iterator i;
- nframes_t old_length = 0;
+ framecnt_t old_length = 0;
int ret = -1;
if (!holding_state()) {
for (i = regions.begin(); i != regions.end(); ++i) {
if (*i == region) {
- nframes_t pos = (*i)->position();
- nframes64_t distance = (*i)->length();
+ framepos_t pos = (*i)->position();
+ framecnt_t distance = (*i)->length();
regions.erase (i);
}
void
-Playlist::partition (nframes_t start, nframes_t end, bool cut)
+Playlist::partition (framepos_t start, framepos_t end, bool cut)
{
RegionList thawlist;
}
void
-Playlist::partition_internal (nframes_t start, nframes_t end, bool cutting, RegionList& thawlist)
+Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist)
{
RegionList new_regions;
string new_name;
RegionList::iterator tmp;
OverlapType overlap;
- nframes_t pos1, pos2, pos3, pos4;
+ framepos_t pos1, pos2, pos3, pos4;
in_partition = true;
/* "middle" ++++++ */
_session.region_name (new_name, current->name(), false);
- region = RegionFactory::create (current, pos2 - pos1, pos3 - pos2, new_name,
- regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::LeftOfSplit|Region::RightOfSplit));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, pos2 - pos1);
+ plist.add (Properties::length, pos3 - pos2);
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, regions.size());
+ plist.add (Properties::automatic, true);
+ plist.add (Properties::left_of_split, true);
+ plist.add (Properties::right_of_split, true);
+
+ region = RegionFactory::create (current, plist);
add_region_internal (region, start);
new_regions.push_back (region);
}
/* "end" ====== */
_session.region_name (new_name, current->name(), false);
- region = RegionFactory::create (current, pos3 - pos1, pos4 - pos3, new_name,
- regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::RightOfSplit));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, pos3 - pos1);
+ plist.add (Properties::length, pos4 - pos3);
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, regions.size());
+ plist.add (Properties::automatic, true);
+ plist.add (Properties::right_of_split, true);
+
+ region = RegionFactory::create (current, plist);
add_region_internal (region, end);
new_regions.push_back (region);
/* end +++++ */
_session.region_name (new_name, current->name(), false);
- region = RegionFactory::create (current, pos2 - pos1, pos4 - pos2, new_name, (layer_t) regions.size(),
- Region::Flag(current->flags()|Region::Automatic|Region::LeftOfSplit));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, pos2 - pos1);
+ plist.add (Properties::length, pos4 - pos2);
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, regions.size());
+ plist.add (Properties::automatic, true);
+ plist.add (Properties::left_of_split, true);
+
+ region = RegionFactory::create (current, plist);
add_region_internal (region, start);
new_regions.push_back (region);
if (!cutting) {
/* front **** */
_session.region_name (new_name, current->name(), false);
- region = RegionFactory::create (current, 0, pos3 - pos1, new_name,
- regions.size(), Region::Flag(current->flags()|Region::Automatic|Region::RightOfSplit));
+
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, pos3 - pos1);
+ plist.add (Properties::name, new_name);
+ plist.add (Properties::layer, regions.size());
+ plist.add (Properties::automatic, true);
+ plist.add (Properties::right_of_split, true);
+
+ region = RegionFactory::create (current, plist);
add_region_internal (region, pos1);
new_regions.push_back (region);
}
boost::shared_ptr<Playlist>
-Playlist::cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(nframes_t, nframes_t,bool), list<AudioRange>& ranges, bool result_is_hidden)
+Playlist::cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t, framecnt_t,bool), list<AudioRange>& ranges, bool result_is_hidden)
{
boost::shared_ptr<Playlist> ret;
boost::shared_ptr<Playlist> pl;
- nframes_t start;
+ framepos_t start;
if (ranges.empty()) {
return boost::shared_ptr<Playlist>();
boost::shared_ptr<Playlist>
Playlist::cut (list<AudioRange>& ranges, bool result_is_hidden)
{
- boost::shared_ptr<Playlist> (Playlist::*pmf)(nframes_t,nframes_t,bool) = &Playlist::cut;
+ boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t,framecnt_t,bool) = &Playlist::cut;
return cut_copy (pmf, ranges, result_is_hidden);
}
boost::shared_ptr<Playlist>
Playlist::copy (list<AudioRange>& ranges, bool result_is_hidden)
{
- boost::shared_ptr<Playlist> (Playlist::*pmf)(nframes_t,nframes_t,bool) = &Playlist::copy;
+ boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t,framecnt_t,bool) = &Playlist::copy;
return cut_copy (pmf, ranges, result_is_hidden);
}
boost::shared_ptr<Playlist>
-Playlist::cut (nframes_t start, nframes_t cnt, bool result_is_hidden)
+Playlist::cut (framepos_t start, framecnt_t cnt, bool result_is_hidden)
{
boost::shared_ptr<Playlist> the_copy;
RegionList thawlist;
}
boost::shared_ptr<Playlist>
-Playlist::copy (nframes_t start, nframes_t cnt, bool result_is_hidden)
+Playlist::copy (framepos_t start, framecnt_t cnt, bool result_is_hidden)
{
char buf[32];
}
int
-Playlist::paste (boost::shared_ptr<Playlist> other, nframes_t position, float times)
+Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times)
{
times = fabs (times);
- nframes_t old_length;
+ framecnt_t old_length;
{
RegionLock rl1 (this);
old_length = _get_maximum_extent();
int itimes = (int) floor (times);
- nframes_t pos = position;
- nframes_t shift = other->_get_maximum_extent();
+ framepos_t pos = position;
+ framecnt_t shift = other->_get_maximum_extent();
layer_t top_layer = regions.size();
while (itimes--) {
void
-Playlist::duplicate (boost::shared_ptr<Region> region, nframes_t position, float times)
+Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, float times)
{
times = fabs (times);
RegionLock rl (this);
int itimes = (int) floor (times);
- nframes_t pos = position;
+ framepos_t pos = position;
while (itimes--) {
boost::shared_ptr<Region> copy = RegionFactory::create (region);
}
if (floor (times) != times) {
- nframes_t length = (nframes_t) floor (region->length() * (times - floor (times)));
+ framecnt_t length = (framecnt_t) floor (region->length() * (times - floor (times)));
string name;
_session.region_name (name, region->name(), false);
- boost::shared_ptr<Region> sub = RegionFactory::create (region, 0, length, name, region->layer(), region->flags());
- add_region_internal (sub, pos);
+
+ {
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, length);
+ plist.add (Properties::name, name);
+
+ boost::shared_ptr<Region> sub = RegionFactory::create (region, plist);
+ add_region_internal (sub, pos);
+ }
}
}
void
-Playlist::shift (nframes64_t at, nframes64_t distance, bool move_intersected, bool ignore_music_glue)
+Playlist::shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue)
{
RegionLock rlock (this);
RegionList copy (regions);
}
void
-Playlist::split (nframes64_t at)
+Playlist::split (framepos_t at)
{
RegionLock rlock (this);
RegionList copy (regions);
}
void
-Playlist::split_region (boost::shared_ptr<Region> region, nframes_t playlist_position)
+Playlist::split_region (boost::shared_ptr<Region> region, framepos_t playlist_position)
{
RegionLock rl (this);
_split_region (region, playlist_position);
}
void
-Playlist::_split_region (boost::shared_ptr<Region> region, nframes_t playlist_position)
+Playlist::_split_region (boost::shared_ptr<Region> region, framepos_t playlist_position)
{
if (!region->covers (playlist_position)) {
return;
boost::shared_ptr<Region> left;
boost::shared_ptr<Region> right;
- nframes_t before;
- nframes_t after;
+ frameoffset_t before;
+ frameoffset_t after;
string before_name;
string after_name;
after = region->length() - before;
_session.region_name (before_name, region->name(), false);
- left = RegionFactory::create (region, 0, before, before_name, region->layer(), Region::Flag (region->flags()|Region::LeftOfSplit));
+
+ {
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, before);
+ plist.add (Properties::name, before_name);
+ plist.add (Properties::left_of_split, true);
+
+ left = RegionFactory::create (region, plist);
+ }
_session.region_name (after_name, region->name(), false);
- right = RegionFactory::create (region, before, after, after_name, region->layer(), Region::Flag (region->flags()|Region::RightOfSplit));
+
+ {
+ PropertyList plist;
+
+ plist.add (Properties::start, before);
+ plist.add (Properties::length, after);
+ plist.add (Properties::name, after_name);
+ plist.add (Properties::right_of_split, true);
+
+ right = RegionFactory::create (region, plist);
+ }
add_region_internal (left, region->position());
add_region_internal (right, region->position() + before);
}
void
-Playlist::possibly_splice (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude)
+Playlist::possibly_splice (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude)
{
if (_splicing || in_set_state) {
/* don't respond to splicing moves or state setting */
}
void
-Playlist::possibly_splice_unlocked (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude)
+Playlist::possibly_splice_unlocked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude)
{
if (_splicing || in_set_state) {
/* don't respond to splicing moves or state setting */
}
void
-Playlist::splice_locked (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude)
+Playlist::splice_locked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude)
{
{
RegionLock rl (this);
}
void
-Playlist::splice_unlocked (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude)
+Playlist::splice_unlocked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude)
{
core_splice (at, distance, exclude);
}
void
-Playlist::core_splice (nframes_t at, nframes64_t distance, boost::shared_ptr<Region> exclude)
+Playlist::core_splice (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude)
{
_splicing = true;
}
if ((*i)->position() >= at) {
- nframes64_t new_pos = (*i)->position() + distance;
+ framepos_t new_pos = (*i)->position() + distance;
if (new_pos < 0) {
new_pos = 0;
} else if (new_pos >= max_frames - (*i)->length()) {
}
void
-Playlist::region_bounds_changed (Change what_changed, boost::shared_ptr<Region> region)
+Playlist::region_bounds_changed (PropertyChange what_changed, boost::shared_ptr<Region> region)
{
if (in_set_state || _splicing || _nudging || _shuffling) {
return;
regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
}
- if (what_changed & Change (ARDOUR::PositionChanged|ARDOUR::LengthChanged)) {
+ if (what_changed & PropertyChange (ARDOUR::PositionChanged|ARDOUR::LengthChanged)) {
- nframes64_t delta = 0;
+ frameoffset_t delta = 0;
if (what_changed & ARDOUR::PositionChanged) {
- delta = (nframes64_t) region->position() - (nframes64_t) region->last_position();
+ delta = region->position() - region->last_position();
}
if (what_changed & ARDOUR::LengthChanged) {
- delta += (nframes64_t) region->length() - (nframes64_t) region->last_length();
+ delta += region->length() - region->last_length();
}
if (delta) {
}
void
-Playlist::region_changed_proxy (Change what_changed, boost::weak_ptr<Region> weak_region)
+Playlist::region_changed_proxy (PropertyChange what_changed, boost::weak_ptr<Region> weak_region)
{
boost::shared_ptr<Region> region (weak_region.lock());
}
bool
-Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
+Playlist::region_changed (PropertyChange what_changed, boost::shared_ptr<Region> region)
{
- Change our_interests = Change (Region::MuteChanged|Region::LayerChanged|Region::OpacityChanged);
+ PropertyChange our_interests = PropertyChange (Region::MuteChanged|Region::LayerChanged|Region::OpacityChanged);
bool save = false;
if (in_set_state || in_flush) {
}
if ((what_changed & our_interests) &&
- !(what_changed & Change (ARDOUR::PositionChanged|ARDOUR::LengthChanged))) {
+ !(what_changed & PropertyChange (ARDOUR::PositionChanged|ARDOUR::LengthChanged))) {
check_dependents (region, false);
}
- if (what_changed & Change (ARDOUR::PositionChanged)) {
+ if (what_changed & PropertyChange (ARDOUR::PositionChanged)) {
notify_region_moved (region);
}
**********************************************************************/
Playlist::RegionList *
-Playlist::regions_at (nframes_t frame)
+Playlist::regions_at (framepos_t frame)
{
RegionLock rlock (this);
}
boost::shared_ptr<Region>
-Playlist::top_region_at (nframes_t frame)
+Playlist::top_region_at (framepos_t frame)
{
RegionLock rlock (this);
}
boost::shared_ptr<Region>
-Playlist::top_unmuted_region_at (nframes_t frame)
+Playlist::top_unmuted_region_at (framepos_t frame)
{
RegionLock rlock (this);
}
Playlist::RegionList*
-Playlist::regions_to_read (nframes_t start, nframes_t end)
+Playlist::regions_to_read (framepos_t start, framepos_t end)
{
/* Caller must hold lock */
RegionList covering;
- set<nframes_t> to_check;
+ set<framepos_t> to_check;
set<boost::shared_ptr<Region> > unique;
RegionList here;
} else {
- for (set<nframes_t>::iterator t = to_check.begin(); t != to_check.end(); ++t) {
+ for (set<framepos_t>::iterator t = to_check.begin(); t != to_check.end(); ++t) {
here.clear ();
}
Playlist::RegionList *
-Playlist::find_regions_at (nframes_t frame)
+Playlist::find_regions_at (framepos_t frame)
{
/* Caller must hold lock */
}
Playlist::RegionList *
-Playlist::regions_touched (nframes_t start, nframes_t end)
+Playlist::regions_touched (framepos_t start, framepos_t end)
{
RegionLock rlock (this);
RegionList *rlist = new RegionList;
return rlist;
}
-nframes64_t
-Playlist::find_next_transient (nframes64_t from, int dir)
+framepos_t
+Playlist::find_next_transient (framepos_t from, int dir)
{
RegionLock rlock (this);
AnalysisFeatureList points;
}
boost::shared_ptr<Region>
-Playlist::find_next_region (nframes_t frame, RegionPoint point, int dir)
+Playlist::find_next_region (framepos_t frame, RegionPoint point, int dir)
{
RegionLock rlock (this);
boost::shared_ptr<Region> ret;
- nframes_t closest = max_frames;
+ framepos_t closest = max_frames;
bool end_iter = false;
if(end_iter) break;
- nframes_t distance;
+ frameoffset_t distance;
boost::shared_ptr<Region> r = (*i);
- nframes_t pos = 0;
+ framepos_t pos = 0;
switch (point) {
case Start:
return ret;
}
-nframes64_t
-Playlist::find_next_region_boundary (nframes64_t frame, int dir)
+framepos_t
+Playlist::find_next_region_boundary (framepos_t frame, int dir)
{
RegionLock rlock (this);
- nframes64_t closest = max_frames;
- nframes64_t ret = -1;
+ framepos_t closest = max_frames;
+ framepos_t ret = -1;
if (dir > 0) {
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
boost::shared_ptr<Region> r = (*i);
- nframes64_t distance;
+ frameoffset_t distance;
if (r->first_frame() > frame) {
for (RegionList::reverse_iterator i = regions.rbegin(); i != regions.rend(); ++i) {
boost::shared_ptr<Region> r = (*i);
- nframes64_t distance;
+ frameoffset_t distance;
if (r->last_frame() < frame) {
if ((region = region_by_id (id))) {
- Change what_changed = Change (0);
-
region->freeze ();
- if (region->set_live_state (*child, version, what_changed, false)) {
+ if (region->set_state (*child, version)) {
region->thaw ();
continue;
}
-
+
} else if ((region = RegionFactory::create (_session, *child, true)) != 0) {
region->freeze ();
} else {
return regions.size();
}
-nframes_t
+framecnt_t
Playlist::get_maximum_extent () const
{
RegionLock rlock (const_cast<Playlist *>(this), false);
return _get_maximum_extent ();
}
-ARDOUR::nframes_t
+framecnt_t
Playlist::_get_maximum_extent () const
{
RegionList::const_iterator i;
- nframes_t max_extent = 0;
- nframes_t end = 0;
+ framecnt_t max_extent = 0;
+ framepos_t end = 0;
for (i = regions.begin(); i != regions.end(); ++i) {
if ((end = (*i)->position() + (*i)->length()) > max_extent) {
int const divisions = 512;
/* find the start and end positions of the regions on this playlist */
- nframes_t start = UINT_MAX;
- nframes_t end = 0;
+ framepos_t start = UINT_MAX;
+ framepos_t end = 0;
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
start = min (start, (*i)->position());
end = max (end, (*i)->position() + (*i)->length());
}
void
-Playlist::nudge_after (nframes_t start, nframes_t distance, bool forwards)
+Playlist::nudge_after (framepos_t start, framecnt_t distance, bool forwards)
{
RegionList::iterator i;
- nframes_t new_pos;
+ framepos_t new_pos;
bool moved = false;
_nudging = true;
Playlist::shuffle (boost::shared_ptr<Region> region, int dir)
{
bool moved = false;
- nframes_t new_pos;
+ framepos_t new_pos;
if (region->locked()) {
return;
bool
-Playlist::has_region_at (nframes64_t const p) const
+Playlist::has_region_at (framepos_t const p) const
{
RegionLock (const_cast<Playlist *> (this));
using namespace ARDOUR;
using namespace PBD;
-Change Region::FadeChanged = PBD::new_change ();
-Change Region::SyncOffsetChanged = PBD::new_change ();
-Change Region::MuteChanged = PBD::new_change ();
-Change Region::OpacityChanged = PBD::new_change ();
-Change Region::LockChanged = PBD::new_change ();
-Change Region::LayerChanged = PBD::new_change ();
-Change Region::HiddenChanged = PBD::new_change ();
-
+PropertyChange Region::FadeChanged = PBD::new_change ();
+PropertyChange Region::SyncOffsetChanged = PBD::new_change ();
+PropertyChange Region::MuteChanged = PBD::new_change ();
+PropertyChange Region::OpacityChanged = PBD::new_change ();
+PropertyChange Region::LockChanged = PBD::new_change ();
+PropertyChange Region::LayerChanged = PBD::new_change ();
+PropertyChange Region::HiddenChanged = PBD::new_change ();
+
+namespace ARDOUR {
+ namespace Properties {
+ PBD::PropertyDescriptor<bool> muted;
+ PBD::PropertyDescriptor<bool> opaque;
+ PBD::PropertyDescriptor<bool> locked;
+ PBD::PropertyDescriptor<bool> automatic;
+ PBD::PropertyDescriptor<bool> whole_file;
+ PBD::PropertyDescriptor<bool> import;
+ PBD::PropertyDescriptor<bool> external;
+ PBD::PropertyDescriptor<bool> sync_marked;
+ PBD::PropertyDescriptor<bool> left_of_split;
+ PBD::PropertyDescriptor<bool> right_of_split;
+ PBD::PropertyDescriptor<bool> hidden;
+ PBD::PropertyDescriptor<bool> position_locked;
+ PBD::PropertyDescriptor<framepos_t> start;
+ PBD::PropertyDescriptor<framecnt_t> length;
+ PBD::PropertyDescriptor<framepos_t> position;
+ PBD::PropertyDescriptor<framecnt_t> sync_position;
+ PBD::PropertyDescriptor<layer_t> layer;
+ PBD::PropertyDescriptor<framepos_t> ancestral_start;
+ PBD::PropertyDescriptor<framecnt_t> ancestral_length;
+ PBD::PropertyDescriptor<float> stretch;
+ PBD::PropertyDescriptor<float> shift;
+ }
+}
+
PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > Region::RegionPropertyChanged;
void
-Region::register_states ()
+Region::make_property_quarks ()
+{
+ Properties::muted.id = g_quark_from_static_string (X_("muted"));
+ Properties::opaque.id = g_quark_from_static_string (X_("opaque"));
+ Properties::locked.id = g_quark_from_static_string (X_("locked"));
+ Properties::automatic.id = g_quark_from_static_string (X_("automatic"));
+ Properties::whole_file.id = g_quark_from_static_string (X_("whole-file"));
+ Properties::import.id = g_quark_from_static_string (X_("import"));
+ Properties::external.id = g_quark_from_static_string (X_("external"));
+ Properties::sync_marked.id = g_quark_from_static_string (X_("sync-marked"));
+ Properties::left_of_split.id = g_quark_from_static_string (X_("left-of-split"));
+ Properties::right_of_split.id = g_quark_from_static_string (X_("right-of-split"));
+ Properties::hidden.id = g_quark_from_static_string (X_("hidden"));
+ Properties::position_locked.id = g_quark_from_static_string (X_("position-locked"));
+ Properties::start.id = g_quark_from_static_string (X_("start"));
+ Properties::length.id = g_quark_from_static_string (X_("length"));
+ Properties::position.id = g_quark_from_static_string (X_("position"));
+ Properties::sync_position.id = g_quark_from_static_string (X_("sync-position"));
+ Properties::layer.id = g_quark_from_static_string (X_("layer"));
+ Properties::ancestral_start.id = g_quark_from_static_string (X_("ancestral-start"));
+ Properties::ancestral_length.id = g_quark_from_static_string (X_("ancestral-length"));
+ Properties::stretch.id = g_quark_from_static_string (X_("stretch"));
+ Properties::shift.id = g_quark_from_static_string (X_("shift"));
+}
+
+void
+Region::register_properties ()
{
_xml_node_name = X_("Region");
- add_state (_flags);
- add_state (_start);
- add_state (_length);
- add_state (_position);
- add_state (_sync_position);
- add_state (_layer);
- add_state (_ancestral_start);
- add_state (_ancestral_length);
- add_state (_stretch);
- add_state (_shift);
-}
+
+ add_property (_muted);
+ add_property (_opaque);
+ add_property (_locked);
+ add_property (_automatic);
+ add_property (_whole_file);
+ add_property (_import);
+ add_property (_external);
+ add_property (_sync_marked);
+ add_property (_left_of_split);
+ add_property (_right_of_split);
+ add_property (_hidden);
+ add_property (_position_locked);
+ add_property (_start);
+ add_property (_length);
+ add_property (_position);
+ add_property (_sync_position);
+ add_property (_layer);
+ add_property (_ancestral_start);
+ add_property (_ancestral_length);
+ add_property (_stretch);
+ add_property (_shift);
+}
+
+#define REGION_DEFAULT_STATE(s,l) \
+ _muted (Properties::muted, MuteChanged, false) \
+ , _opaque (Properties::opaque, OpacityChanged, true) \
+ , _locked (Properties::locked, LockChanged, false) \
+ , _automatic (Properties::automatic, PropertyChange (0), false) \
+ , _whole_file (Properties::whole_file, PropertyChange (0), false) \
+ , _import (Properties::import, PropertyChange (0), false) \
+ , _external (Properties::external, PropertyChange (0), false) \
+ , _sync_marked (Properties::sync_marked, SyncOffsetChanged, false) \
+ , _left_of_split (Properties::left_of_split, PropertyChange (0), false) \
+ , _right_of_split (Properties::right_of_split, PropertyChange (0), false) \
+ , _hidden (Properties::hidden, HiddenChanged, false) \
+ , _position_locked (Properties::position_locked, PropertyChange (0), false) \
+ , _start (Properties::start, StartChanged, (s)) \
+ , _length (Properties::length, LengthChanged, (l)) \
+ , _position (Properties::position, PositionChanged, 0) \
+ , _sync_position (Properties::sync_position, SyncOffsetChanged, (s)) \
+ , _layer (Properties::layer, LayerChanged, 0) \
+ , _ancestral_start (Properties::ancestral_start, PropertyChange (0), (s)) \
+ , _ancestral_length (Properties::ancestral_length, PropertyChange (0), (l)) \
+ , _stretch (Properties::stretch, PropertyChange (0), 1.0) \
+ , _shift (Properties::shift, PropertyChange (0), 1.0)
+
+#define REGION_COPY_STATE(other) \
+ _muted (other->_muted) \
+ , _opaque (other->_opaque) \
+ , _locked (other->_locked) \
+ , _automatic (other->_automatic) \
+ , _whole_file (other->_whole_file) \
+ , _import (other->_import) \
+ , _external (other->_external) \
+ , _sync_marked (other->_sync_marked) \
+ , _left_of_split (other->_left_of_split) \
+ , _right_of_split (other->_right_of_split) \
+ , _hidden (other->_hidden) \
+ , _position_locked (other->_position_locked) \
+ , _start(other->_start) \
+ , _length(other->_length) \
+ , _position(other->_position) \
+ , _sync_position(other->_sync_position) \
+ , _layer (other->_layer) \
+ , _ancestral_start (other->_ancestral_start) \
+ , _ancestral_length (other->_ancestral_length) \
+ , _stretch (other->_stretch) \
+ , _shift (other->_shift)
/* derived-from-derived constructor (no sources in constructor) */
-Region::Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags)
+Region::Region (Session& s, framepos_t start, framecnt_t length, const string& name, DataType type)
: SessionObject(s, name)
, _type(type)
- , _flags (X_("flags"), FlagsChanged, Flag (flags|DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, start)
- , _length (X_("length"), LengthChanged, length)
- , _position (X_("position"), PositionChanged, 0)
+ , _no_property_changes (true)
+ , REGION_DEFAULT_STATE(start,length)
+ , _last_length (length)
, _last_position (0)
, _positional_lock_style(AudioTime)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, _start)
- , _layer (X_("layer"), LayerChanged, layer)
- , _first_edit(EditChangesNothing)
+ , _first_edit (EditChangesNothing)
, _frozen(0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
, _read_data_count(0)
- , _pending_changed(Change (0))
+ , _pending_changed(PropertyChange (0))
, _last_layer_op(0)
, _pending_explicit_relayer (false)
{
- register_states ();
-
+ register_properties ();
+
/* no sources at this point */
}
/** Basic Region constructor (single source) */
-Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags)
- : SessionObject(src->session(), name)
- , _type(type)
- , _flags (X_("flags"), FlagsChanged, Flag (flags|DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, start)
- , _length (X_("length"), LengthChanged, length)
- , _position (X_("position"), PositionChanged, 0)
- , _last_position(0)
- , _positional_lock_style(AudioTime)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, _start)
- , _layer (X_("layer"), LayerChanged, layer)
- , _first_edit(EditChangesNothing)
+Region::Region (boost::shared_ptr<Source> src)
+ : SessionObject(src->session(), "toBeRenamed")
+ , _type (src->type())
+ , _no_property_changes (true)
+ , REGION_DEFAULT_STATE(0,0)
+ , _last_length (0)
+ , _last_position (0)
+ , _positional_lock_style (_type == DataType::AUDIO ? AudioTime : MusicTime)
+ , _first_edit (EditChangesNothing)
, _frozen(0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
, _valid_transients(false)
, _read_data_count(0)
- , _pending_changed(Change (0))
+ , _pending_changed(PropertyChange (0))
, _last_layer_op(0)
, _pending_explicit_relayer (false)
{
- register_states ();
+ register_properties ();
_sources.push_back (src);
_master_sources.push_back (src);
src->DropReferences.connect_same_thread (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(src)));
-
- assert(_sources.size() > 0);
- _positional_lock_style = AudioTime;
+
+ assert (_sources.size() > 0);
+ assert (_type == src->type());
}
/** Basic Region constructor (many sources) */
-Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags)
- : SessionObject(srcs.front()->session(), name)
- , _type(type)
- , _flags (X_("flags"), FlagsChanged, Flag (flags|DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, start)
- , _length (X_("length"), LengthChanged, length)
- , _position (X_("position"), PositionChanged, 0)
- , _last_position(0)
- , _positional_lock_style(AudioTime)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, _start)
- , _layer (X_("layer"), LayerChanged, layer)
- , _first_edit(EditChangesNothing)
- , _frozen(0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
+Region::Region (const SourceList& srcs)
+ : SessionObject(srcs.front()->session(), "toBeRenamed")
+ , _type (srcs.front()->type())
+ , _no_property_changes (true)
+ , REGION_DEFAULT_STATE(0,0)
+ , _last_length (0)
+ , _last_position (0)
+ , _positional_lock_style (_type == DataType::AUDIO ? AudioTime : MusicTime)
+ , _first_edit (EditChangesNothing)
+ , _frozen (0)
+ , _valid_transients(false)
, _read_data_count(0)
- , _pending_changed(Change (0))
- , _last_layer_op(0)
+ , _pending_changed(PropertyChange (0))
+ , _last_layer_op (0)
, _pending_explicit_relayer (false)
{
- register_states ();
+ register_properties ();
+
+ _type = srcs.front()->type();
use_sources (srcs);
+
assert(_sources.size() > 0);
+ assert (_type == srcs.front()->type());
}
-/** Create a new Region from part of an existing one */
-Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
- : SessionObject(other->session(), name)
+/** Create a new Region from part of an existing one, starting at one of two places:
+
+ if @param offset_relative is true, then the start within @param other is given by @param offset
+ (i.e. relative to the start of @param other's sources, the start is @param offset + @param other.start()
+
+ if @param offset_relative is false, then the start within the source is given @param offset.
+*/
+Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset, bool offset_relative)
+ : SessionObject(other->session(), "toBeRenamed")
, _type (other->data_type())
- , _flags (X_("flags"), FlagsChanged, Flag (flags | DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, 0)
- , _length (X_("length"), LengthChanged, 0)
- , _position (X_("position"), PositionChanged, 0)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, 0)
- , _layer (X_("layer"), LayerChanged, 0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
+ , _no_property_changes (true)
+ , REGION_COPY_STATE (other)
+ , _last_length (other->_last_length)
+ , _last_position(other->_last_position) \
+ , _positional_lock_style(other->_positional_lock_style) \
+ , _first_edit (EditChangesNothing)
+ , _frozen (0)
+ , _valid_transients(false)
+ , _read_data_count(0)
+ , _pending_changed(PropertyChange (0))
+ , _last_layer_op (0)
, _pending_explicit_relayer (false)
{
- register_states ();
+ register_properties ();
- _start = other->_start + offset;
- copy_stuff (other, offset, length, name, layer, flags);
+ /* override state that may have been incorrectly inherited from the other region
+ */
- /* if the other region had a distinct sync point
- set, then continue to use it as best we can.
- otherwise, reset sync point back to start.
- */
+ _position = 0;
+ _locked = false;
+ _whole_file = false;
+ _hidden = false;
- if (other->flags() & SyncMarked) {
- if (other->_sync_position < _start) {
- _flags = Flag (_flags & ~SyncMarked);
- _sync_position = _start;
+ use_sources (other->_sources);
+
+ if (!offset_relative) {
+
+ /* not sure why we do this, but its a hangover from ardour before
+ property lists. this would be nice to remove.
+ */
+
+ _positional_lock_style = other->_positional_lock_style;
+ _first_edit = other->_first_edit;
+
+ if (offset == 0) {
+
+ _start = 0;
+
+ /* sync pos is relative to start of file. our start-in-file is now zero,
+ so set our sync position to whatever the the difference between
+ _start and _sync_pos was in the other region.
+
+ result is that our new sync pos points to the same point in our source(s)
+ as the sync in the other region did in its source(s).
+
+ since we start at zero in our source(s), it is not possible to use a sync point that
+ is before the start. reset it to _start if that was true in the other region.
+ */
+
+ if (other->sync_marked()) {
+ if (other->_start < other->_sync_position) {
+ /* sync pos was after the start point of the other region */
+ _sync_position = other->_sync_position - other->_start;
+ } else {
+ /* sync pos was before the start point of the other region. not possible here. */
+ _sync_marked = false;
+ _sync_position = _start;
+ }
+ } else {
+ _sync_marked = false;
+ _sync_position = _start;
+ }
} else {
- _sync_position = other->_sync_position;
+ /* XXX do something else ! */
+ fatal << string_compose (_("programming error: %1"), X_("Region+offset constructor used with illegal combination of offset+relative"))
+ << endmsg;
+ /*NOTREACHED*/
}
+
} else {
- _flags = Flag (_flags & ~SyncMarked);
- _sync_position = _start;
+
+ _start = other->_start + offset;
+
+ /* if the other region had a distinct sync point
+ set, then continue to use it as best we can.
+ otherwise, reset sync point back to start.
+ */
+
+ if (other->sync_marked()) {
+ if (other->_sync_position < _start) {
+ _sync_marked = false;
+ _sync_position = _start;
+ } else {
+ _sync_position = other->_sync_position;
+ }
+ } else {
+ _sync_marked = false;
+ _sync_position = _start;
+ }
}
if (Profile->get_sae()) {
*/
if (_sync_position < _start || _sync_position >= _start + _length) {
- _flags = Flag (_flags & ~SyncMarked);
+ _sync_marked = false;
_sync_position = _start;
}
}
-}
-Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
- : SessionObject(other->session(), name)
- , _type (other->data_type())
- , _flags (X_("flags"), FlagsChanged, Flag (flags|DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, 0)
- , _length (X_("length"), LengthChanged, 0)
- , _position (X_("position"), PositionChanged, 0)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, 0)
- , _layer (X_("layer"), LayerChanged, 0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
+ assert (_type == other->data_type());
+}
+
+/** Create a copy of @param other but with different sources. Used by filters */
+Region::Region (boost::shared_ptr<const Region> other, const SourceList& srcs)
+ : SessionObject (other->session(), other->name())
+ , _type (srcs.front()->type())
+ , _no_property_changes (true)
+ , REGION_COPY_STATE (other)
+ , _last_length (other->_last_length)
+ , _last_position (other->_last_position)
+ , _positional_lock_style (other->_positional_lock_style)
+ , _first_edit (EditChangesID)
+ , _frozen (0)
+ , _valid_transients (false)
+ , _read_data_count (0)
+ , _pending_changed (PropertyChange(0))
+ , _last_layer_op (other->_last_layer_op)
, _pending_explicit_relayer (false)
{
- register_states ();
-
- /* create a new Region exactly like another but starting at 0 in its sources */
+ register_properties ();
- _start = 0;
- copy_stuff (other, 0, length, name, layer, flags);
+ _locked = false;
+ _position_locked = false;
- _flags = Flag (_flags | DoNotSendPropertyChanges);
-
- /* sync pos is relative to start of file. our start-in-file is now zero,
- so set our sync position to whatever the the difference between
- _start and _sync_pos was in the other region.
-
- result is that our new sync pos points to the same point in our source(s)
- as the sync in the other region did in its source(s).
-
- since we start at zero in our source(s), it is not possible to use a sync point that
- is before the start. reset it to _start if that was true in the other region.
- */
+ other->_first_edit = EditChangesName;
- if (other->flags() & SyncMarked) {
- if (other->_start < other->_sync_position) {
- /* sync pos was after the start point of the other region */
- _sync_position = other->_sync_position - other->_start;
- } else {
- /* sync pos was before the start point of the other region. not possible here. */
- _flags = Flag (_flags & ~SyncMarked);
- _sync_position = _start;
- }
+ if (other->_extra_xml) {
+ _extra_xml = new XMLNode (*other->_extra_xml);
} else {
- _flags = Flag (_flags & ~SyncMarked);
- _sync_position = _start;
- }
-
- if (Profile->get_sae()) {
- /* reset sync point to start if its ended up
- outside region bounds.
- */
-
- if (_sync_position < _start || _sync_position >= _start + _length) {
- _flags = Flag (_flags & ~SyncMarked);
- _sync_position = _start;
- }
+ _extra_xml = 0;
}
- /* reset a couple of things that copy_stuff() gets wrong in this particular case */
-
- _positional_lock_style = other->_positional_lock_style;
- _first_edit = other->_first_edit;
+ use_sources (srcs);
+ assert(_sources.size() > 0);
}
-/** Pure copy constructor */
+/** Simple "copy" constructor */
Region::Region (boost::shared_ptr<const Region> other)
: SessionObject(other->session(), other->name())
, _type(other->data_type())
- , _flags (other->_flags)
- , _start(other->_start)
- , _length(other->_length)
- , _position(other->_position)
- , _last_position(other->_last_position)
- , _positional_lock_style(other->_positional_lock_style)
- , _sync_position(other->_sync_position)
- , _layer(other->_layer)
- , _first_edit(EditChangesID)
+ , _no_property_changes (true)
+ , REGION_COPY_STATE (other)
+ , _last_length (other->_last_length)
+ , _last_position (other->_last_position)
+ , _positional_lock_style (other->_positional_lock_style)
+ , _first_edit (EditChangesID)
, _frozen(0)
- , _ancestral_start (other->_ancestral_start)
- , _ancestral_length (other->_ancestral_length)
- , _stretch (other->_stretch)
- , _shift (other->_shift)
, _valid_transients(false)
, _read_data_count(0)
- , _pending_changed(Change(0))
+ , _pending_changed(PropertyChange(0))
, _last_layer_op(other->_last_layer_op)
, _pending_explicit_relayer (false)
{
- register_states ();
+ register_properties ();
- _flags = Flag (_flags & ~ (Locked | PositionLocked));
- _flags = Flag (_flags | DoNotSendPropertyChanges);
+ _locked = false;
+ _position_locked = false;
other->_first_edit = EditChangesName;
Region::Region (const SourceList& srcs, const XMLNode& node)
: SessionObject(srcs.front()->session(), X_("error: XML did not reset this"))
- , _type(DataType::NIL) // to be loaded from XML
- , _flags (X_("flags"), FlagsChanged, Flag (DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, 0)
- , _length (X_("length"), LengthChanged, 0)
- , _position (X_("position"), PositionChanged, 0)
- , _last_position(0)
- , _positional_lock_style(AudioTime)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, _start)
- , _layer (X_("layer"), LayerChanged, 0)
- , _first_edit(EditChangesNothing)
+ , _type (srcs.front()->type())
+ , REGION_DEFAULT_STATE(0,0)
+ , _last_length (0)
+ , _last_position (0)
+ , _positional_lock_style (_type == DataType::AUDIO ? AudioTime : MusicTime)
+ , _first_edit (EditChangesNothing)
, _frozen(0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
+ , _valid_transients(false)
, _read_data_count(0)
- , _pending_changed(Change(0))
+ , _pending_changed(PropertyChange(0))
, _last_layer_op(0)
, _pending_explicit_relayer (false)
{
- register_states ();
+ const XMLProperty* prop;
+
+ register_properties ();
+
+ if ((prop = node.property (X_("id")))) {
+ _id = prop->value();
+ }
use_sources (srcs);
assert(_type != DataType::NIL);
assert(_sources.size() > 0);
+ assert (_type == srcs.front()->type());
+
}
Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
: SessionObject(src->session(), X_("error: XML did not reset this"))
- , _type(DataType::NIL)
- , _flags (X_("flags"), FlagsChanged, Flag (DoNotSendPropertyChanges))
- , _start (X_("start"), StartChanged, 0)
- , _length (X_("length"), LengthChanged, 0)
- , _position (X_("position"), PositionChanged, 0)
- , _last_position(0)
- , _positional_lock_style(AudioTime)
- , _sync_position (X_("sync-position"), SyncOffsetChanged, _start)
- , _layer (X_("layer"), LayerChanged, 0)
- , _first_edit(EditChangesNothing)
- , _frozen(0)
- , _ancestral_start (X_("ancestral-start"), Change (0), 0)
- , _ancestral_length (X_("ancestral-length"), Change (0), 0)
- , _stretch (X_("stretch"), Change (0), 1.0)
- , _shift (X_("shift"), Change (0), 1.0)
- , _read_data_count(0)
- , _pending_changed(Change(0))
- , _last_layer_op(0)
+ , _type (src->type())
+ , REGION_DEFAULT_STATE(0,0)
+ , _last_length (0)
+ , _last_position (0)
+ , _positional_lock_style (_type == DataType::AUDIO ? AudioTime : MusicTime)
+ , _first_edit (EditChangesNothing)
+ , _frozen (0)
+ , _read_data_count (0)
+ , _pending_changed (PropertyChange(0))
+ , _last_layer_op (0)
, _pending_explicit_relayer (false)
{
- register_states ();
+ const XMLProperty *prop;
+
+ register_properties ();
_sources.push_back (src);
+ if ((prop = node.property (X_("id")))) {
+ _id = prop->value();
+ }
+
if (set_state (node, Stateful::loading_state_version)) {
throw failed_constructor();
}
- assert(_type != DataType::NIL);
- assert(_sources.size() > 0);
+ assert (_type != DataType::NIL);
+ assert (_sources.size() > 0);
+ assert (_type == src->type());
}
Region::~Region ()
DEBUG_TRACE (DEBUG::Destruction, string_compose ("Region %1 destructor @ %2\n", _name, this));
}
-void
-Region::copy_stuff (boost::shared_ptr<const Region> other, nframes_t /*offset*/, nframes_t length, const string& name, layer_t layer, Flag flags)
-{
- _frozen = 0;
- _pending_changed = Change (0);
- _read_data_count = 0;
- _valid_transients = false;
-
- _length = length;
- _last_length = length;
- _sync_position = other->_sync_position;
- _ancestral_start = other->_ancestral_start;
- _ancestral_length = other->_ancestral_length;
- _stretch = other->_stretch;
- _shift = other->_shift;
- _name = name;
- _last_position = 0;
- _position = 0;
- _layer = layer;
- _flags = Flag (flags & ~(Locked|WholeFile|Hidden));
- _first_edit = EditChangesNothing;
- _last_layer_op = 0;
- _positional_lock_style = AudioTime;
-
- use_sources (other->_sources);
-}
-
void
Region::set_playlist (boost::weak_ptr<Playlist> wpl)
{
}
void
-Region::set_length (nframes_t len, void */*src*/)
+Region::set_length (framecnt_t len, void */*src*/)
{
//cerr << "Region::set_length() len = " << len << endl;
- if (_flags & Locked) {
+ if (locked()) {
return;
}
_last_length = _length;
_length = len;
-
- _flags = Region::Flag (_flags & ~WholeFile);
-
+ _whole_file = false;
first_edit ();
maybe_uncopy ();
invalidate_transients ();
void
Region::maybe_uncopy ()
{
+ /* this does nothing but marked a semantic moment once upon a time */
}
void
}
void
-Region::special_set_position (nframes_t pos)
+Region::special_set_position (framepos_t pos)
{
/* this is used when creating a whole file region as
a way to store its "natural" or "captured" position.
}
TempoMap& map (_session.tempo_map());
- nframes_t pos = map.frame_time (_bbt_time);
+ framepos_t pos = map.frame_time (_bbt_time);
set_position_internal (pos, false);
}
void
-Region::set_position (nframes_t pos, void* /*src*/)
+Region::set_position (framepos_t pos, void* /*src*/)
{
if (!can_move()) {
return;
}
void
-Region::set_position_internal (nframes_t pos, bool allow_bbt_recompute)
+Region::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
{
if (_position != pos) {
_last_position = _position;
}
void
-Region::set_position_on_top (nframes_t pos, void* /*src*/)
+Region::set_position_on_top (framepos_t pos, void* /*src*/)
{
- if (_flags & Locked) {
+ if (locked()) {
return;
}
}
void
-Region::nudge_position (nframes64_t n, void* /*src*/)
+Region::nudge_position (frameoffset_t n, void* /*src*/)
{
- if (_flags & Locked) {
+ if (locked()) {
return;
}
_position += n;
}
} else {
- if (_position < (nframes_t) -n) {
+ if (_position < -n) {
_position = 0;
} else {
_position += n;
}
void
-Region::set_ancestral_data (nframes64_t s, nframes64_t l, float st, float sh)
+Region::set_ancestral_data (framepos_t s, framecnt_t l, float st, float sh)
{
_ancestral_length = l;
_ancestral_start = s;
}
void
-Region::set_start (nframes_t pos, void* /*src*/)
+Region::set_start (framepos_t pos, void* /*src*/)
{
- if (_flags & (Locked|PositionLocked)) {
+ if (locked() || position_locked()) {
return;
}
/* This just sets the start, nothing else. It effectively shifts
}
_start = pos;
- _flags = Region::Flag (_flags & ~WholeFile);
+ _whole_file = false;
first_edit ();
invalidate_transients ();
}
void
-Region::trim_start (nframes_t new_position, void */*src*/)
+Region::trim_start (framepos_t new_position, void */*src*/)
{
- if (_flags & (Locked|PositionLocked)) {
+ if (locked() || position_locked()) {
return;
}
- nframes_t new_start;
- int32_t start_shift;
+ framepos_t new_start;
+ frameoffset_t start_shift;
if (new_position > _position) {
start_shift = new_position - _position;
} else if (start_shift < 0) {
- if (_start < (nframes_t) -start_shift) {
+ if (_start < -start_shift) {
new_start = 0;
} else {
new_start = _start + start_shift;
}
_start = new_start;
- _flags = Region::Flag (_flags & ~WholeFile);
+ _whole_file = false;
first_edit ();
send_change (StartChanged);
}
void
-Region::trim_front (nframes_t new_position, void *src)
+Region::trim_front (framepos_t new_position, void *src)
{
- if (_flags & Locked) {
+ if (locked()) {
return;
}
- nframes_t end = last_frame();
- nframes_t source_zero;
+ framepos_t end = last_frame();
+ framepos_t source_zero;
if (_position > _start) {
source_zero = _position - _start;
if (new_position < end) { /* can't trim it zero or negative length */
- nframes_t newlen;
+ framecnt_t newlen;
/* can't trim it back passed where source position zero is located */
*/
void
-Region::trim_end (nframes_t new_endpoint, void */*src*/)
+Region::trim_end (framepos_t new_endpoint, void */*src*/)
{
- if (_flags & Locked) {
+ if (locked()) {
return;
}
}
void
-Region::trim_to (nframes_t position, nframes_t length, void *src)
+Region::trim_to (framepos_t position, framecnt_t length, void *src)
{
- if (_flags & Locked) {
+ if (locked()) {
return;
}
}
void
-Region::trim_to_internal (nframes_t position, nframes_t length, void */*src*/)
+Region::trim_to_internal (framepos_t position, framecnt_t length, void */*src*/)
{
- int32_t start_shift;
- nframes_t new_start;
+ frameoffset_t start_shift;
+ framepos_t new_start;
- if (_flags & Locked) {
+ if (locked()) {
return;
}
} else if (start_shift < 0) {
- if (_start < (nframes_t) -start_shift) {
+ if (_start < -start_shift) {
new_start = 0;
} else {
new_start = _start + start_shift;
return;
}
- Change what_changed = Change (0);
+ PropertyChange what_changed = PropertyChange (0);
if (_start != new_start) {
_start = new_start;
- what_changed = Change (what_changed|StartChanged);
+ what_changed = PropertyChange (what_changed|StartChanged);
}
if (_length != length) {
if (!_frozen) {
_last_length = _length;
}
_length = length;
- what_changed = Change (what_changed|LengthChanged);
+ what_changed = PropertyChange (what_changed|LengthChanged);
}
if (_position != position) {
if (!_frozen) {
_last_position = _position;
}
_position = position;
- what_changed = Change (what_changed|PositionChanged);
+ what_changed = PropertyChange (what_changed|PositionChanged);
}
- _flags = Region::Flag (_flags & ~WholeFile);
+ _whole_file = false;
if (what_changed & (StartChanged|LengthChanged)) {
first_edit ();
Region::set_hidden (bool yn)
{
if (hidden() != yn) {
-
- if (yn) {
- _flags = Flag (_flags|Hidden);
- } else {
- _flags = Flag (_flags & ~Hidden);
- }
-
+ _hidden = yn;
send_change (HiddenChanged);
}
}
void
-Region::set_muted (bool yn)
+Region::set_whole_file (bool yn)
{
- if (muted() != yn) {
+ _whole_file = yn;
+ /* no change signal */
+}
- if (yn) {
- _flags = Flag (_flags|Muted);
- } else {
- _flags = Flag (_flags & ~Muted);
- }
+void
+Region::set_automatic (bool yn)
+{
+ _automatic = yn;
+ /* no change signal */
+}
+void
+Region::set_muted (bool yn)
+{
+ if (muted() != yn) {
+ _muted = yn;
send_change (MuteChanged);
}
}
Region::set_opaque (bool yn)
{
if (opaque() != yn) {
- if (yn) {
- _flags = Flag (_flags|Opaque);
- } else {
- _flags = Flag (_flags & ~Opaque);
- }
+ _opaque = yn;
send_change (OpacityChanged);
}
}
Region::set_locked (bool yn)
{
if (locked() != yn) {
- if (yn) {
- _flags = Flag (_flags|Locked);
- } else {
- _flags = Flag (_flags & ~Locked);
- }
+ _locked = yn;
send_change (LockChanged);
}
}
Region::set_position_locked (bool yn)
{
if (position_locked() != yn) {
- if (yn) {
- _flags = Flag (_flags|PositionLocked);
- } else {
- _flags = Flag (_flags & ~PositionLocked);
- }
+ _position_locked = yn;
send_change (LockChanged);
}
}
void
-Region::set_sync_position (nframes_t absolute_pos)
+Region::set_sync_position (framepos_t absolute_pos)
{
- nframes_t const file_pos = _start + (absolute_pos - _position);
+ framepos_t const file_pos = _start + (absolute_pos - _position);
if (file_pos != _sync_position) {
-
+ _sync_marked = true;
_sync_position = file_pos;
- _flags = Flag (_flags|SyncMarked);
-
if (!_frozen) {
maybe_uncopy ();
}
void
Region::clear_sync_position ()
{
- if (_flags & SyncMarked) {
- _flags = Flag (_flags & ~SyncMarked);
-
+ if (sync_marked()) {
+ _sync_marked = false;
if (!_frozen) {
maybe_uncopy ();
}
}
}
-nframes_t
+framepos_t
Region::sync_offset (int& dir) const
{
/* returns the sync point relative the first frame of the region */
- if (_flags & SyncMarked) {
+ if (sync_marked()) {
if (_sync_position > _start) {
dir = 1;
return _sync_position - _start;
}
}
-nframes_t
-Region::adjust_to_sync (nframes_t pos) const
+framepos_t
+Region::adjust_to_sync (framepos_t pos) const
{
int sync_dir;
- nframes_t offset = sync_offset (sync_dir);
+ frameoffset_t offset = sync_offset (sync_dir);
// cerr << "adjusting pos = " << pos << " to sync at " << _sync_position << " offset = " << offset << " with dir = " << sync_dir << endl;
return pos;
}
-nframes_t
+framepos_t
Region::sync_position() const
{
- if (_flags & SyncMarked) {
+ if (sync_marked()) {
return _sync_position;
} else {
return _start;
char buf[64];
const char* fe = NULL;
- add_states (*node);
+ add_properties (*node);
_id.print (buf, sizeof (buf));
node->add_property ("id", buf);
}
int
-Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_changed, bool send)
+Region::set_state (const XMLNode& node, int version)
{
- const XMLNodeList& nlist = node.children();
- const XMLProperty *prop;
+ PropertyChange what_changed = PropertyChange (0);
+ return _set_state (node, version, what_changed, true);
+}
- /* this is responsible for setting those aspects of Region state
- that are mutable after construction.
- */
+int
+Region::_set_state (const XMLNode& node, int version, PropertyChange& what_changed, bool send)
+{
+ const XMLProperty* prop;
- if ((prop = node.property ("type")) == 0) {
- _type = DataType::AUDIO;
- } else {
- _type = DataType(prop->value());
+ what_changed = set_properties (node);
+
+ if ((prop = node.property (X_("id")))) {
+ _id = prop->value();
}
if ((prop = node.property ("positional-lock-style")) != 0) {
}
- /* XXX FIRST EDIT !!! */
-
/* fix problems with old sessions corrupted by impossible
values for _stretch or _shift
*/
_shift = 1.0f;
}
- /* note: derived classes set flags */
+ const XMLNodeList& nlist = node.children();
for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
return 0;
}
-int
-Region::set_state (const XMLNode& node, int version)
-{
- const XMLProperty *prop;
-
- /* ID is not allowed to change, ever */
-
- if ((prop = node.property ("id"))) {
- _id = prop->value();
- }
-
- _first_edit = EditChangesNothing;
-
- uint32_t old_flags = _flags;
-
- Change what_changed = set_state_using_states (node);
-
- /* leave this flag setting in place, no matter what */
-
- if ((old_flags & DoNotSendPropertyChanges)) {
- _flags = Flag (_flags | DoNotSendPropertyChanges);
- }
-
- if ((old_flags ^ _flags) & Muted) {
- what_changed = Change (what_changed|MuteChanged);
- cerr << _name << " mute changed\n";
- }
- if ((old_flags ^ _flags) & Opaque) {
- what_changed = Change (what_changed|OpacityChanged);
- cerr << _name << " opacity changed\n";
- }
- if ((old_flags ^ _flags) & Locked) {
- what_changed = Change (what_changed|LockChanged);
- cerr << _name << " lock changed\n";
- }
-
- set_live_state (node, version, what_changed, true);
-
- return 0;
-}
-
void
Region::freeze ()
{
void
Region::thaw ()
{
- Change what_changed = Change (0);
+ PropertyChange what_changed = PropertyChange (0);
{
Glib::Mutex::Lock lm (_lock);
if (_pending_changed) {
what_changed = _pending_changed;
- _pending_changed = Change (0);
+ _pending_changed = PropertyChange (0);
}
}
- if (what_changed == Change (0)) {
+ if (what_changed == PropertyChange (0)) {
return;
}
}
void
-Region::send_change (Change what_changed)
+Region::send_change (PropertyChange what_changed)
{
{
Glib::Mutex::Lock lm (_lock);
if (_frozen) {
- _pending_changed = Change (_pending_changed|what_changed);
+ _pending_changed = PropertyChange (_pending_changed|what_changed);
return;
}
}
StateChanged (what_changed);
cerr << _name << " done with " << hex << what_changed << dec << " @" << get_microseconds() << endl;
- if (!(_flags & DoNotSendPropertyChanges)) {
-
+ if (!_no_property_changes) {
+
/* Try and send a shared_pointer unless this is part of the constructor.
If so, do nothing.
*/
}
bool
-Region::verify_length (nframes_t len)
+Region::verify_length (framecnt_t len)
{
if (source() && (source()->destructive() || source()->length_mutable())) {
return true;
}
- nframes_t maxlen = 0;
+ framecnt_t maxlen = 0;
for (uint32_t n=0; n < _sources.size(); ++n) {
- maxlen = max (maxlen, (nframes_t)source_length(n) - _start);
+ maxlen = max (maxlen, source_length(n) - _start);
}
len = min (len, maxlen);
}
bool
-Region::verify_start_and_length (nframes_t new_start, nframes_t& new_length)
+Region::verify_start_and_length (framepos_t new_start, framecnt_t& new_length)
{
if (source() && (source()->destructive() || source()->length_mutable())) {
return true;
}
- nframes_t maxlen = 0;
+ framecnt_t maxlen = 0;
for (uint32_t n=0; n < _sources.size(); ++n) {
- maxlen = max (maxlen, (nframes_t)source_length(n) - new_start);
+ maxlen = max (maxlen, source_length(n) - new_start);
}
new_length = min (new_length, maxlen);
}
bool
-Region::verify_start (nframes_t pos)
+Region::verify_start (framepos_t pos)
{
if (source() && (source()->destructive() || source()->length_mutable())) {
return true;
}
bool
-Region::verify_start_mutable (nframes_t& new_start)
+Region::verify_start_mutable (framepos_t& new_start)
{
if (source() && (source()->destructive() || source()->length_mutable())) {
return true;
}
}
+
+PropertyChange
+Region::set_property (const PropertyBase& prop)
+{
+ PropertyChange c = PropertyChange (0);
+
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 set property %2\n", _name.val(), prop.property_name()));
+
+ if (prop == Properties::muted.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _muted) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 muted changed from %2 to %3",
+ _name.val(), _muted.val(), val));
+ _muted = val;
+ c = MuteChanged;
+ }
+ } else if (prop == Properties::opaque.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _opaque) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 opaque changed from %2 to %3",
+ _name.val(), _opaque.val(), val));
+ _opaque = val;
+ c = OpacityChanged;
+ }
+ } else if (prop == Properties::locked.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _locked) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 locked changed from %2 to %3",
+ _name.val(), _locked.val(), val));
+ _locked = val;
+ c = LockChanged;
+ }
+ } else if (prop == Properties::automatic.id) {
+ _automatic = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::whole_file.id) {
+ _whole_file = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::import.id) {
+ _import = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::external.id) {
+ _external = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::sync_marked.id) {
+ _sync_marked = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::left_of_split.id) {
+ _left_of_split = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::right_of_split.id) {
+ _right_of_split = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::hidden.id) {
+ bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ if (val != _hidden) {
+ _hidden = val;
+ c = HiddenChanged;
+ }
+ } else if (prop == Properties::position_locked.id) {
+ _position_locked = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
+ } else if (prop == Properties::start.id) {
+ _start = dynamic_cast<const PropertyTemplate<framepos_t>*>(&prop)->val();
+ } else if (prop == Properties::length.id) {
+ const PropertyTemplate<framecnt_t>* pt1 = dynamic_cast<const PropertyTemplate<framecnt_t>* >(&prop);
+ const PropertyTemplate<int>* pt2 = dynamic_cast<const PropertyTemplate<int>* >(&prop);
+
+ cerr << "Cast to frmecnt = " << pt1 << " to int = " << pt2 << endl;
+
+ framecnt_t val = dynamic_cast<const PropertyTemplate<framecnt_t>* > (&prop)->val();
+ if (val != _length) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 length changed from %2 to %3",
+ _name.val(), _length.val(), val));
+ _length = val;
+ c = LengthChanged;
+ } else {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("length %1 matches %2\n", _length.val(), val));
+ }
+
+ } else if (prop == Properties::position.id) {
+ framepos_t val = dynamic_cast<const PropertyTemplate<framepos_t>*>(&prop)->val();
+ if (val != _position) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 position changed from %2 to %3",
+ _name.val(), _position.val(), val));
+ _position = val;
+ c = PositionChanged;
+ }
+ } else if (prop == Properties::sync_position.id) {
+ framepos_t val = dynamic_cast<const PropertyTemplate<framepos_t>*>(&prop)->val();
+ if (val != _sync_position) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 syncpos changed from %2 to %3",
+ _name.val(), _sync_position, val));
+ _sync_position = val;
+ c = SyncOffsetChanged;
+ }
+ } else if (prop == Properties::layer.id) {
+ layer_t val = dynamic_cast<const PropertyTemplate<layer_t>*>(&prop)->val();
+ if (val != _layer) {
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("region %1 syncpos changed from %2 to %3",
+ _name.val(), _sync_position, val));
+ _layer = val;
+ c = LayerChanged;
+ }
+ } else if (prop == Properties::ancestral_start.id) {
+ _ancestral_start = dynamic_cast<const PropertyTemplate<framepos_t>*>(&prop)->val();
+ } else if (prop == Properties::ancestral_length.id) {
+ _ancestral_length = dynamic_cast<const PropertyTemplate<framecnt_t>*>(&prop)->val();
+ } else if (prop == Properties::stretch.id) {
+ _stretch = dynamic_cast<const PropertyTemplate<float>*>(&prop)->val();
+ } else if (prop == Properties::shift.id) {
+ _shift = dynamic_cast<const PropertyTemplate<float>*>(&prop)->val();
+ } else {
+ return SessionObject::set_property (prop);
+ }
+
+ return c;
+}
#include "pbd/enumwriter.h"
#include "ardour/region.h"
-#include "ardour/region_command.h"
#include "ardour/utils.h"
#include "i18n.h"
map<PBD::ID,boost::weak_ptr<Region> > RegionFactory::region_map;
boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<Region> region, nframes_t start,
- nframes_t length, const std::string& name,
- layer_t layer, Region::Flag flags, bool announce)
+RegionFactory::create (boost::shared_ptr<const Region> region)
+{
+ boost::shared_ptr<Region> ret;
+ boost::shared_ptr<const AudioRegion> ar;
+ boost::shared_ptr<const MidiRegion> mr;
+
+ if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
+
+ AudioRegion* arn = new AudioRegion (ar, 0, true);
+ boost_debug_shared_ptr_mark_interesting (arn, "Region");
+
+ boost::shared_ptr<AudioRegion> arp (arn);
+ ret = boost::static_pointer_cast<Region> (arp);
+
+ } else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
+
+ MidiRegion* mrn = new MidiRegion (mr, 0, true);
+ boost::shared_ptr<MidiRegion> mrp (mrn);
+ ret = boost::static_pointer_cast<Region> (mrp);
+
+ } else {
+ fatal << _("programming error: RegionFactory::create() called with unknown Region type")
+ << endmsg;
+ /*NOTREACHED*/
+ }
+
+ if (ret) {
+ ret->unlock_property_changes ();
+ map_add (ret);
+
+ /* pure copy constructor - no property list */
+ /* pure copy constructor - no CheckNewRegion emitted */
+ }
+
+ return ret;
+}
+
+boost::shared_ptr<Region>
+RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, const PropertyList& plist, bool announce)
{
+ boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other_a;
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
- AudioRegion* ar = new AudioRegion (other_a, start, length, name, layer, flags);
+
+ AudioRegion* ar = new AudioRegion (other_a, offset, true);
boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
boost::shared_ptr<AudioRegion> arp (ar);
- boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
- ret->unlock_property_changes ();
- map_add (ret);
- if (announce) {
- CheckNewRegion (ret);
- }
- return ret;
+ ret = boost::static_pointer_cast<Region> (arp);
+
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
- MidiRegion* ar = new MidiRegion (other_m, start, length, name, layer, flags);
- boost::shared_ptr<MidiRegion> arp (ar);
- boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
- ret->unlock_property_changes ();
- map_add (ret);
- if (announce) {
- CheckNewRegion (ret);
- }
- return ret;
+
+ MidiRegion* mr = new MidiRegion (other_m, offset, true);
+ boost::shared_ptr<MidiRegion> mrp (mr);
+ ret = boost::static_pointer_cast<Region> (mrp);
+
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
/*NOTREACHED*/
return boost::shared_ptr<Region>();
}
+
+ if (ret) {
+
+ ret->set_properties (plist);
+ ret->unlock_property_changes ();
+
+ map_add (ret);
+
+ if (announce) {
+ CheckNewRegion (ret);
+ }
+ }
+
+ return ret;
}
boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<const Region> region)
+RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& plist, bool announce)
{
- boost::shared_ptr<const AudioRegion> ar;
- boost::shared_ptr<const MidiRegion> mr;
+ boost::shared_ptr<Region> ret;
+ boost::shared_ptr<const AudioRegion> other_a;
+ boost::shared_ptr<const MidiRegion> other_m;
+
+ if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
+
+ AudioRegion* ar = new AudioRegion (other_a, 0, false);
+ boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
+ boost::shared_ptr<AudioRegion> arp (ar);
+ ret = boost::static_pointer_cast<Region> (arp);
+
+ } else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
+
+ MidiRegion* mr = new MidiRegion (other_m, 0, false);
+ boost::shared_ptr<MidiRegion> mrp (mr);
+ ret = boost::static_pointer_cast<Region> (mrp);
- if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
- AudioRegion* arn = new AudioRegion (ar);
- boost_debug_shared_ptr_mark_interesting (arn, "Region");
- boost::shared_ptr<Region> ret (arn);
- ret->unlock_property_changes ();
- map_add (ret);
- /* pure copy constructor - no CheckNewRegion emitted */
- return ret;
- } else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
- boost::shared_ptr<Region> ret (new MidiRegion (mr));
- ret->unlock_property_changes ();
- /* pure copy constructor - no CheckNewRegion emitted */
- return ret;
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
/*NOTREACHED*/
return boost::shared_ptr<Region>();
}
-}
-boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<AudioRegion> region, nframes_t start,
- nframes_t length, const std::string& name,
- layer_t layer, Region::Flag flags, bool announce)
-{
- return create (boost::static_pointer_cast<Region> (region), start, length, name, layer, flags, announce);
+ if (ret) {
+
+ ret->set_properties (plist);
+ ret->unlock_property_changes ();
+
+ map_add (ret);
+
+ if (announce) {
+ CheckNewRegion (ret);
+ }
+ }
+
+ return ret;
}
-boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
- const std::string& name, layer_t layer, Region::Flag flags, bool announce)
+
+
+boost::shared_ptr<Region>
+RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs, const PropertyList& plist, bool announce)
{
+ boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other;
/* used by AudioFilter when constructing a new region that is intended to have nearly
*/
if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
- AudioRegion* ar = new AudioRegion (other, srcs, srcs.front()->length(srcs.front()->timeline_position()), name, layer, flags);
+
+ // XXX use me in caller where plist is setup, this is start i think srcs.front()->length (srcs.front()->timeline_position())
+
+ AudioRegion* ar = new AudioRegion (other, srcs);
boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
boost::shared_ptr<AudioRegion> arp (ar);
- boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
- ret->unlock_property_changes ();
- map_add (ret);
- if (announce) {
- CheckNewRegion (ret);
- }
- return ret;
+ ret = boost::static_pointer_cast<Region> (arp);
+
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
/*NOTREACHED*/
- return boost::shared_ptr<Region>();
}
-}
-boost::shared_ptr<Region>
-RegionFactory::create (Session& session, XMLNode& node, bool yn)
-{
- boost::shared_ptr<Region> r = session.XMLRegionFactory (node, yn);
+ if (ret) {
- if (r) {
- r->unlock_property_changes ();
- map_add (r);
- CheckNewRegion (r);
+ ret->set_properties (plist);
+ ret->unlock_property_changes ();
+
+ map_add (ret);
+
+ if (announce) {
+ CheckNewRegion (ret);
+ }
}
- return r;
+ return ret;
+
}
boost::shared_ptr<Region>
-RegionFactory::create (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Region::Flag flags, bool announce)
+RegionFactory::create (boost::shared_ptr<Source> src, const PropertyList& plist, bool announce)
{
- if (srcs.empty()) {
- return boost::shared_ptr<Region>();
- }
+ boost::shared_ptr<Region> ret;
+ boost::shared_ptr<AudioSource> as;
+ boost::shared_ptr<MidiSource> ms;
- if (srcs[0]->type() == DataType::AUDIO) {
+ if ((as = boost::dynamic_pointer_cast<AudioSource>(src)) != 0) {
- AudioRegion* ar = new AudioRegion (srcs, start, length, name, layer, flags);
+ AudioRegion* ar = new AudioRegion (as);
boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
boost::shared_ptr<AudioRegion> arp (ar);
- boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
+ ret = boost::static_pointer_cast<Region> (arp);
+
+ } else if ((ms = boost::dynamic_pointer_cast<MidiSource>(src)) != 0) {
+ MidiRegion* mr = new MidiRegion (ms);
+ boost_debug_shared_ptr_mark_interesting (mr, "Region");
+
+ boost::shared_ptr<MidiRegion> mrp (mr);
+ ret = boost::static_pointer_cast<Region> (mrp);
+ }
+
+ if (ret) {
+ ret->set_properties (plist);
ret->unlock_property_changes ();
+
map_add (ret);
+
if (announce) {
CheckNewRegion (ret);
}
- return ret;
+ }
- } else if (srcs[0]->type() == DataType::MIDI) {
+ return ret;
+}
- MidiRegion* ar = new MidiRegion (srcs, start, length, name, layer, flags);
- boost::shared_ptr<MidiRegion> mrp (ar);
- boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (mrp));
+boost::shared_ptr<Region>
+RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool announce)
+{
+ boost::shared_ptr<Region> ret;
+ boost::shared_ptr<AudioSource> as;
+ boost::shared_ptr<MidiSource> ms;
+
+ if ((as = boost::dynamic_pointer_cast<AudioSource>(srcs[0])) != 0) {
+
+ AudioRegion* ar = new AudioRegion (srcs);
+ boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
+ boost::shared_ptr<AudioRegion> arp (ar);
+ ret = boost::static_pointer_cast<Region> (arp);
+
+ } else if ((ms = boost::dynamic_pointer_cast<MidiSource>(srcs[0])) != 0) {
+ MidiRegion* mr = new MidiRegion (srcs);
+ boost_debug_shared_ptr_mark_interesting (mr, "Region");
+
+ boost::shared_ptr<MidiRegion> mrp (mr);
+ ret = boost::static_pointer_cast<Region> (mrp);
+ }
+
+ if (ret) {
+ ret->set_properties (plist);
ret->unlock_property_changes ();
+
map_add (ret);
+
if (announce) {
CheckNewRegion (ret);
}
- return ret;
+ }
+ return ret;
+}
+
+boost::shared_ptr<Region>
+RegionFactory::create (Session& session, XMLNode& node, bool yn)
+{
+ boost::shared_ptr<Region> r = session.XMLRegionFactory (node, yn);
+
+ if (r) {
+ r->unlock_property_changes ();
+ map_add (r);
+ CheckNewRegion (r);
}
- return boost::shared_ptr<Region> ();
+ return r;
}
+
boost::shared_ptr<Region>
RegionFactory::create (SourceList& srcs, const XMLNode& node)
{
+ boost::shared_ptr<Region> ret;
+
if (srcs.empty()) {
- return boost::shared_ptr<Region>();
+ return ret;
}
if (srcs[0]->type() == DataType::AUDIO) {
+
AudioRegion* ar = new AudioRegion (srcs, node);
boost_debug_shared_ptr_mark_interesting (ar, "Region");
+
+ boost::shared_ptr<AudioRegion> arp (ar);
+ ret = boost::static_pointer_cast<Region> (arp);
+
boost::shared_ptr<Region> ret (ar);
- ret->unlock_property_changes ();
- map_add (ret);
- CheckNewRegion (ret);
- return ret;
- } else if (srcs[0]->type() == DataType::MIDI) {
- boost::shared_ptr<Region> ret (new MidiRegion (srcs, node));
- ret->unlock_property_changes ();
- map_add (ret);
- CheckNewRegion (ret);
+
return ret;
- }
- return boost::shared_ptr<Region> ();
-}
+ } else if (srcs[0]->type() == DataType::MIDI) {
+
+ MidiRegion* mr = new MidiRegion (srcs, node);
-boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<Source> src, nframes_t start, nframes_t length, const string& name, layer_t layer, Region::Flag flags, bool announce)
-{
- boost::shared_ptr<AudioSource> as;
- boost::shared_ptr<MidiSource> ms;
+ boost::shared_ptr<MidiRegion> mrp (mr);
+ ret = boost::static_pointer_cast<Region> (mrp);
+ }
- if ((as = boost::dynamic_pointer_cast<AudioSource>(src)) != 0) {
- AudioRegion* ar = new AudioRegion (as, start, length, name, layer, flags);
- boost_debug_shared_ptr_mark_interesting (ar, "Region");
- boost::shared_ptr<Region> ret (ar);
+ if (ret) {
ret->unlock_property_changes ();
map_add (ret);
- if (announce) {
- CheckNewRegion (ret);
- }
- return ret;
- } else if ((ms = boost::dynamic_pointer_cast<MidiSource>(src)) != 0) {
- boost::shared_ptr<Region> ret (new MidiRegion (ms, start, length, name, layer, flags));
- ret->unlock_property_changes ();
- map_add (ret);
- if (announce) {
- CheckNewRegion (ret);
- }
- return ret;
+ CheckNewRegion (ret);
}
- return boost::shared_ptr<Region>();
+ return ret;
}
+
void
RegionFactory::map_add (boost::shared_ptr<Region> r)
{
{
SourceList nsrcs;
SourceList::iterator si;
- nframes_t blocksize = 256 * 1024;
+ framecnt_t blocksize = 256 * 1024;
Sample* buf = 0;
- nframes_t fpos;
- nframes_t fstart;
- nframes_t to_read;
+ framepos_t fpos;
+ framepos_t fstart;
+ framecnt_t to_read;
int ret = -1;
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(r);
void
Route::set_gain (gain_t val, void *src)
{
- if (src != 0 && _route_group && src != _route_group && _route_group->active_property (RouteGroup::Gain)) {
+ if (src != 0 && _route_group && src != _route_group && _route_group->is_active() && _route_group->is_gain()) {
if (_route_group->is_relative()) {
return;
}
- if (_route_group && src != _route_group && _route_group->active_property (RouteGroup::Solo)) {
+ if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
_route_group->apply (&Route::set_solo, yn, _route_group);
return;
}
return;
}
- if (_route_group && src != _route_group && _route_group->active_property (RouteGroup::Solo)) {
+ if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
_route_group->apply (&Route::set_solo_isolated, yn, _route_group);
return;
}
void
Route::set_mute (bool yn, void *src)
{
- if (_route_group && src != _route_group && _route_group->active_property (RouteGroup::Mute)) {
+ if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_mute()) {
_route_group->apply (&Route::set_mute, yn, _route_group);
return;
}
#include "i18n.h"
using namespace ARDOUR;
+using namespace PBD;
using namespace std;
-RouteGroup::RouteGroup (Session& s, const string &n, Flag f, Property p)
- : _session (s)
+PropertyChange RouteGroup::FlagsChange = new_change ();
+PropertyChange RouteGroup::PropertiesChange = new_change ();
+
+namespace ARDOUR {
+ namespace Properties {
+ PropertyDescriptor<bool> relative;
+ PropertyDescriptor<bool> active;
+ PropertyDescriptor<bool> gain;
+ PropertyDescriptor<bool> mute;
+ PropertyDescriptor<bool> solo;
+ PropertyDescriptor<bool> recenable;
+ PropertyDescriptor<bool> select;
+ PropertyDescriptor<bool> edit;
+ }
+}
+
+void
+RouteGroup::make_property_quarks ()
+{
+ Properties::relative.id = g_quark_from_static_string (X_("relative"));
+ Properties::active.id = g_quark_from_static_string (X_("active"));
+ Properties::hidden.id = g_quark_from_static_string (X_("hidden"));
+ Properties::gain.id = g_quark_from_static_string (X_("gain"));
+ Properties::mute.id = g_quark_from_static_string (X_("mute"));
+ Properties::solo.id = g_quark_from_static_string (X_("solo"));
+ Properties::recenable.id = g_quark_from_static_string (X_("recenable"));
+ Properties::select.id = g_quark_from_static_string (X_("select"));
+ Properties::edit.id = g_quark_from_static_string (X_("edit"));
+}
+
+#define ROUTE_GROUP_DEFAULT_PROPERTIES _relative (Properties::relative, FlagsChange, false) \
+ , _active (Properties::active, FlagsChange, false) \
+ , _hidden (Properties::hidden, FlagsChange, false) \
+ , _gain (Properties::gain, PropertiesChange, false) \
+ , _mute (Properties::mute, PropertiesChange, false) \
+ , _solo (Properties::solo, PropertiesChange , false) \
+ , _recenable (Properties::recenable, PropertiesChange, false) \
+ , _select (Properties::select, PropertiesChange, false) \
+ , _edit (Properties::edit, PropertiesChange , false)
+
+RouteGroup::RouteGroup (Session& s, const string &n)
+ : SessionObject (s, n)
, routes (new RouteList)
- , _name (n)
- , _flags (f)
- , _properties (Property (p))
+ , ROUTE_GROUP_DEFAULT_PROPERTIES
{
+ _xml_node_name = X_("RegionGroup");
+
+ add_property (_relative);
+ add_property (_active);
+ add_property (_hidden);
+ add_property (_gain);
+ add_property (_mute);
+ add_property (_solo);
+ add_property (_recenable);
+ add_property (_select);
+ add_property (_edit);
}
RouteGroup::~RouteGroup ()
}
}
-void
-RouteGroup::set_name (string str)
-{
- _name = str;
- _session.set_dirty ();
- FlagsChanged (0); /* EMIT SIGNAL */
-}
-
/** Add a route to a group. Adding a route which is already in the group is allowed; nothing will happen.
* @param r Route to add.
*/
RouteGroup::get_state (void)
{
XMLNode *node = new XMLNode ("RouteGroup");
- node->add_property ("name", _name);
- node->add_property ("flags", enum_2_string (_flags));
- node->add_property ("properties", enum_2_string (_properties));
+
+ add_properties (*node);
if (!routes->empty()) {
stringstream str;
const XMLProperty *prop;
- if ((prop = node.property ("name")) != 0) {
- _name = prop->value();
- }
-
- if ((prop = node.property ("flags")) != 0) {
- _flags = Flag (string_2_enum (prop->value(), _flags));
- }
-
- if ((prop = node.property ("properties")) != 0) {
- _properties = Property (string_2_enum (prop->value(), _properties));
- }
-
if ((prop = node.property ("routes")) != 0) {
stringstream str (prop->value());
vector<string> ids;
int
RouteGroup::set_state_2X (const XMLNode& node, int /*version*/)
{
- XMLProperty const * prop;
+ set_properties (node);
- if ((prop = node.property ("name")) != 0) {
- _name = prop->value();
+ if (node.name() == "MixGroup") {
+ _gain = true;
+ _mute = true;
+ _solo = true;
+ _recenable = true;
+ _edit = false;
+ } else if (node.name() == "EditGroup") {
+ _gain = false;
+ _mute = false;
+ _solo = false;
+ _recenable = false;
+ _edit = true;
}
- if ((prop = node.property ("flags")) != 0) {
- _flags = Flag (string_2_enum (prop->value(), _flags));
+ return 0;
+}
+
+void
+RouteGroup::set_gain (bool yn)
+{
+ if (is_gain() == yn) {
+ return;
}
+ _gain = yn;
+}
- if (node.name() == "MixGroup") {
- _properties = Property (Gain | Mute | Solo | RecEnable);
- } else if (node.name() == "EditGroup") {
- _properties = Property (Select | Edit);
+void
+RouteGroup::set_mute (bool yn)
+{
+ if (is_mute() == yn) {
+ return;
}
+ _mute = yn;
+}
- return 0;
+void
+RouteGroup::set_solo (bool yn)
+{
+ if (is_solo() == yn) {
+ return;
+ }
+ _solo = yn;
+}
+
+void
+RouteGroup::set_recenable (bool yn)
+{
+ if (is_recenable() == yn) {
+ return;
+ }
+ _recenable = yn;
+}
+
+void
+RouteGroup::set_select (bool yn)
+{
+ if (is_select() == yn) {
+ return;
+ }
+ _select = yn;
+}
+
+void
+RouteGroup::set_edit (bool yn)
+{
+ if (is_edit() == yn) {
+ return;
+ }
+ _edit = yn;
}
void
if (is_active() == yn) {
return;
}
- if (yn) {
- _flags = Flag (_flags | Active);
- } else {
- _flags = Flag (_flags & ~Active);
- }
+ _active = yn;
_session.set_dirty ();
FlagsChanged (src); /* EMIT SIGNAL */
}
if (is_relative() == yn) {
return;
}
- if (yn) {
- _flags = Flag (_flags | Relative);
- } else {
- _flags = Flag (_flags & ~Relative);
- }
+ _relative = yn;
_session.set_dirty ();
FlagsChanged (src); /* EMIT SIGNAL */
}
void
RouteGroup::set_hidden (bool yn, void *src)
-
{
if (is_hidden() == yn) {
return;
}
if (yn) {
- _flags = Flag (_flags | Hidden);
+ _hidden = true;
if (Config->get_hiding_groups_deactivates_groups()) {
- _flags = Flag (_flags & ~Active);
+ _active = false;
}
} else {
- _flags = Flag (_flags & ~Hidden);
+ _hidden = false;
if (Config->get_hiding_groups_deactivates_groups()) {
- _flags = Flag (_flags | Active);
+ _active = true;
}
}
_session.set_dirty ();
_session.remove_route (subgroup_bus);
subgroup_bus.reset ();
}
+
+bool
+RouteGroup::enabled_property (PBD::PropertyID prop)
+{
+ if (Properties::relative.id == prop) {
+ return is_relative();
+ } else if (Properties::active.id == prop) {
+ return is_active();
+ } else if (Properties::hidden.id == prop) {
+ return is_hidden();
+ } else if (Properties::gain.id == prop) {
+ return is_gain();
+ } else if (Properties::mute.id == prop) {
+ return is_mute();
+ } else if (Properties::solo.id == prop) {
+ return is_solo();
+ } else if (Properties::recenable.id == prop) {
+ return is_recenable();
+ } else if (Properties::select.id == prop) {
+ return is_select();
+ } else if (Properties::edit.id == prop) {
+ return is_edit();
+ }
+
+ return false;
+}
}
void
-Session::region_changed (Change what_changed, boost::weak_ptr<Region> weak_region)
+Session::region_changed (PropertyChange what_changed, boost::weak_ptr<Region> weak_region)
{
boost::shared_ptr<Region> region (weak_region.lock ());
}
void
-Session::tempo_map_changed (Change)
+Session::tempo_map_changed (PropertyChange)
{
clear_clicks ();
/* construct a region to represent the bounced material */
- result = RegionFactory::create (srcs, 0,
- srcs.front()->length(srcs.front()->timeline_position()),
- region_name_from_path (srcs.front()->name(), true));
+ PropertyList plist;
+
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, srcs.front()->length(srcs.front()->timeline_position()));
+ plist.add (Properties::name, region_name_from_path (srcs.front()->name(), true));
+
+ result = RegionFactory::create (srcs, plist);
+
}
out:
#include "ardour/midi_track.h"
#include "ardour/named_selection.h"
#include "ardour/processor.h"
-#include "ardour/region_command.h"
#include "ardour/region_factory.h"
#include "ardour/route_group.h"
#include "ardour/send.h"
error << _("Failed to downcast MidiSource for DeltaCommand") << endmsg;
}
- } else if (n->name() == "RegionCommand") {
- PBD::ID id (n->property ("region")->value());
- boost::shared_ptr<Region> region = RegionFactory::region_by_id (id);
-
- if (region) {
- ut->add_command (new RegionCommand (region, *n));
- } else {
- error << string_compose (_("Region command references an unknown region ID=%1"), id.to_s()) << endmsg;
- }
-
} else if (n->name() == "StatefulDiffCommand") {
if ((c = stateful_diff_command_factory (n))) {
ut->add_command (c);
gain_t* SndFileSource::out_coefficient = 0;
gain_t* SndFileSource::in_coefficient = 0;
-nframes_t SndFileSource::xfade_frames = 64;
+framecnt_t SndFileSource::xfade_frames = 64;
const Source::Flag SndFileSource::default_writable_flags = Source::Flag (
Source::Writable |
Source::Removable |
return _info.samplerate;
}
-nframes_t
-SndFileSource::read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const
+framecnt_t
+SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const
{
int32_t nread;
float *ptr;
uint32_t real_cnt;
- nframes_t file_cnt;
+ framepos_t file_cnt;
if (start > _length) {
}
if (file_cnt != cnt) {
- nframes_t delta = cnt - file_cnt;
+ framepos_t delta = cnt - file_cnt;
memset (dst+file_cnt, 0, sizeof (Sample) * delta);
}
return nread;
}
-nframes_t
-SndFileSource::write_unlocked (Sample *data, nframes_t cnt)
+framecnt_t
+SndFileSource::write_unlocked (Sample *data, framecnt_t cnt)
{
if (destructive()) {
return destructive_write_unlocked (data, cnt);
}
}
-nframes_t
-SndFileSource::nondestructive_write_unlocked (Sample *data, nframes_t cnt)
+framecnt_t
+SndFileSource::nondestructive_write_unlocked (Sample *data, framecnt_t cnt)
{
if (!writable()) {
warning << string_compose (_("attempt to write a non-writable audio file source (%1)"), _path) << endmsg;
return 0;
}
- nframes_t oldlen;
+ framecnt_t oldlen;
int32_t frame_pos = _length;
if (write_float (data, frame_pos, cnt) != cnt) {
return cnt;
}
-nframes_t
-SndFileSource::destructive_write_unlocked (Sample* data, nframes_t cnt)
+framecnt_t
+SndFileSource::destructive_write_unlocked (Sample* data, framecnt_t cnt)
{
- nframes_t old_file_pos;
+ framepos_t old_file_pos;
if (!writable()) {
warning << string_compose (_("attempt to write a non-writable audio file source (%1)"), _path) << endmsg;
}
}
-nframes_t
-SndFileSource::write_float (Sample* data, sframes_t frame_pos, nframes_t cnt)
+framecnt_t
+SndFileSource::write_float (Sample* data, framepos_t frame_pos, framecnt_t cnt)
{
if (sf_seek (sf, frame_pos, SEEK_SET|SFM_WRITE) < 0) {
char errbuf[256];
return cnt;
}
-sframes_t
+framepos_t
SndFileSource::natural_position() const
{
return _timeline_position;
}
}
-nframes_t
-SndFileSource::crossfade (Sample* data, nframes_t cnt, int fade_in)
+framecnt_t
+SndFileSource::crossfade (Sample* data, framecnt_t cnt, int fade_in)
{
- nframes_t xfade = min (xfade_frames, cnt);
- nframes_t nofade = cnt - xfade;
+ framecnt_t xfade = min (xfade_frames, cnt);
+ framecnt_t nofade = cnt - xfade;
Sample* fade_data = 0;
- nframes_t fade_position = 0; // in frames
+ framepos_t fade_position = 0; // in frames
ssize_t retval;
- nframes_t file_cnt;
+ framecnt_t file_cnt;
if (fade_in) {
fade_position = file_pos;
}
if (file_cnt != xfade) {
- nframes_t delta = xfade - file_cnt;
+ framecnt_t delta = xfade - file_cnt;
memset (xfade_buf+file_cnt, 0, sizeof (Sample) * delta);
}
if (xfade == xfade_frames) {
- nframes_t n;
+ framecnt_t n;
/* use the standard xfade curve */
compute_equal_power_fades (xfade, in, out);
- for (nframes_t n = 0; n < xfade; ++n) {
+ for (framecnt_t n = 0; n < xfade; ++n) {
xfade_buf[n] = (xfade_buf[n] * out[n]) + (fade_data[n] * in[n]);
}
-
+
} else if (xfade) {
/* long xfade length, has to be computed across several calls */
before any DFS's are created.
*/
- xfade_frames = (nframes_t) floor ((s.config.get_destructive_xfade_msecs () / 1000.0) * rate);
+ xfade_frames = (framecnt_t) floor ((s.config.get_destructive_xfade_msecs () / 1000.0) * rate);
delete [] out_coefficient;
delete [] in_coefficient;
}
/* find periods of silence in the region */
- std::list<std::pair<nframes_t, nframes_t> > const silence =
+ std::list<std::pair<frameoffset_t, framecnt_t> > const silence =
region->find_silence (dB_to_coefficient (_threshold), _minimum_length);
if (silence.size () == 1 && silence.front().first == 0 && silence.front().second == region->length() - 1) {
return 0;
}
- std::list<std::pair<nframes_t, nframes_t > >::const_iterator s = silence.begin ();
- nframes_t const pos = region->position ();
- nframes_t const end = region->start () + region->length() - 1;
- nframes_t const start = region->start ();
+ std::list<std::pair<framepos_t, framecnt_t > >::const_iterator s = silence.begin ();
+ framepos_t const pos = region->position ();
+ framepos_t const end = region->start () + region->length() - 1;
+ framepos_t const start = region->start ();
region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region));
region->set_name (session.new_region_name (region->name ()));
TempoMap::move_tempo (TempoSection& tempo, const BBT_Time& when)
{
if (move_metric_section (tempo, when) == 0) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
TempoMap::move_meter (MeterSection& meter, const BBT_Time& when)
{
if (move_metric_section (meter, when) == 0) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
}
if (removed) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
}
if (removed) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
do_insert (new TempoSection (where, tempo.beats_per_minute(), tempo.note_type()), true);
}
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
void
do_insert (new TempoSection (where, tempo.beats_per_minute(), tempo.note_type()), false);
}
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
void
}
if (replaced) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
do_insert (new MeterSection (where, meter.beats_per_bar(), meter.note_divisor()), true);
}
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
void
do_insert (new MeterSection (where, meter.beats_per_bar(), meter.note_divisor()), false);
}
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
void
}
if (replaced) {
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
}
for (Metrics::iterator i = metrics->begin(); i != metrics->end(); ++i) {
if ((t = dynamic_cast<TempoSection*> (*i)) != 0) {
*((Tempo*) t) = newtempo;
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
break;
}
}
/* reset */
*((Tempo*)prev) = newtempo;
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
const MeterSection&
}
}
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
return 0;
}
timestamp_metrics (false);
- StateChanged (Change (0));
+ StateChanged (PropertyChange (0));
}
BBT_Time
return;
}
- if (_route_group && src != _route_group && _route_group->active_property (RouteGroup::RecEnable)) {
+ if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_recenable()) {
_route_group->apply (&Track::set_record_enable, yn, _route_group);
return;
}
'quantize.cc',
'rc_configuration.cc',
'recent_sessions.cc',
- 'region.cc',
- 'region_command.cc',
'region_factory.cc',
'resampled_source.cc',
+ 'region.cc',
'return.cc',
'reverse.cc',
'route.cc',
'session_handle.cc',
'session_metadata.cc',
'session_midi.cc',
+ 'session_object.cc',
'session_playlists.cc',
'session_process.cc',
'session_rtevents.cc',
#define MIDI_CMD_NOTE_OFF 0x80 /**< Note Off */
#define MIDI_CMD_NOTE_ON 0x90 /**< Note On */
#define MIDI_CMD_NOTE_PRESSURE 0xA0 /**< Key Pressure */
-#define MIDI_CMD_CONTROL 0xB0 /**< Control Change */
-#define MIDI_CMD_PGM_CHANGE 0xC0 /**< Program Change */
+#define MIDI_CMD_CONTROL 0xB0 /**< Control PropertyChange */
+#define MIDI_CMD_PGM_CHANGE 0xC0 /**< Program PropertyChange */
#define MIDI_CMD_CHANNEL_PRESSURE 0xD0 /**< Channel Pressure */
#define MIDI_CMD_BENDER 0xE0 /**< Pitch Bender */
#define MIDI_CMD_COMMON_SYSEX 0xF0 /**< Sysex (System Exclusive) Begin */
* adding the event (using smf_track_add_event_seconds(), smf_track_add_event_pulses() or
* smf_track_add_event_delta_pulses()); the remaining two values are computed from that.
*
- * Tempo related stuff happens automatically - when you add a metaevent that is Tempo Change or
- * Time Signature, libsmf adds that event to the tempo map. If you remove Tempo Change event
+ * Tempo related stuff happens automatically - when you add a metaevent that is Tempo PropertyChange or
+ * Time Signature, libsmf adds that event to the tempo map. If you remove Tempo PropertyChange event
* that is in the middle of the song, the rest of the events will have their event->time_seconds
* recomputed from event->time_pulses before smf_event_remove_from_track() function returns.
- * Adding Tempo Change in the middle of the song works in a similar way.
+ * Adding Tempo PropertyChange in the middle of the song works in a similar way.
*
* MIDI data (event->midi_buffer) is always kept in normalized form - it always begins with
* status byte (no running status), there are no System Realtime events embedded in them etc.
case MIDI_CMD_NOTE_PRESSURE:
return "Key Pressure"; break;
case MIDI_CMD_CONTROL:
- return "Control Change"; break;
+ return "Control PropertyChange"; break;
case MIDI_CMD_PGM_CHANGE:
- return "Program Change"; break;
+ return "Program PropertyChange"; break;
case MIDI_CMD_CHANNEL_PRESSURE:
return "Channel Pressure"; break;
case MIDI_CMD_BENDER:
*o << trace_prefix
<< "Channel "
<< (msg[0]&0xF)+1
- << " Program Change ProgNum "
+ << " Program PropertyChange ProgNum "
<< (int) msg[1]
<< endmsg;
break;
#define __pbd_properties_h__
#include <string>
+#include <sstream>
#include <list>
-#include <glib/glib.h>
+#include <glib.h>
-class XMLNode;
+#include "pbd/xml++.h"
namespace PBD {
enum PropertyChange {
- range_guarantee = ~0
+ range_guarantee = ~0ULL
};
PropertyChange new_change ();
+typedef GQuark PropertyID;
+
+template<typename T>
+struct PropertyDescriptor {
+ PropertyID id;
+ typedef T value_type;
+};
+
/** Base (non template) part of Property */
class PropertyBase
{
public:
- PropertyBase (GQuark quark, PropertyChange c)
+ PropertyBase (PropertyID pid, PropertyChange c)
: _have_old (false)
- , _property_quark (q)
+ , _property_id (pid)
, _change (c)
{
}
virtual void diff (XMLNode *, XMLNode *) const = 0;
+ virtual void diff (PropertyChange&) const = 0;
virtual PropertyChange set_state (XMLNode const &) = 0;
virtual void add_state (XMLNode &) const = 0;
- std::string property_name() const { return g_quark_to_string (_property_quark); }
+ const gchar* property_name() const { return g_quark_to_string (_property_id); }
PropertyChange change() const { return _change; }
+ PropertyID id() const { return _property_id; }
- bool operator== (GQuark q) const {
- return _property_quark == q;
+ bool operator== (PropertyID pid) const {
+ return _property_id == pid;
}
protected:
bool _have_old;
- GQuark _property_quark;
+ PropertyID _property_id;
PropertyChange _change;
};
class PropertyTemplate : public PropertyBase
{
public:
- PropertyTemplate (GQuark q, PropertyChange c, T const & v)
- : PropertyBase (q, c)
+ PropertyTemplate (PropertyDescriptor<T> p, PropertyChange c, T const & v)
+ : PropertyBase (p.id, c)
, _current (v)
{
}
-
PropertyTemplate<T> & operator= (PropertyTemplate<T> const & s) {
/* XXX: isn't there a nicer place to do this? */
_have_old = s._have_old;
- _property_quark = s._property_quark;
+ _property_id = s._property_id;
_change = s._change;
_current = s._current;
void diff (XMLNode* old, XMLNode* current) const {
if (_have_old) {
- old->add_property (g_quark_to_string (_property_quark), to_string (_old));
- current->add_property (g_quark_to_string (_property_quark), to_string (_current));
+ old->add_property (g_quark_to_string (_property_id), to_string (_old));
+ current->add_property (g_quark_to_string (_property_id), to_string (_current));
+ }
+ }
+
+ void diff (PropertyChange& c) const {
+ if (_have_old && _change) {
+ c = PropertyChange (c | _change);
}
}
* @return PropertyChange effected, or 0.
*/
PropertyChange set_state (XMLNode const & node) {
- XMLProperty const * p = node.property (g_quark_to_string (_property_quark));
+ XMLProperty const * p = node.property (g_quark_to_string (_property_id));
+ PropertyChange c = PropertyChange (0);
if (p) {
T const v = from_string (p->value ());
- if (v == _current) {
- return PropertyChange (0);
+ if (v != _current) {
+ set (v);
+ c = _change;
}
-
- set (v);
- return _change;
}
- return PropertyChange (0);
+ return c;
}
void add_state (XMLNode & node) const {
- node.add_property (g_quark_to_string (_property_quark), to_string (_current));
+ node.add_property (g_quark_to_string (_property_id), to_string (_current));
}
protected:
class Property : public PropertyTemplate<T>
{
public:
- Property (GQuark q, PropertyChange c, T const & v)
+ Property (PropertyDescriptor<T> q, PropertyChange c, T const & v)
: PropertyTemplate<T> (q, c, v)
{
+ }
+
+ Property (PropertyDescriptor<T> q, T const & v)
+ : PropertyTemplate<T> (q, PropertyChange (0), v)
+ {
+
}
T & operator= (T const & v) {
}
private:
- std::string to_string (T const & v) const {
- // XXX LocaleGuard
+ /* note that we do not set a locale for the streams used
+ in to_string() or from_string(), because we want the
+ format to be portable across locales (i.e. C or
+ POSIX). Also, there is the small matter of
+ std::locale aborting on OS X if used with anything
+ other than C or POSIX locales.
+ */
+ std::string to_string (T const & v) const {
std::stringstream s;
s.precision (12); // in case its floating point
s << v;
}
T from_string (std::string const & s) const {
- // XXX LocaleGuard
std::stringstream t (s);
T v;
- t.precision (12); // in case its floating point
t >> v;
return v;
}
};
+class PropertyList : public std::map<PropertyID,PropertyBase*>
+{
+public:
+ PropertyList() : property_owner (true) {}
+ virtual ~PropertyList() {
+ if (property_owner)
+ for (std::map<PropertyID,PropertyBase*>::iterator i = begin(); i != end(); ++i) {
+ delete i->second;
+ }
+ }
+ /* classes that own property lists use this to add their
+ property members to their plists.
+ */
+ bool add (PropertyBase& p) {
+ return insert (value_type (p.id(), &p)).second;
+ }
+
+ /* code that is constructing a property list for use
+ in setting the state of an object uses this.
+ */
+ template<typename T, typename V> bool add (PropertyDescriptor<T> pid, const V& v) {
+ return insert (value_type (pid.id, new Property<T> (pid, (T) v))).second;
+ }
+
+protected:
+ bool property_owner;
+};
+
+/** A variant of PropertyList that does not delete its
+ property list in its destructor. Objects with their
+ own Properties store them in an OwnedPropertyList
+ to avoid having them deleted at the wrong time.
+*/
+
+class OwnedPropertyList : public PropertyList
+{
+public:
+ OwnedPropertyList() { property_owner = false; }
+};
+
} /* namespace PBD */
#endif /* __pbd_properties_h__ */
#define __pbd_stateful_h__
#include <string>
+#include <list>
#include <cassert>
#include "pbd/id.h"
#include "pbd/xml++.h"
#include "pbd/enumwriter.h"
+#include "pbd/properties.h"
class XMLNode;
class path;
}
-enum Change {
- range_guarantee = ~0
-};
-
-Change new_change ();
-
-/** Base (non template) part of State */
-class StateBase
-{
-public:
- StateBase (std::string const & p, Change c)
- : _have_old (false)
- , _xml_property_name (p)
- , _change (c)
- {
-
- }
-
- /** Forget about any old value for this state */
- void clear_history () {
- _have_old = false;
- }
-
- virtual void diff (XMLNode *, XMLNode *) const = 0;
- virtual Change set_state (XMLNode const &) = 0;
- virtual void add_state (XMLNode &) const = 0;
-
-protected:
- bool _have_old;
- std::string _xml_property_name;
- Change _change;
-};
-
-/** Parent class for classes which represent a single piece of state in a Stateful object */
-template <class T>
-class StateTemplate : public StateBase
-{
-public:
- StateTemplate (std::string const & p, Change c, T const & v)
- : StateBase (p, c)
- , _current (v)
- {
-
- }
-
- StateTemplate<T> & operator= (StateTemplate<T> const & s) {
- /* XXX: isn't there a nicer place to do this? */
- _have_old = s._have_old;
- _xml_property_name = s._xml_property_name;
- _change = s._change;
-
- _current = s._current;
- _old = s._old;
- return *this;
- }
-
- T & operator= (T const & v) {
- set (v);
- return _current;
- }
-
- T & operator+= (T const & v) {
- set (_current + v);
- return _current;
- }
-
- bool operator== (const T& other) const {
- return _current == other;
- }
-
- bool operator!= (const T& other) const {
- return _current != other;
- }
-
- operator T const & () const {
- return _current;
- }
-
- T const & val () const {
- return _current;
- }
-
- void diff (XMLNode* old, XMLNode* current) const {
- if (_have_old) {
- old->add_property (_xml_property_name.c_str(), to_string (_old));
- current->add_property (_xml_property_name.c_str(), to_string (_current));
- }
- }
-
- /** Try to set state from the property of an XML node.
- * @param node XML node.
- * @return Change effected, or 0.
- */
- Change set_state (XMLNode const & node) {
- XMLProperty const * p = node.property (_xml_property_name.c_str());
-
- if (p) {
- T const v = from_string (p->value ());
-
- if (v == _current) {
- return Change (0);
- }
-
- set (v);
- return _change;
- }
-
- return Change (0);
- }
-
- void add_state (XMLNode & node) const {
- node.add_property (_xml_property_name.c_str(), to_string (_current));
- }
-
-protected:
- void set (T const & v) {
- _old = _current;
- _have_old = true;
- _current = v;
- }
-
- virtual std::string to_string (T const & v) const = 0;
- virtual T from_string (std::string const & s) const = 0;
-
- T _current;
- T _old;
-};
-
-template<class T>
-std::ostream& operator<< (std::ostream& os, StateTemplate<T> const & s)
-{
- os << s.val();
- return os;
-}
-
-/** Representation of a single piece of state in a Stateful; for use
- * with types that can be written to / read from stringstreams.
- */
-template <class T>
-class State : public StateTemplate<T>
-{
-public:
- State (std::string const & p, Change c, T const & v)
- : StateTemplate<T> (p, c, v)
- {
-
- }
-
- T & operator= (T const & v) {
- this->set (v);
- return this->_current;
- }
-
-private:
- std::string to_string (T const & v) const {
- std::stringstream s;
- s.precision (12); // in case its floating point
- s << v;
- return s.str ();
- }
-
- T from_string (std::string const & s) const {
- std::stringstream t (s);
- T v;
- t.precision (12); // in case its floating point
- t >> v;
- return v;
- }
-};
-
-template <class T>
-class EnumState : public StateTemplate<T>
-{
-public:
- EnumState (std::string const & p, Change c, T const & v)
- : StateTemplate<T> (p, c, v)
- {
-
- }
-
- T & operator= (T const & v) {
- this->set (v);
- return this->_current;
- }
-
-private:
- std::string to_string (T const & v) const {
- return enum_2_string (v);
- }
-
- T from_string (std::string const & v) const {
- return T (string_2_enum (v, this->_current));
- }
-};
-
/** Base class for objects with saveable and undoable state */
class Stateful {
public:
virtual ~Stateful();
virtual XMLNode& get_state (void) = 0;
-
virtual int set_state (const XMLNode&, int version) = 0;
+ /* derived types do not have to implement this, but probably should
+ give it serious attention.
+ */
+ virtual PropertyChange set_property (const PropertyBase&) { return PropertyChange (0); }
- void add_state (StateBase & s) {
- _states.push_back (&s);
+ PropertyChange set_properties (const PropertyList&);
+
+ void add_property (PropertyBase& s) {
+ _properties.add (s);
}
- /* Extra XML nodes */
+ /* Extra XML node: so that 3rd parties can attach state to the XMLNode
+ representing the state of this object.
+ */
void add_extra_xml (XMLNode&);
XMLNode *extra_xml (const std::string& str);
const PBD::ID& id() const { return _id; }
void clear_history ();
- std::pair<XMLNode *, XMLNode*> diff ();
+ std::pair<XMLNode *, XMLNode*> diff () const;
+ void changed (PropertyChange&) const;
static int current_state_version;
static int loading_state_version;
void add_instant_xml (XMLNode&, const sys::path& directory_path);
XMLNode *instant_xml (const std::string& str, const sys::path& directory_path);
- Change set_state_using_states (XMLNode const &);
- void add_states (XMLNode &);
+ void add_properties (XMLNode &);
+ /* derived types can call this from ::set_state() (or elsewhere)
+ to get basic property setting done.
+ */
+ PropertyChange set_properties (XMLNode const &);
+
+
+ /* derived classes can implement this to do cross-checking
+ of property values after either a PropertyList or XML
+ driven property change.
+ */
+ virtual void post_set () { };
XMLNode *_extra_xml;
XMLNode *_instant_xml;
PBD::ID _id;
std::string _xml_node_name; ///< name of node to use for this object in XML
- std::list<StateBase*> _states; ///< state variables that this object has
+ OwnedPropertyList _properties;
};
} // namespace PBD
*/
+#include <stdint.h>
+
#include "pbd/properties.h"
#include "pbd/error.h"
using namespace PBD;
PropertyChange
-new_change ()
+PBD::new_change ()
{
static uint64_t change_bit = 1;
int Stateful::current_state_version = 0;
int Stateful::loading_state_version = 0;
-PBD::Change
-new_change ()
-{
- Change c;
- static uint32_t change_bit = 1;
-
- /* catch out-of-range */
- if (!change_bit)
- {
- fatal << _("programming error: ")
- << "change_bit out of range in ARDOUR::new_change()"
- << endmsg;
- /*NOTREACHED*/
- }
-
- c = Change (change_bit);
- change_bit <<= 1; // if it shifts too far, change_bit == 0
-
- return c;
-}
-
Stateful::Stateful ()
{
_extra_xml = 0;
void
Stateful::clear_history ()
{
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->clear_history ();
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->clear_history ();
}
}
* It is the caller's responsibility to delete the returned XMLNodes.
*/
pair<XMLNode *, XMLNode *>
-Stateful::diff ()
+Stateful::diff () const
{
XMLNode* old = new XMLNode (_xml_node_name);
XMLNode* current = new XMLNode (_xml_node_name);
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->diff (old, current);
+ for (OwnedPropertyList::const_iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->diff (old, current);
}
return make_pair (old, current);
}
+
+/** Modifies PropertyChange @param c to indicate what properties have changed since the last
+ time clear_history was called on this object. Note that not all properties have change
+ values - if this object has any such Property members, they will never show up in
+ the value of @param c. Note also that @param c is not cleared by this function.
+*/
+void
+Stateful::changed (PropertyChange& c) const
+{
+ for (OwnedPropertyList::const_iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->diff (c);
+ }
+}
-/** Set state of _states from an XML node.
+/** Set state of some/all _properties from an XML node.
* @param node Node.
- * @return Changes made.
+ * @return PropertyChanges made.
*/
-Change
-Stateful::set_state_using_states (XMLNode const & node)
+PropertyChange
+Stateful::set_properties (XMLNode const & node)
{
- Change c = Change (0);
-
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- c = Change (c | (*i)->set_state (node));
+ PropertyChange c = PropertyChange (0);
+
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ c = PropertyChange (c | i->second->set_state (node));
+ }
+
+ post_set ();
+
+ return c;
+}
+
+PropertyChange
+Stateful::set_properties (const PropertyList& property_list)
+{
+ PropertyChange c = PropertyChange (0);
+ PropertyList::const_iterator p;
+
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ if ((p = property_list.find (i->first)) != property_list.end()) {
+ c = PropertyChange (c|set_property (*(p->second)));
+ }
}
+
+ post_set ();
return c;
}
-/** Add state of _states to an XML node.
+
+/** Add property states to an XML node.
* @param node Node.
*/
void
-Stateful::add_states (XMLNode & node)
+Stateful::add_properties (XMLNode & node)
{
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->add_state (node);
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->add_state (node);
}
}
mountpoint.cc
pathscanner.cc
pool.cc
+ property.cc
pthread_utils.cc
receiver.cc
search_path.cc
#!/bin/sh
-. ../gtk2_ardour/ardev_common.sh
-
+. `dirname "$0"`/../build/default/gtk2_ardour/ardev_common_waf.sh
export LD_LIBRARY_PATH=$TOP/gtk2_ardour:$LD_LIBRARY_PATH
exec wine $TOP/vst/ardour_vst.exe.so "$@"