大佬教程收集整理的这篇文章主要介绍了iOS:将OpenAL的Pitch Shifting和Piping输出转换为缓冲区,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在看Hollance的声音银行播放器.它会吸收大约15个左右的钢琴音符,通过计算出最接近哪个样本来播放任何音符,然后调整适当数量的音高.这是执行此操作的代码:
- (void) noteOn: (int) midiNotenumber gain: (float) gain { if (!initialized) { NSLog(@"SoundBankPlayer is not initialized yet"); return; } int sourceIndex = [self findAvailablesource]; if (sourceIndex != -1) { alGetError(); // clear any errors Note* note = notes + midiNotenumber; if (note->bufferIndex != -1) { Buffer* buffer = buffers + note->bufferIndex; source* source = sources + sourceIndex; source->noteIndex = midiNotenumber; alsourcef(source->sourcEID,AL_PITCH,note->pitch / buffer->pitch); alsourcei(source->sourcEID,AL_LOOPING,AL_falSE); alsourcef(source->sourcEID,AL_REFERENCE_DISTANCE,100.0f); alsourcef(source->sourcEID,AL_GAIN,gain); float sourcePos[] = { note->pAnning,0.0f,0.0f }; alsourcefv(source->sourcEID,AL_POSITION,sourcePos); alsourcei(source->sourcEID,AL_BUFFER,AL_NONE); alsourcei(source->sourcEID,buffer->bufferId); ALenum error; if ((error = alGetError()) != AL_NO_ERROR) { NSLog(@"Error attaching buffer to source: %x",error); return; } alsourcePlay(source->sourcEID); if ((error = alGetError()) != AL_NO_ERROR) { NSLog(@"Error starTing source: %x",error); return; } } } }
你可以看到这条线做了音高变换:
alsourcef(source->sourcEID,note->pitch / buffer->pitch);
不幸的是,这对于同时播放一堆音符并不好,因为它需要太多的cpu.它是动态的音高变换.
我想要的是为每个钢琴音符创建一个缓冲区,并使用这种音高变换技术填充这些缓冲区.但我无法看到如何让openAL将声音播放到缓冲区而不是通过扬声器播放.
有没有办法管道输出
alsourcePlay(源 – >的sourcEID);
进入缓冲区?
如果我不能这样做,我的选择是什么?我已经尝试过使用DSPDimension文章中的smbPitchShift,但它没有提供良好的保真度:钢琴音符的攻击阶段确实丢失了.我想我可以使用Dirac3的免费版本…(我目前没有完整版本的钱,但我认为免费版本允许Mono处理,@R_635_9447@破解它).还有其他选择吗?
编辑:我已经测试过Dirac3,它也有同样的问题.它似乎包围了攻击.似乎OpenAL的音高变换器以某种方式做了Dirac3没有的东西.
以上是大佬教程为你收集整理的iOS:将OpenAL的Pitch Shifting和Piping输出转换为缓冲区全部内容,希望文章能够帮你解决iOS:将OpenAL的Pitch Shifting和Piping输出转换为缓冲区所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。