2011-11-10 38 views
2

有人在iOS上使用MoMu STK成功實現了一個樂器嗎?我有點爲Instrument的流初始化。 我使用教程代碼,看起來像缺點什麼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,然後在它不工作爲好。 任何想法都會很棒。

回答

2

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(); 
} 
2

是的,我在店裏幾個應用程序與在其上運行STK類。請記住,在iOS上運行STK所需的設置與在桌面上運行STK所需的設置不同。

下面是關於如何使用iOS應用內STK類的教程: https://arielelkin.github.io/articles/mandolin

+0

這個鏈接似乎是出過期 – user3717478

+0

謝謝你讓我知道!鏈接已更新。 – Eric