forked from dulnikovsky/magicstompfrenzy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
midisender.cpp
71 lines (59 loc) · 2.05 KB
/
midisender.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/****************************************************************************
**
** Copyright (C) 2018 Robert Vetter.
**
** This file is part of the MagicstompFrenzy - an editor for Yamaha Magicstomp
** effect processor
**
** THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
** ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
** IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
** PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version . The licenses are
** as published by the Free Software Foundation and appearing in the file LICENSE
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**/
#include "midisender.h"
#include "midievent.h"
#ifdef Q_OS_LINUX
#include <alsa/asoundlib.h>
#include <QApplication>
#include <QThread>
#include <QDebug>
#include <QCoreApplication>
bool MidiSender::event(QEvent *e)
{
MidiEvent *me = dynamic_cast<MidiEvent *>(e);
if(me && me->type()==static_cast<QEvent::Type>(UserEventTypes::MidiSysEx))
{
snd_seq_event_t ev;
snd_seq_ev_clear(&ev);
snd_seq_ev_set_source(&ev, outport.portId());
snd_seq_ev_set_subs(&ev);
snd_seq_ev_set_direct(&ev);
snd_seq_ev_set_variable(&ev, me->sysExData()->size(), (void * )me->sysExData()->constData() );
ev.type=SND_SEQ_EVENT_SYSEX;
//qDebug() << me->sysExData()->toHex(',') << "\n";
int ret;
ret = snd_seq_event_output(handle, &ev);
if(ret < 0)
{
qDebug() << "Error at snd_seq_event_output";
}
ret = snd_seq_drain_output(handle);
if(ret < 0)
{
qDebug() << "Error at snd_seq_drain_output";
}
me->accept();
}
return true;
}
#endif