• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetSampleRate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetSampleRate函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSampleRate函数的具体用法?C++ GetSampleRate怎么用?C++ GetSampleRate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetSampleRate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: return

DWORD ISndStreamWAV::GetCurrentTime()
{
    // return total time in ms
    if (GetSampleRate()>0)
        return (DWORD)sf_seek( m_pSndFile, 0, SEEK_CUR )/GetSampleRate()*1000;
    return 0;
}
开发者ID:joshlong,项目名称:libcd,代码行数:7,代码来源:ISndStreamWav.cpp


示例2: prepareToPlay

    void prepareToPlay()
    {
        if (juceFilter != 0)
        {
#if ! JucePlugin_IsSynth
            juceFilter->setPlayConfigDetails (GetInput(0)->GetStreamFormat().mChannelsPerFrame,
#else
            juceFilter->setPlayConfigDetails (0,
#endif
                                              GetOutput(0)->GetStreamFormat().mChannelsPerFrame,
                                              GetSampleRate(),
                                              GetMaxFramesPerSlice());

            bufferSpace.setSize (juceFilter->getNumInputChannels() + juceFilter->getNumOutputChannels(),
                                 GetMaxFramesPerSlice() + 32);

            juceFilter->prepareToPlay (GetSampleRate(),
                                       GetMaxFramesPerSlice());

            midiEvents.clear();

            juce_free (channels);
            channels = (float**) juce_calloc (sizeof (float*) * jmax (juceFilter->getNumInputChannels(),
                                                                      juceFilter->getNumOutputChannels()) + 4);

            prepared = true;
        }
开发者ID:NonPlayerCharactor,项目名称:juce_pitcher,代码行数:27,代码来源:juce_AudioUnitWrapper.cpp


示例3: AUEffectBase

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	karoke::karoke
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
karoke::karoke(AudioUnit component)
	: AUEffectBase(component, false)
{
	CreateElements();
	CAStreamBasicDescription streamDescIn;
	streamDescIn.SetCanonical(NUM_INPUTS, false);	// number of input channels
	streamDescIn.mSampleRate = GetSampleRate();
	
	CAStreamBasicDescription streamDescOut;
	streamDescOut.SetCanonical(NUM_OUTPUTS, false);	// number of output channels
	streamDescOut.mSampleRate = GetSampleRate();
	
	Inputs().GetIOElement(0)->SetStreamFormat(streamDescIn);
	Outputs().GetIOElement(0)->SetStreamFormat(streamDescOut);
	
	Globals()->UseIndexedParameters(kNumberOfParameters);
	SetParameter(kParam_One, kDefaultValue_ParamOne );
        
#if AU_DEBUG_DISPATCHER
	mDebugDispatcher = new AUDebugDispatcher (this);
#endif
	
	mLeftFilter = new FirFilter(200);
	mLeftFilter->setCoeffecients(lp_200, 200);
	mRightFilter = new FirFilter(200);
	mRightFilter->setCoeffecients(lp_200, 200);
}
开发者ID:slagyr,项目名称:8LU-DSP,代码行数:30,代码来源:karoke.cpp


示例4: lock

void IPlugConvoEngine::Reset()
{
	TRACE; IMutexLock lock(this);

	// Detect a change in sample rate.
	if (GetSampleRate() != mSampleRate)
	{
		mSampleRate = GetSampleRate();

		const int irLength = sizeof(mIR) / sizeof(mIR[0]);
		const double irSampleRate = 44100.;
		mImpulse.SetNumChannels(1);

		#if defined(_USE_WDL_RESAMPLER)
			mResampler.SetMode(false, 0, true); // Sinc, default size
			mResampler.SetFeedMode(true); // Input driven
		#elif defined(_USE_R8BRAIN)
			if (mResampler) delete mResampler;
			mResampler = new CDSPResampler16IR(irSampleRate, mSampleRate, mBlockLength);
		#endif

		// Resample the impulse response.
		int len = mImpulse.SetLength(ResampleLength(irLength, irSampleRate, mSampleRate));
		if (len) Resample(mIR, irLength, irSampleRate, mImpulse.impulses[0].Get(), len, mSampleRate);

		// Tie the impulse response to the convolution engine.
		mEngine.SetImpulse(&mImpulse);
	}
}
开发者ID:bacusters,项目名称:wdl-ol,代码行数:29,代码来源:IPlugConvoEngine.cpp


示例5: lock

	void Synthesis::Reset()
	{
		TRACE;
		IMutexLock lock(this);
		mOscillator.setSampleRate(GetSampleRate());
		mEnvelopeGenerator.setSampleRate(GetSampleRate());
	}
开发者ID:zeivhann,项目名称:libsounds-synthesis,代码行数:7,代码来源:Synthesis.cpp


示例6: GetTotalTime

DWORD ISndStreamWAV::GetTotalTime()
{
    // return total time in ms
    if (GetSampleRate()>0)
        return m_dwSamples/GetSampleRate()*1000;
    return 0;
}
开发者ID:joshlong,项目名称:libcd,代码行数:7,代码来源:ISndStreamWav.cpp


示例7: ASSERT

INT MPEGHeader::CalcFrameSize()
{
	m_nFrameSize=0;

	if (GetSampleRate()==0)
	{
		ASSERT(FALSE);
		return 0;
	}

	switch (GetLayer())
	{
		case 1:
			m_nFrameSize = (12 * GetBitRate()*1000)/GetSampleRate();
			if (m_RawMPEGHeader.Padding)
				m_nFrameSize++;
			m_nFrameSize  <<= 2;		// one slot is 4 bytes long
		break;
		case 2:
		case 3:
			m_nFrameSize = (144 * GetBitRate()*1000) / GetSampleRate();

			if (m_RawMPEGHeader.Version == MPEG_II)
				m_nFrameSize/=2;

			if (m_RawMPEGHeader.Padding)
				m_nFrameSize++;
		break;
		default:
			ASSERT(FALSE);
	}

	return m_nFrameSize;
}
开发者ID:joshlong,项目名称:libcd,代码行数:34,代码来源:MPEGHeader.cpp


示例8: GetLatency

    Float64 GetLatency()
    {
        jassert (GetSampleRate() > 0);

        if (GetSampleRate() <= 0)
            return 0.0;

        return juceFilter->getLatencySamples() / GetSampleRate();
    }
开发者ID:NonPlayerCharactor,项目名称:juce_pitcher,代码行数:9,代码来源:juce_AudioUnitWrapper.cpp


示例9: switch

//--------------------------------------------------------------------------------
OSStatus SubSynth::GetProperty(AudioUnitPropertyID inPropertyID, AudioUnitScope inScope, AudioUnitElement inElement, void * outData)
{
	if (inScope == kAudioUnitScope_Global)
	{
		switch (inPropertyID)
		{
			case kAudioUnitProperty_ParameterValueFromString:
			{
				AudioUnitParameterValueFromString * name = (AudioUnitParameterValueFromString*)outData;
				if (name->inString == NULL)
					return kAudioUnitErr_InvalidPropertyValue;
				double paramValue_literal = CFStringGetDoubleValue(name->inString);
				switch (name->inParamID)
				{
					case kParam_Tune:
						if (paramValue_literal <= 0.0)
							name->outValue = 0.0;	// XXX avoid log10(0) or log10(-X)
						else
							name->outValue = (log10(paramValue_literal / (0.0726 * GetSampleRate())) + 2.5) / 1.5;
						break;
					case kParam_Release:
						return kAudioUnitErr_PropertyNotInUse;	// XXX I can't figure out how to invert this one
					default:
						return kAudioUnitErr_InvalidParameter;
				}
				return noErr;
			}

			case kAudioUnitProperty_ParameterStringFromValue:
			{
				AudioUnitParameterStringFromValue * name = (AudioUnitParameterStringFromValue*)outData;
				double paramValue = (name->inValue == NULL) ? GetParameter(name->inParamID) : *(name->inValue);
				int precision = 0;
				switch (name->inParamID)
				{
					case kParam_Tune:
						paramValue = 0.0726 * GetSampleRate() * pow(10.0, -2.5 + (1.5 * paramValue));
						precision = 3;
						break;
					case kParam_Release:
						paramValue = GetReleaseTimeForParamValue(paramValue);
						precision = 1;
						break;
					default:
						return kAudioUnitErr_InvalidParameter;
				}
				name->outString = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%.*f"), precision, paramValue);
				if (name->outString == NULL)
					return coreFoundationUnknownErr;
				return noErr;
			}
		}
	}

	return AUEffectBase::GetProperty(inPropertyID, inScope, inElement, outData);
}
开发者ID:arcanelab,项目名称:mda-VST-plug-ins,代码行数:57,代码来源:subsynth.cpp


示例10: Start

void CWaveInstrumentB::Start()
{
    m_wavePlayer.SetSampleRate(GetSampleRate());
    m_wavePlayer.Start();
	
	m_ar.SetSource(&m_wavePlayer);
	m_ar.SetSampleRate(GetSampleRate());
	m_ar.SetDuration(m_duration);
	m_ar.Start();

}
开发者ID:aeverdeen,项目名称:synthesizer,代码行数:11,代码来源:WaveInstrumentB.cpp


示例11: lock

void ATKColoredExpander::OnParamChange(int paramIdx)
{
  IMutexLock lock(this);
  
  switch (paramIdx)
  {
    case kPower:
    {
      auto power = GetParam(kPower)->Value();
      if (power == 0)
      {
        powerFilter.set_memory(0);
      }
      else
      {
        powerFilter.set_memory(std::exp(-1e3 / (power * GetSampleRate())));
      }
      break;
    }
    case kThreshold:
      gainExpanderFilter.set_threshold(std::pow(10, GetParam(kThreshold)->Value() / 10));
      break;
    case kSlope:
      gainExpanderFilter.set_ratio(GetParam(kSlope)->Value());
      break;
    case kSoftness:
      gainExpanderFilter.set_softness(std::pow(10, GetParam(kSoftness)->Value()));
      break;
    case kColored:
      gainExpanderFilter.set_color(GetParam(kColored)->Value());
      break;
    case kQuality:
      gainExpanderFilter.set_quality(GetParam(kQuality)->Value());
      break;
    case kAttack:
      attackReleaseFilter.set_attack(std::exp(-1e3/(GetParam(kAttack)->Value() * GetSampleRate()))); // in ms
      break;
    case kRelease:
      attackReleaseFilter.set_release(std::exp(-1e3/(GetParam(kRelease)->Value() * GetSampleRate()))); // in ms
      break;
    case kMaxReduction:
      gainExpanderFilter.set_max_reduction_db(GetParam(kMaxReduction)->Value());
      break;
    case kMakeup:
      volumeFilter.set_volume_db(GetParam(kMakeup)->Value());
      break;
    case kDryWet:
      drywetFilter.set_dry(GetParam(kDryWet)->Value());
      break;
      
    default:
      break;
  }
}
开发者ID:EQ4,项目名称:ATK-plugins,代码行数:54,代码来源:ATKColoredExpander.cpp


示例12: Start

void CSubtractiveAmplitudeFilter::Start()
{
	mTime = 0;
	mEnvelope->SetDuration(mDuration);
	mEnvelope->SetSampleRate(GetSampleRate());
	mEnvelope->Start();
}
开发者ID:ungrodtb,项目名称:CSE471---Proj01,代码行数:7,代码来源:SubtractiveAmplitudeFilter.cpp


示例13: pow

//--------------------------------------------------------------------------------
double SubSynth::GetReleaseTimeForParamValue(double inLinearValue)
{
	inLinearValue = 1.0 - pow(10.0, -2.0 - (3.0 * inLinearValue));
	if (inLinearValue == 0.0)
		inLinearValue = 10.0;	// XXX avoid log10(0) and division by 0
	return -301.03 / (GetSampleRate() * log10(fabs(inLinearValue)));
}
开发者ID:arcanelab,项目名称:mda-VST-plug-ins,代码行数:8,代码来源:subsynth.cpp


示例14: GetChannels

/*--------------------------------------------------------------------------------*/
bool ADMRIFFFile::CreateExtraChunks()
{
  bool success = true;

  if (adm)
  {
    RIFFChunk *chunk;
    uint64_t  chnalen;
    uint8_t   *chna;
    uint_t i, nchannels = GetChannels();

    success = true;

    for (i = 0; i < nchannels; i++)
    {
      ADMAudioTrack *track;

      // create chna track data
      if ((track = adm->CreateTrack(i)) != NULL)
      {
        track->SetSampleRate(GetSampleRate());
        track->SetBitDepth(GetBitsPerSample());
      }
    }

    if (!admfile.empty())
    {
      // create ADM structure (content and objects from file)
      if (adm->CreateFromFile(admfile.c_str()))
      {
        // can prepare cursors now since all objects have been created
        PrepareCursors();
      }
      else
      {
        BBCERROR("Unable to create ADM structure from '%s'", admfile.c_str());
        success = false;
      }
    }

    // get ADM object to create chna chunk
    if ((chna = adm->GetChna(chnalen)) != NULL)
    {
      // and add it to the RIFF file
      if ((chunk = AddChunk(chna_ID)) != NULL)
      {
        success &= chunk->CreateChunkData(chna, chnalen);
      }
      else BBCERROR("Failed to add chna chunk");

      // don't need the raw data any more
      delete[] chna;
    }
    else BBCERROR("No chna data available");

    success &= (AddChunk(axml_ID) != NULL);
  }

  return success;
}
开发者ID:0x4d52,项目名称:bbcat-audioobjects,代码行数:61,代码来源:ADMRIFFFile.cpp


示例15: memset

BOOL OSndStreamWAV::OpenStream( const CUString& strFileName )
{
	SF_INFO wfInfo;

    memset(&wfInfo,0,sizeof(SF_INFO));
	wfInfo.samplerate  = GetSampleRate();
	wfInfo.frames      = -1;
	wfInfo.sections	   = 1;
	wfInfo.channels    = GetChannels();
	wfInfo.format      = (SF_FORMAT_WAV | m_OutputFormat) ;

	// Set file name
	SetFileName(strFileName);
	
    CUStringConvert strCnv;

	// Open stream
    #ifdef _UNICODE
    if (! (m_pSndFile = sf_open(	(const tchar*)strCnv.ToT( GetFileName() + _W( "." ) + GetFileExtention() ),
									SFM_WRITE,
									&wfInfo ) ) )
    #else
	if (! (m_pSndFile = sf_open(	strCnv.ToT( GetFileName() + _W( "." ) + GetFileExtention() ),
									SFM_WRITE,
									&wfInfo ) ) )
    #endif
	{
		ASSERT( FALSE );
		return FALSE;
	}

	// return Success
	return TRUE;
}
开发者ID:joshlong,项目名称:libcd,代码行数:34,代码来源:OSndStreamWAV.cpp


示例16: lock

void ATKStereoCompressor::Reset()
{
  TRACE;
  IMutexLock lock(this);
  
  int sampling_rate = GetSampleRate();
  
  if (sampling_rate != endpoint.get_input_sampling_rate())
  {
    inLFilter.set_input_sampling_rate(sampling_rate);
    inLFilter.set_output_sampling_rate(sampling_rate);
    inRFilter.set_input_sampling_rate(sampling_rate);
    inRFilter.set_output_sampling_rate(sampling_rate);
    outLFilter.set_input_sampling_rate(sampling_rate);
    outLFilter.set_output_sampling_rate(sampling_rate);
    outRFilter.set_input_sampling_rate(sampling_rate);
    outRFilter.set_output_sampling_rate(sampling_rate);

    middlesidesplitFilter.set_input_sampling_rate(sampling_rate);
    middlesidesplitFilter.set_output_sampling_rate(sampling_rate);
    volumesplitFilter.set_input_sampling_rate(sampling_rate);
    volumesplitFilter.set_output_sampling_rate(sampling_rate);
    middlesidemergeFilter.set_input_sampling_rate(sampling_rate);
    middlesidemergeFilter.set_output_sampling_rate(sampling_rate);
    volumemergeFilter.set_input_sampling_rate(sampling_rate);
    volumemergeFilter.set_output_sampling_rate(sampling_rate);
    sumFilter.set_input_sampling_rate(sampling_rate);
    sumFilter.set_output_sampling_rate(sampling_rate);

    powerFilter1.set_input_sampling_rate(sampling_rate);
    powerFilter1.set_output_sampling_rate(sampling_rate);
    attackReleaseFilter1.set_input_sampling_rate(sampling_rate);
    attackReleaseFilter1.set_output_sampling_rate(sampling_rate);
    gainCompressorFilter1.set_input_sampling_rate(sampling_rate);
    gainCompressorFilter1.set_output_sampling_rate(sampling_rate);
    makeupFilter1.set_input_sampling_rate(sampling_rate);
    makeupFilter1.set_output_sampling_rate(sampling_rate);

    powerFilter2.set_input_sampling_rate(sampling_rate);
    powerFilter2.set_output_sampling_rate(sampling_rate);
    attackReleaseFilter2.set_input_sampling_rate(sampling_rate);
    attackReleaseFilter2.set_output_sampling_rate(sampling_rate);
    gainCompressorFilter2.set_input_sampling_rate(sampling_rate);
    gainCompressorFilter2.set_output_sampling_rate(sampling_rate);
    makeupFilter2.set_input_sampling_rate(sampling_rate);
    makeupFilter2.set_output_sampling_rate(sampling_rate);

    applyGainFilter.set_input_sampling_rate(sampling_rate);
    applyGainFilter.set_output_sampling_rate(sampling_rate);
    drywetFilter.set_input_sampling_rate(sampling_rate);
    drywetFilter.set_output_sampling_rate(sampling_rate);
    endpoint.set_input_sampling_rate(sampling_rate);
    endpoint.set_output_sampling_rate(sampling_rate);

    attackReleaseFilter1.set_release(std::exp(-1e3 / (GetParam(kAttack1)->Value() * sampling_rate))); // in ms
    attackReleaseFilter1.set_attack(std::exp(-1e3 / (GetParam(kRelease1)->Value() * sampling_rate))); // in ms
    attackReleaseFilter2.set_release(std::exp(-1e3 / (GetParam(kAttack2)->Value() * sampling_rate))); // in ms
    attackReleaseFilter2.set_attack(std::exp(-1e3 / (GetParam(kRelease2)->Value() * sampling_rate))); // in ms
  }
}
开发者ID:EQ4,项目名称:ATK-plugins,代码行数:60,代码来源:ATKStereoCompressor.cpp


示例17: AUEffectBase

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	RadioEffectUnit::RadioEffectUnit
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RadioEffectUnit::RadioEffectUnit(AudioUnit Component)
	: AUEffectBase(Component)
{
	CreateElements();

	if (!bGLocalized) {		
		// Because we are in a component, we need to load our bundle by identifier so we can access our localized strings
		// It is important that the string passed here exactly matches that in the Info.plist Identifier string
		CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.epicgames.audiounit.radio") );
		
		if (bundle != NULL) {
			kChebyshevPowerMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerMultiplierName, CFSTR("Localizable"), bundle, CFSTR(""));
			kChebyshevPowerName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerName, CFSTR("Localizable"), bundle, CFSTR(""));
			kChebyshevMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevMultiplierName, CFSTR("Localizable"), bundle, CFSTR(""));	
			kChebyshevCubedMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevCubedMultiplierName, CFSTR("Localizable"), bundle, CFSTR(""));	
		}
		bGLocalized = TRUE; //so never pass the test again...
	}

	GFinalBandPassFilter.Initialize( 2000.0f, 400.0f, GetSampleRate() );

	SetParameter(RadioParam_ChebyshevPowerMultiplier, 	kDefaultValue_ChebyshevPowerMultiplier );
	SetParameter(RadioParam_ChebyshevPower, 			kDefaultValue_ChebyshevPower );
	SetParameter(RadioParam_ChebyshevMultiplier, 		kDefaultValue_ChebyshevMultiplier );
	SetParameter(RadioParam_ChebyshevCubedMultiplier,	kDefaultValue_ChebyshevCubedMultiplier );
}
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:30,代码来源:RadioEffectUnit.cpp


示例18: lock

void Synthesis::Reset()
{
  TRACE;
  IMutexLock lock(this);
  double sampleRate = GetSampleRate();
  VoiceManager::getInstance().setSampleRate(sampleRate);
}
开发者ID:UIKit0,项目名称:gpu-synth,代码行数:7,代码来源:Synthesis.cpp


示例19: GetSampleRate

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	FilterKernel::GetFrequencyResponse()
//
//		returns scalar magnitude response
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double FilterKernel::GetFrequencyResponse( double inFreq /* in Hertz */ )
{
	float srate = GetSampleRate();
	
	double scaledFrequency = 2.0 * inFreq / srate;
	
	// frequency on unit circle in z-plane
	double zr = cos(M_PI * scaledFrequency);
	double zi = sin(M_PI * scaledFrequency);
	
	// zeros response
	double num_r = mA0*(zr*zr - zi*zi) + mA1*zr + mA2;
	double num_i = 2.0*mA0*zr*zi + mA1*zi;
	
	double num_mag = sqrt(num_r*num_r + num_i*num_i);
	
	// poles response
	double den_r = zr*zr - zi*zi + mB1*zr + mB2;
	double den_i = 2.0*zr*zi + mB1*zi;
	
	double den_mag = sqrt(den_r*den_r + den_i*den_i);
	
	// total response
	double response = num_mag  / den_mag;

	
	return response;
}
开发者ID:arnelh,项目名称:Examples,代码行数:33,代码来源:Filter.cpp


示例20: AUKernelBase

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	TremoloUnit::TremoloUnitKernel::TremoloUnitKernel()
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This is the constructor for the TremoloUnitKernel helper class, which holds the DSP code 
//  for the audio unit. TremoloUnit is an n-to-n audio unit; one kernel object gets built for 
//  each channel in the audio unit.
//
// The first line of the method consists of the constructor method declarator and constructor-
//  initializer. In addition to calling the appropriate superclasses, this code initializes two 
//  member variables:
//
// mCurrentScale:		a factor for correlating points in the current wave table to
//						the audio signal sampling frequency. to produce the desired
//						tremolo frequency
// mSamplesProcessed:	a global count of samples processed. it allows the tremolo effect
//						to be continuous over data input buffer boundaries
//
// (In the Xcode template, the header file contains the call to the superclass constructor.)
TremoloUnit::TremoloUnitKernel::TremoloUnitKernel (AUEffectBase *inAudioUnit ) : AUKernelBase (inAudioUnit),
	mSamplesProcessed (0), mCurrentScale (0)
{	
	// Generates a wave table that represents one cycle of a sine wave, normalized so that
	//  it never goes negative and so it ranges between 0 and 1; this sine wave specifies 
	//  how to vary the volume during one cycle of tremolo.
	for (int i = 0; i < kWaveArraySize; ++i) {
		double radians = i * 2.0 * pi / kWaveArraySize;
		mSine [i] = (sin (radians) + 1.0) * 0.5;
	}

	// Does the same for a pseudo square wave, with nice rounded corners to avoid pops.
	for (int i = 0; i < kWaveArraySize; ++i) {
		double radians = i * 2.0 * pi / kWaveArraySize;
		radians = radians + 0.32; // shift the wave over for a smoother start
		mSquare [i] =
			(
				sin (radians) +	// Sums the odd harmonics, scaled for a nice final waveform
				0.3 * sin (3 * radians) +
				0.15 * sin (5 * radians) +
				0.075 * sin (7 * radians) +
				0.0375 * sin (9 * radians) +
				0.01875 * sin (11 * radians) +
				0.009375 * sin (13 * radians) +
				0.8			// Shifts the value so it doesn't go negative.
			) * 0.63;		// Scales the waveform so the peak value is close 
							//  to unity gain.
	}

	// Gets the samples per second of the audio stream provided to the audio unit. 
	// Obtaining this value here in the constructor assumes that the sample rate
	// will not change during one instantiation of the audio unit.
	mSampleFrequency = GetSampleRate ();
}
开发者ID:fruitsamples,项目名称:TremoloUnit,代码行数:52,代码来源:TremoloUnit.cpp



注:本文中的GetSampleRate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetSaveFileName函数代码示例发布时间:2022-05-30
下一篇:
C++ GetSafeComboBoxSelection函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap