summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-07-06 11:33:27 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-07-06 11:33:27 +0000
commit2f9184d65395da75a43ea21ffb5f11b8d577d27a (patch)
treea50a5d5a4bd8b09ca9bd1f3bb6754b7bf86cd3c5 /libs
parent2f11b367cac5fe05f5f69e2c73946312d8145260 (diff)
beat slicing patch #1 from lincoln spiteri
git-svn-id: svn://localhost/ardour2/branches/3.0@7381 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audioregion.h6
-rw-r--r--libs/ardour/ardour/region.h30
-rw-r--r--libs/ardour/audioregion.cc62
-rw-r--r--libs/ardour/playlist.cc14
-rw-r--r--libs/ardour/region.cc27
-rw-r--r--libs/ardour/session.cc44
6 files changed, 146 insertions, 37 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 0a3e53039e..5843d6f753 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -176,7 +176,13 @@ class AudioRegion : public Region
void resume_fade_in ();
void resume_fade_out ();
+ void add_transient (nframes64_t where);
+ void remove_transient (nframes64_t where);
+ int set_transients (AnalysisFeatureList&);
int get_transients (AnalysisFeatureList&, bool force_new = false);
+ int update_transient (nframes64_t old_position, nframes64_t new_position);
+ int adjust_transients (nframes64_t delta);
+
std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t, InterThreadInfo&) const;
private:
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index 8bc1612fbc..3dab0f46de 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -52,6 +52,7 @@ namespace Properties {
extern PBD::PropertyDescriptor<bool> right_of_split;
extern PBD::PropertyDescriptor<bool> hidden;
extern PBD::PropertyDescriptor<bool> position_locked;
+ extern PBD::PropertyDescriptor<bool> valid_transients;
extern PBD::PropertyDescriptor<framepos_t> start;
extern PBD::PropertyDescriptor<framecnt_t> length;
extern PBD::PropertyDescriptor<framepos_t> position;
@@ -95,6 +96,8 @@ class Region
bool set_name (const std::string& str);
const DataType& data_type() const { return _type; }
+
+ AnalysisFeatureList transients () { return _transients; };
/** How the region parameters play together:
*
@@ -137,6 +140,7 @@ class Region
bool opaque () const { return _opaque; }
bool locked() const { return _locked; }
bool position_locked() const { return _position_locked; }
+ bool valid_transients() const { return _valid_transients; }
bool automatic() const { return _automatic; }
bool whole_file() const { return _whole_file; }
bool captured() const { return !(_import || _external); }
@@ -245,12 +249,35 @@ class Region
virtual int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&) = 0;
+ virtual void add_transient (nframes64_t where) {
+ // no transients, but its OK
+ }
+
+ virtual int update_transient (nframes64_t old_position, nframes64_t new_position) {
+ // no transients, but its OK
+ return 0;
+ }
+
+ virtual void remove_transient (nframes64_t where) {
+ // no transients, but its OK
+ }
+
+ virtual int set_transients (AnalysisFeatureList&) {
+ // no transients, but its OK
+ return 0;
+ }
+
virtual int get_transients (AnalysisFeatureList&, bool force_new = false) {
(void) force_new;
// no transients, but its OK
return 0;
}
+ virtual int adjust_transients (nframes64_t delta) {
+ // no transients, but its OK
+ return 0;
+ }
+
virtual int separate_by_channel (ARDOUR::Session&,
std::vector< boost::shared_ptr<Region> >&) const {
return 0;
@@ -317,6 +344,7 @@ class Region
PBD::Property<bool> _right_of_split;
PBD::Property<bool> _hidden;
PBD::Property<bool> _position_locked;
+ PBD::Property<bool> _valid_transients;
PBD::Property<framepos_t> _start;
PBD::Property<framecnt_t> _length;
PBD::Property<framepos_t> _position;
@@ -333,7 +361,7 @@ class Region
mutable RegionEditState _first_edit;
BBT_Time _bbt_time;
AnalysisFeatureList _transients;
- bool _valid_transients;
+
mutable uint64_t _read_data_count; ///< modified in read()
uint64_t _last_layer_op; ///< timestamp
SourceList _sources;
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 80f8baef0e..5f8b35256b 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -101,15 +101,14 @@ AudioRegion::register_properties ()
, _fade_in_active (Properties::fade_in_active, true) \
, _fade_out_active (Properties::fade_out_active, true) \
, _scale_amplitude (Properties::scale_amplitude, 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)
-
+ , _scale_amplitude (other->_scale_amplitude)
/* a Session will reset these to its chosen defaults by calling AudioRegion::set_default_fade() */
void
@@ -1265,6 +1264,63 @@ AudioRegion::audio_source (uint32_t n) const
return boost::dynamic_pointer_cast<AudioSource>(source(n));
}
+int
+AudioRegion::adjust_transients (nframes64_t delta)
+{
+ for (AnalysisFeatureList::iterator x = _transients.begin(); x != _transients.end(); ++x) {
+ (*x) = (*x) + delta;
+ }
+
+ send_change (PropertyChange (Properties::valid_transients));
+
+ return 0;
+}
+
+int
+AudioRegion::update_transient (nframes64_t old_position, nframes64_t new_position)
+{
+ for (AnalysisFeatureList::iterator x = _transients.begin(); x != _transients.end(); ++x) {
+ if ((*x) == old_position) {
+ (*x) = new_position;
+ send_change (PropertyChange (Properties::valid_transients));
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+void
+AudioRegion::add_transient (nframes64_t where)
+{
+ _transients.push_back(where);
+ _valid_transients = true;
+
+ send_change (PropertyChange (Properties::valid_transients));
+}
+
+void
+AudioRegion::remove_transient (nframes64_t where)
+{
+ _transients.remove(where);
+ _valid_transients = true;
+
+ send_change (PropertyChange (Properties::valid_transients));
+}
+
+int
+AudioRegion::set_transients (AnalysisFeatureList& results)
+{
+ _transients.clear();
+ _transients = results;
+ _valid_transients = true;
+
+ send_change (PropertyChange (Properties::valid_transients));
+
+ return 0;
+}
+
int
AudioRegion::get_transients (AnalysisFeatureList& results, bool force_new)
{
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index cc9dc62ec7..20d771c692 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -696,7 +696,7 @@ Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, flo
framepos_t pos = position;
if (times == 1 && auto_partition){
- partition(pos, (pos + region->length()), true);
+ partition((nframes_t) pos - 1, (nframes_t) (pos + region->length()), true);
}
if (itimes >= 1) {
@@ -869,9 +869,7 @@ Playlist::remove_region_internal (boost::shared_ptr<Region> region)
}
}
- /* XXX and thaw ... */
-
- return ret;
+ return -1;
}
void
@@ -1284,7 +1282,7 @@ Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, floa
RegionLock rl (this);
int itimes = (int) floor (times);
- framepos_t pos = position;
+ nframes_t pos = position + 1;
while (itimes--) {
boost::shared_ptr<Region> copy = RegionFactory::create (region);
@@ -2094,6 +2092,7 @@ Playlist::find_next_region_boundary (framepos_t frame, int dir)
return ret;
}
+
/***********************************************************************/
@@ -2257,7 +2256,7 @@ Playlist::set_state (const XMLNode& node, int version)
error << _("Playlist: cannot create region from XML") << endmsg;
continue;
}
-
+
add_region (region, region->position(), 1.0);
// So that layer_op ordering doesn't get screwed up
@@ -2300,7 +2299,7 @@ XMLNode&
Playlist::state (bool full_state)
{
XMLNode *node = new XMLNode (X_("Playlist"));
- char buf[64];
+ char buf[64] = "";
node->add_property (X_("id"), id().to_s());
node->add_property (X_("name"), _name);
@@ -2312,6 +2311,7 @@ Playlist::state (bool full_state)
if (full_state) {
RegionLock rlock (this, false);
+
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
node->add_child_nocopy ((*i)->get_state());
}
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 64c7d8c66a..9d8e4e8ca0 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -59,6 +59,7 @@ namespace ARDOUR {
PBD::PropertyDescriptor<bool> right_of_split;
PBD::PropertyDescriptor<bool> hidden;
PBD::PropertyDescriptor<bool> position_locked;
+ PBD::PropertyDescriptor<bool> valid_transients;
PBD::PropertyDescriptor<framepos_t> start;
PBD::PropertyDescriptor<framecnt_t> length;
PBD::PropertyDescriptor<framepos_t> position;
@@ -101,6 +102,8 @@ Region::make_property_quarks ()
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for hidden = %1\n", Properties::hidden.property_id));
Properties::position_locked.property_id = g_quark_from_static_string (X_("position-locked"));
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for position-locked = %1\n", Properties::position_locked.property_id));
+ Properties::valid_transients.property_id = g_quark_from_static_string (X_("valid-transients"));
+ DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for valid-transients = %1\n", Properties::valid_transients.property_id));
Properties::start.property_id = g_quark_from_static_string (X_("start"));
DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for start = %1\n", Properties::start.property_id));
Properties::length.property_id = g_quark_from_static_string (X_("length"));
@@ -140,6 +143,7 @@ Region::register_properties ()
add_property (_right_of_split);
add_property (_hidden);
add_property (_position_locked);
+ add_property (_valid_transients);
add_property (_start);
add_property (_length);
add_property (_position);
@@ -165,6 +169,7 @@ Region::register_properties ()
, _right_of_split (Properties::right_of_split, false) \
, _hidden (Properties::hidden, false) \
, _position_locked (Properties::position_locked, false) \
+ , _valid_transients (Properties::valid_transients, false) \
, _start (Properties::start, (s)) \
, _length (Properties::length, (l)) \
, _position (Properties::position, 0) \
@@ -189,6 +194,7 @@ Region::register_properties ()
, _right_of_split (other->_right_of_split) \
, _hidden (other->_hidden) \
, _position_locked (other->_position_locked) \
+ , _valid_transients (other->_valid_transients) \
, _start(other->_start) \
, _length(other->_length) \
, _position(other->_position) \
@@ -225,7 +231,6 @@ Region::Region (const SourceList& srcs)
, _last_length (0)
, _last_position (0)
, _first_edit (EditChangesNothing)
- , _valid_transients(false)
, _read_data_count(0)
, _last_layer_op (0)
, _pending_explicit_relayer (false)
@@ -254,7 +259,6 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset, boo
, _last_length (other->_last_length)
, _last_position(other->_last_position) \
, _first_edit (EditChangesNothing)
- , _valid_transients(false)
, _read_data_count(0)
, _last_layer_op (0)
, _pending_explicit_relayer (false)
@@ -360,7 +364,6 @@ Region::Region (boost::shared_ptr<const Region> other, const SourceList& srcs)
, _last_length (other->_last_length)
, _last_position (other->_last_position)
, _first_edit (EditChangesID)
- , _valid_transients (false)
, _read_data_count (0)
, _last_layer_op (other->_last_layer_op)
, _pending_explicit_relayer (false)
@@ -390,7 +393,6 @@ Region::Region (boost::shared_ptr<const Region> other)
, _last_length (other->_last_length)
, _last_position (other->_last_position)
, _first_edit (EditChangesID)
- , _valid_transients(false)
, _read_data_count(0)
, _last_layer_op(other->_last_layer_op)
, _pending_explicit_relayer (false)
@@ -609,13 +611,12 @@ Region::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
recompute_position_from_lock_style ();
}
- invalidate_transients ();
+ //invalidate_transients ();
}
/* do this even if the position is the same. this helps out
a GUI that has moved its representation already.
*/
-
send_change (Properties::position);
}
@@ -802,7 +803,8 @@ Region::modify_front (nframes_t new_position, bool reset_fade, void *src)
if (new_position < end) { /* can't trim it zero or negative length */
- nframes_t newlen;
+ nframes_t newlen = 0;
+ nframes64_t delta = 0;
/* can't trim it back passed where source position zero is located */
@@ -810,11 +812,14 @@ Region::modify_front (nframes_t new_position, bool reset_fade, void *src)
if (new_position > _position) {
newlen = _length - (new_position - _position);
+ delta = -1 * (new_position - _position);
} else {
newlen = _length + (_position - new_position);
+ delta = _position - new_position;
}
trim_to_internal (new_position, newlen, src);
+
if (reset_fade) {
_right_of_split = true;
}
@@ -822,6 +827,10 @@ Region::modify_front (nframes_t new_position, bool reset_fade, void *src)
if (!property_changes_suspended()) {
recompute_at_start ();
}
+
+ if (_transients.size() > 0){
+ adjust_transients(delta);
+ }
}
}
@@ -892,7 +901,6 @@ Region::trim_to_internal (framepos_t position, framecnt_t length, void */*src*/)
new_start = _start + start_shift;
}
-
} else if (start_shift < 0) {
if (_start < -start_shift) {
@@ -900,6 +908,7 @@ Region::trim_to_internal (framepos_t position, framecnt_t length, void */*src*/)
} else {
new_start = _start + start_shift;
}
+
} else {
new_start = _start;
}
@@ -1528,6 +1537,8 @@ Region::invalidate_transients ()
{
_valid_transients = false;
_transients.clear ();
+
+ send_change (PropertyChange (Properties::valid_transients));
}
void
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index dd6a453080..5e56b82e68 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -957,25 +957,33 @@ Session::handle_locations_changed (Locations::LocationList& locations)
void
Session::enable_record ()
{
- /* XXX really atomic compare+swap here */
- if (g_atomic_int_get (&_record_status) != Recording) {
- g_atomic_int_set (&_record_status, Recording);
- _last_record_location = _transport_frame;
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
-
- if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
-
- boost::shared_ptr<RouteList> rl = routes.reader ();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
- if (tr && tr->record_enabled ()) {
- tr->monitor_input (true);
- }
- }
- }
+ while (1) {
+ RecordState rs = (RecordState) g_atomic_int_get (&_record_status);
+
+ if (rs == Recording) {
+ break;
+ }
- RecordStateChanged ();
- }
+ if (g_atomic_int_compare_and_exchange (&_record_status, rs, Recording)) {
+
+ _last_record_location = _transport_frame;
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
+
+ if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
+
+ boost::shared_ptr<RouteList> rl = routes.reader ();
+ for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (tr && tr->record_enabled ()) {
+ tr->monitor_input (true);
+ }
+ }
+ }
+
+ RecordStateChanged ();
+ break;
+ }
+ }
}
void