1 /*!
2  * @file arpwidget_lv2.cpp
3  * @brief Headers for the LV2 GUI for the QMidiArp Arp plugin.
4  *
5  *
6  *      Copyright 2009 - 2017 <qmidiarp-devel@lists.sourceforge.net>
7  *
8  *      This program is free software; you can redistribute it and/or modify
9  *      it under the terms of the GNU General Public License as published by
10  *      the Free Software Foundation; either version 2 of the License, or
11  *      (at your option) any later version.
12  *
13  *      This program is distributed in the hope that it will be useful,
14  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *      GNU General Public License for more details.
17  *
18  *      You should have received a copy of the GNU General Public License
19  *      along with this program; if not, write to the Free Software
20  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  *      MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef QMIDIARP_ARPWIDGET_LV2_H
26 #define QMIDIARP_ARPWIDGET_LV2_H
27 
28 #include "lv2_common.h"
29 #include "arpwidget.h"
30 
31 #define QMIDIARP_ARP_LV2_URI QMIDIARP_LV2_URI "/arp"
32 #define QMIDIARP_ARP_LV2_PREFIX QMIDIARP_ARP_LV2_URI "#"
33 #define QMIDIARP_ARP_LV2UI_URI QMIDIARP_ARP_LV2_PREFIX "ui"
34 
35 class ArpWidgetLV2 : public ArpWidget
36 {
37   Q_OBJECT
38 
39   public:
40 
41     enum PortIndex {
42             MidiIn = 0,
43             MidiOut = 1,
44             ATTACK = 2,
45             RELEASE = 3,
46             RANDOM_TICK = 4,
47             RANDOM_LEN = 5,
48             RANDOM_VEL = 6,
49             CH_OUT = 7,
50             CH_IN = 8,
51             CURSOR_POS = 9, //output
52             ENABLE_RESTARTBYKBD = 10,
53             ENABLE_TRIGBYKBD = 11,
54             MUTE = 12,
55             LATCH_MODE = 13,
56             OCTAVE_MODE = 14,
57             OCTAVE_LOW = 15,
58             OCTAVE_HIGH = 16,
59             INDEX_IN1 = 17,
60             INDEX_IN2 = 18,
61             RANGE_IN1 = 19,
62             RANGE_IN2 = 20,
63             ENABLE_TRIGLEGATO = 21,
64             REPEAT_MODE = 22,
65             RPATTERNFLAG = 23,
66             DEFER = 24,
67             PATTERN_PRESET = 25,
68             TRANSPORT_MODE = 26,
69             TEMPO = 27,
70             HOST_TEMPO = 28,
71             HOST_POSITION = 29,
72             HOST_SPEED = 30
73     };
74 
75     ArpWidgetLV2(
76         LV2UI_Controller ct,
77         LV2UI_Write_Function write_function,
78         const LV2_Feature *const *host_features
79         );
80     ~ArpWidgetLV2();
81 
82     void port_event(uint32_t port_index,
83         uint32_t buffer_size, uint32_t format, const void *buffer);
84     void sendUIisUp(bool on);
85 
86   public slots:
87     void mapParam(int value);
88     void mapBool(bool on);
89     void updatePattern(const QString&);
90     void receivePattern(LV2_Atom* atom);
91     void sendPattern(const QString & p);
92 
93   protected:
94     void updateParam(int index, float fValue) const;
95 
96   private:
97     LV2UI_Controller     m_controller;
98     LV2UI_Write_Function writeFunction;
99     QCheckBox* transportBox;
100     QSpinBox* tempoSpin;
101     QMidiArpURIs m_uris;
102     LV2_Atom_Forge forge;
103     LV2_Atom_Forge_Frame frame;
104 
105     QString newPattern;
106     double mouseXCur, mouseYCur;
107     bool receivePatternFlag;
108     bool receivedPatternOnce;
109 };
110 
111 #endif
112