本文整理汇总了C++中AudioOutputPtr::playSine方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioOutputPtr::playSine方法的具体用法?C++ AudioOutputPtr::playSine怎么用?C++ AudioOutputPtr::playSine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioOutputPtr
的用法示例。
在下文中一共展示了AudioOutputPtr::playSine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encodeAudioFrame
//.........这里部分代码省略.........
}
sum=1.0f;
for (i=0;i<iFrameSize;i++)
sum += static_cast<float>(psSource[i] * psSource[i]);
float micLevel = sqrtf(sum / static_cast<float>(iFrameSize));
dPeakSignal=20.0f*log10f(micLevel / 32768.0f);
if (dPeakSignal < -96.0f)
dPeakSignal = -96.0f;
spx_int32_t prob = 0;
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_GET_PROB, &prob);
fSpeechProb = static_cast<float>(prob) / 100.0f;
float level = (g.s.vsVAD == Settings::SignalToNoise) ? fSpeechProb : (1.0f + dPeakMic / 96.0f);
if (level > g.s.fVADmax)
iIsSpeech = 1;
else if (level > g.s.fVADmin && bPreviousVoice)
iIsSpeech = 1;
else
iIsSpeech = 0;
if (! iIsSpeech) {
iHoldFrames++;
if (iHoldFrames < g.s.iVoiceHold)
iIsSpeech=1;
} else {
iHoldFrames = 0;
}
if (g.s.atTransmit == Settings::Continous)
iIsSpeech = 1;
else if (g.s.atTransmit == Settings::PushToTalk)
iIsSpeech = g.s.uiDoublePush && ((g.uiDoublePush < g.s.uiDoublePush) || (g.tDoublePush.elapsed() < g.s.uiDoublePush));
iIsSpeech = iIsSpeech || (g.iPushToTalk > 0) || (g.iAltSpeak > 0);
if (g.s.bMute || ((g.s.lmLoopMode != Settings::Local) && p && p->bMute) || g.bPushToMute) {
iIsSpeech = 0;
}
if (iIsSpeech) {
iSilentFrames = 0;
} else {
iSilentFrames++;
if (iSilentFrames > 200)
iFrameCounter = 0;
}
if (p)
p->setTalking(iIsSpeech, (g.iAltSpeak > 0));
if (g.s.bPushClick && (g.s.atTransmit == Settings::PushToTalk)) {
AudioOutputPtr ao = g.ao;
if (iIsSpeech && ! bPreviousVoice && ao)
ao->playSine(400.0f,1200.0f,5);
else if (ao && !iIsSpeech && bPreviousVoice && ao)
ao->playSine(620.0f,-1200.0f,5);
}
if (! iIsSpeech && ! bPreviousVoice) {
iBitrate = 0;
if (g.s.iIdleTime && ! g.s.bMute && ((tIdle.elapsed() / 1000000ULL) > g.s.iIdleTime)) {
emit doMute();
tIdle.restart();
}
return;
}
bPreviousVoice = iIsSpeech;
tIdle.restart();
if (! iIsSpeech) {
memset(psMic, 0, sizeof(short) * iFrameSize);
}
if (g.s.bTransmitPosition && g.p && ! g.bCenterPosition && (iFrames == 0) && g.p->fetch()) {
QByteArray q;
QDataStream ds(&q, QIODevice::WriteOnly);
ds << g.p->fPosition[0];
ds << g.p->fPosition[1];
ds << g.p->fPosition[2];
speex_bits_pack(&sbBits, 13, 5);
speex_bits_pack(&sbBits, q.size(), 4);
const unsigned char *d=reinterpret_cast<const unsigned char*>(q.data());
for (i=0;i<q.size();i++) {
speex_bits_pack(&sbBits, d[i], 8);
}
}
speex_encode_int(esEncState, psSource, &sbBits);
iFrames++;
speex_encoder_ctl(esEncState, SPEEX_GET_BITRATE, &iBitrate);
flushCheck();
}