ALSA的C++封装库 Drumstick
<p>Drumstick 是一个ALSA的音序器 (MIDI 接口)的C++封装库</p> <p>示例代码:</p> <pre class="brush:cpp; toolbar: true; auto-links: false;">#include <QApplication> #include <drumstick.h> int main(int argc, char **argv) { QApplication app(argc, argv, false); // create a client object on the heap drumstick::MidiClient *client = new drumstick::MidiClient; client->open(); client->setClientName( "MyClient" ); // create the port drumstick::MidiPort *port = client->createPort(); port->setPortName( "MyPort" ); port->setCapability( SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ ); port->setPortType( SND_SEQ_PORT_TYPE_MIDI_GENERIC ); // subscribe the port to some other client:port port->subscribeTo( "20:0" ); // or "name:port", like in "KMidimon:0" // create an event object on the stack, to send a note on message drumstick::NoteOnEvent ev( 0, 66, 100 ); // (channel, note number, velocity) ev.setSource( port->getPortId() ); ev.setSubscribers(); // deliver to all the connected ports ev.setDirect(); // not scheduled, deliver immediately client->output( &ev ); // or outputDirect() if you prefer not buffered client->drainOutput(); // flush the buffer // close and clean client->close(); delete client; return 0; }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326627919687" target="_blank">http://www.open-open.com/lib/view/home/1326627919687</a></p> <p></p>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!