本文整理汇总了C++中Partial::bandwidthAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Partial::bandwidthAt方法的具体用法?C++ Partial::bandwidthAt怎么用?C++ Partial::bandwidthAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partial
的用法示例。
在下文中一共展示了Partial::bandwidthAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
//! their Dilator, or Partials having Breakpoints before time 0, both
//! of which are probably unusual circumstances.)
//!
//! \param p is the Partial to dilate.
//
void
Dilator::dilate( Partial & p ) const
{
debugger << "dilating Partial having " << p.numBreakpoints()
<< " Breakpoints" << endl;
// sanity check:
Assert( _initial.size() == _target.size() );
// don't dilate if there's no time points, or no Breakpoints:
if ( 0 == _initial.size() ||
0 == p.numBreakpoints() )
{
return;
}
// create the new Partial:
Partial newp;
newp.setLabel( p.label() );
// timepoint index:
int idx = 0;
for ( Partial::const_iterator iter = p.begin(); iter != p.end(); ++iter )
{
// find the first initial time point later
// than the currentTime:
double currentTime = iter.time();
idx = std::distance( _initial.begin(),
std::lower_bound( _initial.begin(), _initial.end(), currentTime ) );
Assert( idx == _initial.size() || currentTime <= _initial[idx] );
// compute a new time for the Breakpoint at pIter:
double newtime = 0;
if ( idx == 0 )
{
// all time points in _initial are later than
// the currentTime; stretch if no zero time
// point has been specified, otherwise, shift:
if ( _initial[idx] != 0. )
newtime = currentTime * _target[idx] / _initial[idx];
else
newtime = _target[idx] + (currentTime - _initial[idx]);
}
else if ( idx == _initial.size() )
{
// all time points in _initial are earlier than
// the currentTime; shift:
//
// note: size is already known to be > 0, so
// idx-1 is safe
newtime = _target[idx-1] + (currentTime - _initial[idx-1]);
}
else
{
// currentTime is between the time points at idx and
// idx-1 in _initial; shift and stretch:
//
// note: size is already known to be > 0, so
// idx-1 is safe
Assert( _initial[idx-1] < _initial[idx] ); // currentTime can't wind up
// between two equal times
double stretch = (_target[idx] - _target[idx-1]) / (_initial[idx] - _initial[idx-1]);
newtime = _target[idx-1] + ((currentTime - _initial[idx-1]) * stretch);
}
// add a Breakpoint at the computed time:
newp.insert( newtime, iter.breakpoint() );
}
// new Breakpoints need to be added to the Partial at times corresponding
// to all target time points that are after the first Breakpoint and
// before the last, otherwise, Partials may be briefly out of tune with
// each other, since our Breakpoints are non-uniformly distributed in time:
for ( idx = 0; idx < _initial.size(); ++ idx )
{
if ( _initial[idx] <= p.startTime() )
{
continue;
}
else if ( _initial[idx] >= p.endTime() )
{
break;
}
else
{
newp.insert( _target[idx],
Breakpoint( p.frequencyAt(_initial[idx]), p.amplitudeAt(_initial[idx]),
p.bandwidthAt(_initial[idx]), p.phaseAt(_initial[idx]) ) );
}
}
// store the new Partial:
p = newp;
}