Hi!
As suggested by David (with my full agreement :) ) I'm changing the name
maxLength to maxPosition, as the current name maxLength was too confusing...
Also I added a
void maxPosition(double maxPosition)
Maybe it should be setMaxPosition? I decided against it - the getter
isn't getMaxPosition, so the setter shouldn't be setMaxPosition either, or?
OK, so this is a totally boring patch, just thought I'd announce it, in
case anyone is using Segmentation objects :)
(Also added in the patch is a constructor without a parameter, as I want
the segmentation object to be available through a Port and then it
can't have any constructor parameters... or... the Big Question: or am I
missing something? )
with this the segmentation port on TonalAnalysis is just almost there, I
can almost see it now... :-)
... hopefully not yet another Fata Morgana ... ;-)
cheers!
roman
Index: CLAM/src/Data/Editable/ContiguousSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/ContiguousSegmentation.hxx (revision 10734)
+++ CLAM/src/Data/Editable/ContiguousSegmentation.hxx (working copy)
@@ -15,20 +15,20 @@
};
typedef std::vector<double> TimePositions;
public:
- ContiguousSegmentation(double maxLength)
- : Segmentation(maxLength)
+ ContiguousSegmentation(double maxPosition)
+ : Segmentation(maxPosition)
{
_onsets.push_back(0);
- _offsets.push_back(maxLength);
+ _offsets.push_back(maxPosition);
_selection.push_back(false);
}
template <typename Iterator>
- ContiguousSegmentation(double maxLength, Iterator begin, Iterator end)
- : Segmentation(maxLength)
+ ContiguousSegmentation(double maxPosition, Iterator begin, Iterator end)
+ : Segmentation(maxPosition)
{
_onsets.push_back(0);
- _offsets.push_back(maxLength);
+ _offsets.push_back(maxPosition);
_selection.push_back(false);
for (Iterator it=begin; it!=end; it++)
insert(*it);
Index: CLAM/src/Data/Editable/Segmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/Segmentation.hxx (revision 10734)
+++ CLAM/src/Data/Editable/Segmentation.hxx (working copy)
@@ -19,9 +19,9 @@
};
typedef std::vector<double> TimePositions;
public:
- Segmentation(double maxLength)
+ Segmentation(double maxPosition)
: _current(0)
- , _maxLength(maxLength)
+ , _maxPosition(maxPosition)
{
}
virtual ~Segmentation();
@@ -131,10 +131,14 @@
if (index>=_onsets.size()) return;
_current = index;
}
- double maxLength() const
+ double maxPosition() const
{
- return _maxLength;
+ return _maxPosition;
}
+ void maxPosition(double maxPosition)
+ {
+ _maxPosition = maxPosition;
+ }
void xUnits(const std::string & units)
{
_xUnits=units;
@@ -148,7 +152,7 @@
TimePositions _offsets;
std::vector<bool> _selection;
unsigned _current;
- double _maxLength;
+ double _maxPosition;
std::string _xUnits;
};
Index: CLAM/src/Data/Editable/UnsizedSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/UnsizedSegmentation.hxx (revision 10734)
+++ CLAM/src/Data/Editable/UnsizedSegmentation.hxx (working copy)
@@ -15,14 +15,14 @@
};
typedef std::vector<double> TimePositions;
public:
- UnsizedSegmentation(double maxLength)
- : Segmentation(maxLength)
+ UnsizedSegmentation(double maxPosition)
+ : Segmentation(maxPosition)
{
}
template <typename Iterator>
- UnsizedSegmentation(double maxLength, Iterator begin, Iterator end)
- : Segmentation(maxLength)
+ UnsizedSegmentation(double maxPosition, Iterator begin, Iterator end)
+ : Segmentation(maxPosition)
{
for (Iterator it=begin; it!=end; it++)
insert(*it);
@@ -36,7 +36,7 @@
unsigned insert(double timePosition)
{
if (timePosition<0.0) throw InsertedOutOfBounds();
- if (timePosition>=maxLength()) throw InsertedOutOfBounds();
+ if (timePosition>=maxPosition()) throw InsertedOutOfBounds();
TimePositions::iterator insertPoint =
std::lower_bound(_offsets.begin(), _offsets.end(), timePosition);
if (insertPoint==_offsets.end())
@@ -121,7 +121,7 @@
double leftLimit = segment!=0 ?
_onsets[segment-1] : 0.0;
double rightLimit = segment+1<_offsets.size()?
- _onsets[segment+1] : maxLength();
+ _onsets[segment+1] : maxPosition();
if (newTimePosition<leftLimit)
newTimePosition = leftLimit;
// Limit movement on the right to the next offset
Index: CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx (revision 10734)
+++ CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx (working copy)
@@ -54,18 +54,18 @@
};
typedef std::vector<double> TimePositions;
public:
- DiscontinuousSegmentation(double maxLength)
- : Segmentation(maxLength)
+ DiscontinuousSegmentation(double maxPosition)
+ : Segmentation(maxPosition)
{
}
/**
* It will create a discontinuous segmentation where the onsets and offsets
* are specified on the ordered list of bounds [begin,end)
- * @pre The onsets is a sorted container of bounds in between 0 and maxLength
+ * @pre The onsets is a sorted container of bounds in between 0 and maxPosition
*/
template <typename Iterator>
- DiscontinuousSegmentation(double maxLength, Iterator begin, Iterator end)
- : Segmentation(maxLength)
+ DiscontinuousSegmentation(double maxPosition, Iterator begin, Iterator end)
+ : Segmentation(maxPosition)
{
double previousOffset=0.0;
unsigned i=0;
@@ -76,7 +76,7 @@
if (it==end) throw OffsetMissing();
double offset = *it++;
if (offset<onset) throw MissplacedOffset(i, onset, offset);
- if (offset>maxLength) throw InsertedOutOfBounds();
+ if (offset>maxPosition) throw InsertedOutOfBounds();
_onsets.push_back(onset);
_offsets.push_back(offset);
_selection.push_back(false);
@@ -89,13 +89,13 @@
unsigned insert(double timePosition)
{
if (timePosition<0.0) throw InsertedOutOfBounds();
- if (timePosition>_maxLength) throw InsertedOutOfBounds();
+ if (timePosition>_maxPosition) throw InsertedOutOfBounds();
TimePositions::iterator nextOffset =
std::lower_bound(_offsets.begin(), _offsets.end(), timePosition);
if (nextOffset == _offsets.end()) // Beyond any existing segment
{
_onsets.push_back(timePosition);
- _offsets.push_back(_maxLength);
+ _offsets.push_back(_maxPosition);
_selection.push_back(false);
return _onsets.size()-1;
}
@@ -197,7 +197,7 @@
if (segment>=_offsets.size()) return; // Invalid segment
// Limit to the right to the next offset or max
- double rigthBound = segment+1==_offsets.size()? _maxLength : _onsets[segment+1];
+ double rigthBound = segment+1==_offsets.size()? _maxPosition : _onsets[segment+1];
if (newTimePosition>rigthBound)
newTimePosition=rigthBound;
// Limit to the left to the own onset
Index: CLAM/src/Data/Editable/ContiguousSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/ContiguousSegmentation.hxx (revision 10738)
+++ CLAM/src/Data/Editable/ContiguousSegmentation.hxx (working copy)
@@ -15,6 +15,10 @@
};
typedef std::vector<double> TimePositions;
public:
+ ContiguousSegmentation()
+ : Segmentation(0)
+ {
+ }
ContiguousSegmentation(double maxPosition)
: Segmentation(maxPosition)
{
Index: CLAM/src/Data/Editable/Segmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/Segmentation.hxx (revision 10738)
+++ CLAM/src/Data/Editable/Segmentation.hxx (working copy)
@@ -19,6 +19,11 @@
};
typedef std::vector<double> TimePositions;
public:
+ Segmentation()
+ : _current(0)
+ , _maxPosition(0)
+ {
+ }
Segmentation(double maxPosition)
: _current(0)
, _maxPosition(maxPosition)
Index: CLAM/src/Data/Editable/UnsizedSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/UnsizedSegmentation.hxx (revision 10738)
+++ CLAM/src/Data/Editable/UnsizedSegmentation.hxx (working copy)
@@ -15,10 +15,13 @@
};
typedef std::vector<double> TimePositions;
public:
+ UnsizedSegmentation()
+ : Segmentation(0)
+ {
+ }
UnsizedSegmentation(double maxPosition)
: Segmentation(maxPosition)
{
-
}
template <typename Iterator>
UnsizedSegmentation(double maxPosition, Iterator begin, Iterator end)
Index: CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx
===================================================================
--- CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx (revision 10738)
+++ CLAM/src/Data/Editable/DiscontinuousSegmentation.hxx (working copy)
@@ -54,6 +54,10 @@
};
typedef std::vector<double> TimePositions;
public:
+ DiscontinuousSegmentation()
+ : Segmentation(0)
+ {
+ }
DiscontinuousSegmentation(double maxPosition)
: Segmentation(maxPosition)
{
_______________________________________________
Clam-devel mailing list
[email protected]
https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel