blob: d209ea916bf1918252bead889409223f4327f696 (
plain)
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
|
//=============================================================================
// MusE
// Linux Music Editor
//
// Copyright (C) 1999-2010 by Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef __CONTROLFIFO_H__
#define __CONTROLFIFO_H__
#define CONTROL_FIFO_SIZE 8192
//---------------------------------------------------------
// ControlEvent
// Item struct for ControlFifo.
//---------------------------------------------------------
struct ControlEvent
{
// Unique: Whether the item must not be skipped, even if it has the same
// (possibly rounded) frame and index as the previous item. This is mainly for
// dssi-vst guis, they require acknowledgment of every message.
bool unique;
unsigned long idx;
float value;
unsigned long frame;
};
//---------------------------------------------------------
// ControlFifo
//---------------------------------------------------------
class ControlFifo
{
ControlEvent fifo[CONTROL_FIFO_SIZE];
volatile int size;
int wIndex;
int rIndex;
public:
ControlFifo() { clear(); }
bool put(const ControlEvent& event); // returns true on fifo overflow
ControlEvent get();
const ControlEvent& peek(int n = 0);
void remove();
bool isEmpty() const { return size == 0; }
void clear() { size = 0, wIndex = 0, rIndex = 0; }
int getSize() const { return size; }
};
#endif
|