c++ - 使用 MoMu STK 进行音频合成

标签 c++ ios core-audio

有人在 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/

相关文章:

ios - 我可以即时生成音调(音乐)吗?

ios - 改变非交错浮点的间距

c++ - 结构的互锁交换

c++ - 在 aux 方法中创建的 QWidget 不显示/绘制

c++ - 如何在 C++ 函数中输入变量名并使用该变量?

ios - 在 UITableView 中自定义每个单元格的分隔符

ios - 是否可以延迟加载符合 nscoding 协议(protocol)的对象

c++ - 获取cocos2dx游戏时间

IOS:IBAction 有两个 Action

swift - 使用 CoreAudio 在 Swift 中以编程方式创建聚合音频设备