예제 #1
0
int main(int argc, char **argv)
{
    const QString errorstr = "Fatal error from the ALSA sequencer. "
        "This usually happens when the kernel doesn't have ALSA support, "
        "or the device node (/dev/snd/seq) doesn't exists, "
        "or the kernel module (snd_seq) is not loaded. "
        "Please check your ALSA/MIDI configuration.";

    CmdLineArgs args;
    signal(SIGINT, signalHandler);
    signal(SIGTERM, signalHandler);

    args.setUsage("[options] port [bpm]");
    args.addRequiredArgument("port", "Destination, MIDI port identifier");
    args.addOptionalArgument("bpm", "Tempo, in beats per minute (default=120)");
    args.parse(argc, argv);

    try {
        metronome = new Metronome();
        QVariant port = args.getArgument("port");
        if (!port.isNull())
            metronome->subscribe(port.toString());
        QVariant bpm = args.getArgument("bpm");
        metronome->play(bpm.toString());
    } catch (const SequencerError& ex) {
        cerr << errorstr + " Returned error was: " + ex.qstrError() << endl;
    } catch (...) {
        cerr << errorstr << endl;
    }
    delete metronome;
    return 0;
}
예제 #2
0
int main(int argc, char **argv)
{
    const QString errorstr = "Fatal error from the ALSA sequencer. "
        "This usually happens when the kernel doesn't have ALSA support, "
        "or the device node (/dev/snd/seq) doesn't exists, "
        "or the kernel module (snd_seq) is not loaded. "
        "Please check your ALSA/MIDI configuration.";

    CmdLineArgs args;
    args.setUsage("[port]");
    args.addOptionalArgument("port", "Source MIDI port");
    args.parse(argc, argv);
    try {
        test = new QDumpMIDI();
        signal(SIGINT, signalHandler);
        signal(SIGTERM, signalHandler);
        QVariant portName = args.getArgument("port");
        if (!portName.isNull())
            test->subscribe(portName.toString());
        test->run();
    } catch (const SequencerError& ex) {
        cerr << errorstr + " Returned error was: " + ex.qstrError() << endl;
    } catch (...) {
        cerr << errorstr << endl;
    }
    delete test;
    return 0;
}