当前位置: 首页>>代码示例>>C++>>正文


C++ GetSampleRate函数代码示例

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


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


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