有人在 iOS 上使用 MoMu STK 成功实现了仪器吗?我对仪器流的初始化有点困惑。 我正在使用教程代码,看起来缺少一些东西
RtAudio dac; // Figure out how many bytes in an StkFloat and setup the RtAudio stream. RtAudio::StreamParameters parameters; parameters.deviceId = dac.getDefaultOutputDevice(); parameters.nChannels = 1; RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32; unsigned int bufferFrames = RT_BUFFER_SIZE; dac.openStream( & parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
错误描述表明输出设备的输出参数无效,但是当我跳过分配设备 ID 时,它也不起作用。 任何想法都会很棒。
最佳答案
RtAudio仅适用于桌面应用,在iOS上实现时无需打开流。
示例:
头文件:
#import "Simple.h"
// make struct to hold
struct TickData {
Simple *synth;
};
// Make instance of the struct in @interface=
TickData data;
实现文件:
// init the synth:
data.synth = new Simple();
data.synth->keyOff();
// to trigger note on/off:
data.synth->noteOn(frequency, velocity);
data.synth->noteOff(velocity);
// audio callback method:
for (int i=0; i < FRAMESIZE; i++) {
buffer[i] = data.synth -> tick();
}
关于c++ - 使用 MoMu STK 进行音频合成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8076694/