本文整理汇总了C++中Breakpoint::setPhase方法的典型用法代码示例。如果您正苦于以下问题:C++ Breakpoint::setPhase方法的具体用法?C++ Breakpoint::setPhase怎么用?C++ Breakpoint::setPhase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Breakpoint
的用法示例。
在下文中一共展示了Breakpoint::setPhase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matchPhaseFwd
// ---------------------------------------------------------------------------
// matchPhaseFwd
//
//! Compute the target frequency that will affect the
//! predicted (by the Breakpoint phases) amount of
//! sinusoidal phase travel between two breakpoints,
//! and assign that frequency to the target Breakpoint.
//! After computing the new frequency, update the phase of
//! the later Breakpoint.
//!
//! If the earlier Breakpoint is null and the later one
//! is non-null, then update the phase of the earlier
//! Breakpoint, and do not modify its frequency or the
//! later Breakpoint.
//!
//! The most common kinds of errors are local (or burst) errors in
//! frequency and phase. These errors are best corrected by correcting
//! less than half the detected error at any time. Correcting more
//! than that will produce frequency oscillations for the remainder of
//! the Partial, in the case of a single bad frequency (as is common
//! at the onset of a tone). Any damping factor less then one will
//! converge eventually, .5 or less will converge without oscillating.
//! Use the damping argument to control the damping of the correction.
//! Specify 1 for no damping.
//!
//! \pre The two Breakpoints are assumed to be consecutive in
//! a Partial.
//! \param bp0 The earlier Breakpoint.
//! \param bp1 The later Breakpoint.
//! \param dt The time (in seconds) between bp0 and bp1.
//! \param damping The fraction of the amount of phase error that will
//! be corrected (.5 or less will prevent frequency oscilation
//! due to burst errors in phase).
//! \param maxFixPct The maximum amount of frequency adjustment
//! that can be made to the frequency of bp1, expressed
//! as a precentage of the unmodified frequency of bp1.
//! If the necessary amount of frequency adjustment exceeds
//! this amount, then the phase will not be matched,
//! but will be updated as well to be consistent with
//! the frequencies. (default is 0.2%)
//
void matchPhaseFwd( Breakpoint & bp0, Breakpoint & bp1,
double dt, double damping, double maxFixPct )
{
double travel = phaseTravel( bp0, bp1, dt );
if ( ! BreakpointUtils::isNonNull( bp1 ) )
{
// if bp1 is null, just compute a new phase,
// no need to match it.
bp1.setPhase( wrapPi( bp0.phase() + travel ) );
}
else if ( ! BreakpointUtils::isNonNull( bp0 ) )
{
// if bp0 is null, and bp1 is not, then bp0
// should be a phase reset Breakpoint during
// rendering, so compute a new phase for
// bp0 that achieves bp1's phase.
bp0.setPhase( wrapPi( bp1.phase() - travel ) ) ;
}
else
{
// invariant:
// neither bp0 nor bp1 is null
//
// modify frequecies to match phases as nearly as possible
double err = wrapPi( bp1.phase() - ( bp0.phase() + travel ) );
// The most common kinds of errors are local (or burst) errors in
// frequency and phase. These errors are best corrected by correcting
// less than half the detected error at any time. Correcting more
// than that will produce frequency oscillations for the remainder of
// the Partial, in the case of a single bad frequency (as is common
// at the onset of a tone). Any damping factor less then one will
// converge eventually, .5 or less will converge without oscillating.
// #define DAMPING .5
travel += damping * err;
double f0 = bp0.frequency();
double ftgt = ( travel / ( Pi * dt ) ) - f0;
#ifdef Loris_Debug
debugger << "matchPhaseFwd: correcting " << bp1.frequency() << " to " << ftgt
<< " (phase " << wrapPi( bp1.phase() ) << "), ";
#endif
// If the target is not a null breakpoint, may need to
// clamp the amount of frequency modification.
//
// Actually, should probably always clamp the amount
// of modulation, should never have arbitrarily large
// frequency adjustments.
//
// Really, should never call this function if bp1
// is a null Breakpoint, because we don't care about
// those phases in Loris.
if ( true ) // bp1.amplitude() != 0. )
{
if ( ftgt > bp1.frequency() * ( 1 + (maxFixPct*.01) ) )
{
//.........这里部分代码省略.........