當前位置: 首頁>>代碼示例>>C++>>正文


C++ Breakpoint::amplitude方法代碼示例

本文整理匯總了C++中Breakpoint::amplitude方法的典型用法代碼示例。如果您正苦於以下問題:C++ Breakpoint::amplitude方法的具體用法?C++ Breakpoint::amplitude怎麽用?C++ Breakpoint::amplitude使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Breakpoint的用法示例。


在下文中一共展示了Breakpoint::amplitude方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: accum_samples

// ---------------------------------------------------------------------------
//      accum_samples
// ---------------------------------------------------------------------------
//      helper
//
static void accum_samples( CSOUND * csound,
                           Oscillator & oscil, Breakpoint & bp,
                           double * bufbegin )
{
  if( bp.amplitude() > 0 || oscil.amplitude() > 0 )
    {
      double radfreq = radianFreq( csound, bp.frequency() );
      double amp = bp.amplitude();
      double bw = bp.bandwidth();

      //        initialize the oscillator if it is changing from zero
      //        to non-zero amplitude in this  control block:
      if ( oscil.amplitude() == 0. )
        {
          //    don't initialize with bogus values, Oscillator
          //    only guards against out-of-range target values
          //    in generateSamples(), parameter mutators are
          //    dangerous:

          if ( radfreq > PI )   //      don't alias
            amp = 0.;

          if ( bw > 1. )        //      clamp bandwidth
            bw = 1.;
          else if ( bw < 0. )
            bw = 0.;

#ifdef DEBUG_LORISGENS
        /*
          std::cerr << "initializing oscillator " << std::endl;
          std::cerr << "parameters: " << bp.frequency() << "  ";
          std::cerr << amp << "  " << bw << std::endl;
        */
#endif

          //    initialize frequency, amplitude, and bandwidth to
          //    their target values:
          /*
            oscil.setRadianFreq( radfreq );
            oscil.setAmplitude( amp );
            oscil.setBandwidth( bw );
          */
          oscil.resetEnvelopes( bp, (double) csound->esr );

          //    roll back the phase:
          oscil.resetPhase( bp.phase() - ( radfreq * (double) csound->ksmps ) );
        }

      //        accumulate samples into buffer:
      // oscil.generateSamples( bufbegin, bufbegin + nsamps, radfreq, amp, bw );
      oscil.oscillate( bufbegin, bufbegin + csound->ksmps,
                       bp, (double) csound->esr );
    }
}
開發者ID:gesellkammer,項目名稱:loris14-extended,代碼行數:59,代碼來源:lorisgens5.C

示例2: if

// ---------------------------------------------------------------------------
//	resetEnvelopes
// ---------------------------------------------------------------------------
//	Reset the instantaneous envelope parameters 
// 	(frequency, amplitude, bandwidth, and phase).
// 	The sample rate is needed to convert the 
// 	Breakpoint frequency (Hz) to radians per sample.
//
void 
Oscillator::resetEnvelopes( const Breakpoint & bp, double srate )
{
	//	Remember that the oscillator only knows about 
	//	radian frequency! Convert!
	i_frequency = bp.frequency() * TwoPi / srate;
	i_amplitude = bp.amplitude();
	i_bandwidth = bp.bandwidth();
	determ_phase = bp.phase();
	
 	//	clamp bandwidth:
	if ( i_bandwidth > 1. )
	{
		debugger << "clamping bandwidth at 1." << endl;
		i_bandwidth = 1.;
	}
	else if ( i_bandwidth < 0. )
	{ 
		debugger << "clamping bandwidth at 0." << endl;
		i_bandwidth = 0.;
	}

	//	don't alias:
	if ( i_frequency > Pi )
	{ 
		debugger << "fading out aliasing Partial" << endl;
		i_amplitude = 0.;
	}
}
開發者ID:gesellkammer,項目名稱:loris14-extended,代碼行數:37,代碼來源:Oscillator.C

示例3: if

// ---------------------------------------------------------------------------
//  resetEnvelopes
// ---------------------------------------------------------------------------
//  Reset the instantaneous envelope parameters
//  (frequency, amplitude, bandwidth, and phase).
//  The Breakpoint frequency (Hz) is in radians per sample.
void
RealtimeOscillator::restoreEnvelopes( const Breakpoint & bp) noexcept
{
    //  Remember that the oscillator only knows about
    //  radian frequency! Convert!
    m_instfrequency = bp.frequency();
    m_instamplitude = bp.amplitude();
    m_instbandwidth = bp.bandwidth();
    m_determphase = bp.phase();

    //  clamp bandwidth:
    if ( m_instbandwidth > 1. )
    {
        m_instbandwidth = 1.;
    }
    else if ( m_instbandwidth < 0. )
    {
        m_instbandwidth = 0.;
    }
    //  don't alias:
    if ( m_instfrequency > Pi )
    {
        m_instamplitude = 0.;
    }

    //  Reset the fitler state too.
    m_filter.clear();
}
開發者ID:EQ4,項目名稱:Paraphrasis,代碼行數:34,代碼來源:RealtimeOscillator.cpp


注:本文中的Breakpoint::amplitude方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。