我的目标是能够使用 Superpowered API 播放多种声音(为了制作鼓组),因为我需要非常低的延迟。
我在 .mm 文件中找不到整体架构。
现在,我的 .mm 文件中有:
- 1 个超级强大的 IOSAudioIO* 输出
- 10 SuperpoweredAdvancedAudioPlayer* (players[10]), 因为我有 10 个鼓
但我找不到如何实现 .mm 文件的其余部分,特别是audioProcessing
循环。
我目前有这个:
static bool audioProcessing(Superpowered *clientdata, float **buffers, unsigned int inputChannels, unsigned int outputChannels, unsigned int numberOfSamples, unsigned int samplerate, uint64_t hostTime) {
Superpowered *self = clientdata;
bool overallSilence = true;
for(int i = 0; i < 10; i++) {
SuperpoweredAdvancedAudioPlayer *player = self->players[i];
bool silence = !player->process(self->stereoBuffer, false, numberOfSamples);
if (silence == false) {
overallSilence = false;
}
}
if (!overallSilence) SuperpoweredDeInterleave(self->stereoBuffer, buffers[0], buffers[1], numberOfSamples); // The stereoBuffer is ready now, let's put the finished audio into the requested buffers.
return !overallSilence;
}
当我想播放声音时:
- (void)playWithPlayerAtIndex:(int) index {
SuperpoweredAdvancedAudioPlayer* player = players[index];
player->seek(0);
player->play(false);
}
但是有了这个,我一次只能听到一种声音。
有人知道 Superpowered API 吗?