本文整理汇总了C++中AudioDecoder::SetPitch方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDecoder::SetPitch方法的具体用法?C++ AudioDecoder::SetPitch怎么用?C++ AudioDecoder::SetPitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioDecoder
的用法示例。
在下文中一共展示了AudioDecoder::SetPitch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: available
void Psp2Audio::SE_Play(std::string const& file, int volume, int pitch) {
// Opening file
FILE* stream = FileFinder::fopenUTF8(file, "rb");
if (!stream) {
Output::Warning("Couldn't open sound file %s", file.c_str());
return;
}
// Pick the next free SE slot.
// Does not need synchronisation
int idx = -1;
for (int i = 0; i < AUDIO_CHANNELS; ++i) {
if (sfx_sounds[i].isPlaying && sfx_sounds[i].isFinished) {
idx = i;
break;
}
}
if (idx == -1) {
fclose(stream);
Output::Warning("SE: No free channels available (%s)", file.c_str());
return;
}
DecodedSound& sfx = sfx_sounds[idx];
sfx.decoder = AudioDecoder::Create(stream, file);
if (sfx.decoder == nullptr){
fclose(stream);
Output::Warning("Unsupported sound format (%s)", file.c_str());
return;
}
// Initializing internal audio decoder
int audiotype;
AudioDecoder* decoder = sfx.decoder.get();
if (!decoder->Open(stream)) {
Output::Warning("Error occured in audio decoder (%s)", audio_decoder->GetError().c_str());
return;
}
decoder->SetLooping(false);
AudioDecoder::Format int_format;
int samplerate;
decoder->SetFormat(48000, AudioDecoder::Format::S16, 2);
decoder->GetFormat(samplerate, int_format, audiotype);
if (samplerate != 48000) Output::Warning("Cannot resample sound file. Sound will be distorted.");
// Check for file audiocodec
sfx.isStereo = audiotype == 2;
// Setting default streaming values
sfx.cur_audiobuf = sfx.audiobuf;
decoder->SetPitch(pitch);
decoder->SetVolume(volume);
// Wait and signal is required to prevent reordering
sceKernelWaitSema(SFX_Mutex_ID, 1, NULL);
sfx.isPlaying = false;
sfx.isFinished = false;
sceKernelSignalSema(SFX_Mutex_ID, 1);
// Start one SE thread
sceKernelSignalSema(SFX_Mutex, 1);
}