本文整理汇总了C++中fmod::DSP::setParameterInt方法的典型用法代码示例。如果您正苦于以下问题:C++ DSP::setParameterInt方法的具体用法?C++ DSP::setParameterInt怎么用?C++ DSP::setParameterInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::DSP
的用法示例。
在下文中一共展示了DSP::setParameterInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FMODGMS_Effect_Set_Parameter
//Sets a parameter a of effect e to value v. For parameters of different effects, see fmod_dsp_effects.h
GMexport double FMODGMS_Effect_Set_Parameter(double e, double p, double v)
{
int effectIndex = (int)round(e);
if ((effectIndex < 0) || (effectIndex >= (int)effectList.size()))
{
errorMessage = "Invalid effect index";
return GMS_error;
}
FMOD::DSP* effect = effectList[effectIndex];
int param = (int)round(p);
int value = (int)round(v);
FMOD_DSP_PARAMETER_DESC* desc = NULL;
if (effect->getParameterInfo(param, &desc) != FMOD_OK)
{
errorMessage = "Could not get effect parameter info, probably invalid param index";
return GMS_error;
}
if (desc->type == FMOD_DSP_PARAMETER_TYPE_FLOAT)
{
if (effect->setParameterFloat(param, (float)value) == FMOD_OK)
return FMODGMS_Util_ErrorChecker();
}
else if (desc->type == FMOD_DSP_PARAMETER_TYPE_INT)
{
if (effect->setParameterInt(param, (int)round(value)) == FMOD_OK)
return FMODGMS_Util_ErrorChecker();
}
else if (desc->type == FMOD_DSP_PARAMETER_TYPE_BOOL)
{
if (effect->setParameterBool(param, (bool)(value > 0.5)) == FMOD_OK)
return FMODGMS_Util_ErrorChecker();
}
else
{
errorMessage = "Unsupported effect parameter type";
return GMS_error;
}
errorMessage = "Could not set effect parameter";
return GMS_error;
}
示例2: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Channel *channel = 0;
FMOD::DSP *dsp;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
Common_Init(&extradriverdata);
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
}
result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
/*
Create an oscillator DSP units for the tone.
*/
result = system->createDSPByType(FMOD_DSP_TYPE_OSCILLATOR, &dsp);
ERRCHECK(result);
result = dsp->setParameterFloat(FMOD_DSP_OSCILLATOR_RATE, 440.0f); /* Musical note 'A' */
ERRCHECK(result);
/*
Main loop
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.5f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 0);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION2))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.125f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 1);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION3))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.125f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 2);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION4))
{
if (channel)
//.........这里部分代码省略.........
示例3: getSpectrum
void AnalyzerToolUtils::getSpectrum(SoundAnalyzer* soundAnalyzer)
{
//FMod variable
boost::thread_group threadpool;
FMOD::DSP* dspSpectrum;
FMOD::ChannelGroup* masterChannel;
FMOD::Channel* chan;
FMOD_RESULT res;
//Variable
int sampleRate, musicSpectrumSize;
unsigned int soundTime;
float niquistRate, i = 0;
//sound time in MS
soundAnalyzer->Sound->getLength(&soundTime, FMOD_TIMEUNIT_MS);
//DSP / FFT / Window
soundAnalyzer->sys->createDSPByType(FMOD_DSP_TYPE_FFT, &dspSpectrum);
dspSpectrum->setParameterInt(FMOD_DSP_FFT_WINDOWSIZE, soundAnalyzer->GetWindowSize());
dspSpectrum->getParameterInt(FMOD_DSP_FFT_WINDOWSIZE, &musicSpectrumSize, 0, 0);
dspSpectrum->setParameterInt(FMOD_DSP_FFT_WINDOWTYPE, FMOD_DSP_FFT_WINDOW_TRIANGLE);
//Master Channel -> Add Dsp
soundAnalyzer->sys->getMasterChannelGroup(&masterChannel);
masterChannel->addDSP(0, dspSpectrum);
soundAnalyzer->sys->setOutput(FMOD_OUTPUTTYPE_NOSOUND_NRT); //FMOD_OUTPUTTYPE_NOSOUND_NRT
soundAnalyzer->sys->playSound(soundAnalyzer->Sound, masterChannel, false, &chan);
soundAnalyzer->sys->setDSPBufferSize(SPECTRUM_BUFFER_SIZE, 0);
soundAnalyzer->sys->update();
//Get Samplerate
soundAnalyzer->sys->getSoftwareFormat(&sampleRate, 0, 0);
niquistRate = sampleRate / 2.0f;
soundAnalyzer->data.SpectrumData.resize(static_cast<int>(soundTime / (((double)SPECTRUM_BUFFER_SIZE / (double)sampleRate) * 1000)) + 1);
soundAnalyzer->SetFrequencyStep(musicSpectrumSize / niquistRate);
int index = 0;
//double val;
do{
FMOD_DSP_PARAMETER_FFT *dataSpectrum;
dspSpectrum->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&dataSpectrum, 0, 0, 0);
SpectrumSegment segment(musicSpectrumSize / 2, musicSpectrumSize / niquistRate);
threadpool.create_thread(boost::bind(&AnalyzerToolUtils::ExtractSpectrum, soundAnalyzer, boost::ref(dataSpectrum), musicSpectrumSize/2, musicSpectrumSize / niquistRate, index));
/*for (int bin = 0; bin < dataSpectrum->length/2; bin++)
{
val = 0;
for (int channel = 0; channel < MAX_CHANNELS; channel++)
{
val += dataSpectrum->spectrum[channel][bin];
}
segment.AddSegment(val);
}
soundAnalyzer->data.AddData(segment);*/
soundAnalyzer->sys->update();
index++;
i += ((double)SPECTRUM_BUFFER_SIZE / (double)sampleRate) * 1000;
} while (i < (soundTime));
threadpool.join_all();
}