微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Drumstick ALSA的C++封装库

程序名称:Drumstick

授权协议: GPL

操作系统: Linux

开发语言: C/C++

Drumstick 介绍

Drumstick 是一个ALSA的音序器 (MIDI 接口)的C++封装库

示例代码

#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;  
}

Drumstick 官网

http://drumstick.sourceforge.net/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐