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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: organ.h,v 1.5 2004/04/15 13:46:18 wschweer Exp $
//
// Parts of this file taken from:
// Organ - Additive Organ Synthesizer Voice
// Copyright (c) 1999, 2000 David A. Bartold
//
// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
//=========================================================
#ifndef __ORGAN_H__
#define __ORGAN_H__
#include "muse/midictrl.h"
#include "libsynti/mess2.h"
static const int NO_VOICES = 128; // max polyphony
static const int NO_KEYS = 97 - 36;
class OrganGui;
static const int MAX_ATTENUATION = 960;
static const int NO_BUSES = 9;
static const int NO_WHEELS = 91;
static const int NO_ELEMENTS = 194;
enum {
DRAWBAR0 = CTRL_RPN14_OFFSET, DRAWBAR1, DRAWBAR2,
DRAWBAR3, DRAWBAR4, DRAWBAR5, DRAWBAR6, DRAWBAR7, DRAWBAR8,
ATTACK_LO, DECAY_LO, SUSTAIN_LO, RELEASE_LO,
ATTACK_HI, DECAY_HI, SUSTAIN_HI, RELEASE_HI,
BRASS, FLUTE, REED, VELO
};
//---------------------------------------------------------
// Wheel
//---------------------------------------------------------
struct Wheel {
unsigned freq256;
unsigned accu;
int refCount;
bool active;
float gain[NO_BUSES];
// envelopes:
float* env[NO_BUSES];
int envCount[NO_BUSES];
float deltaGain[NO_BUSES];
};
//---------------------------------------------------------
// Voice
//---------------------------------------------------------
struct Voice {
bool isOn;
int pitch;
};
struct Elem {
short wheel;
short bus;
float level;
Elem() { bus = -1; }
Elem(short w, short b, float l) : wheel(w), bus(b), level(l) {}
};
//---------------------------------------------------------
// Organ
//---------------------------------------------------------
class Organ : public Mess2 {
static int useCount;
static float* waveTable;
static double cb2amp_tab[MAX_ATTENUATION];
static unsigned freq256[128][NO_BUSES];
static double cb2amp(int cb);
static Elem routing[NO_KEYS][NO_ELEMENTS];
static float* attackEnv;
static float* releaseEnv;
static int envSize;
static int resolution;
static int resolution256;
double volume;
float drawBarGain[NO_BUSES];
Wheel wheels[NO_WHEELS];
Voice voices[NO_VOICES];
QList<Wheel*> activeWheels;
void noteoff(int channel, int pitch);
void setController(int ctrl, int val);
virtual void process(float**, int, int);
virtual bool playNote(int channel, int pitch, int velo);
virtual bool setController(int channel, int ctrl, int val);
virtual bool sysex(int, const unsigned char*);
virtual bool guiVisible() const;
virtual void showGui(bool);
virtual bool hasGui() const { return true; }
virtual void getGeometry(int* x, int* y, int* w, int* h) const;
virtual void setGeometry(int x, int y, int w, int h);
OrganGui* gui;
public:
friend class OrganGui;
Organ(int sampleRate);
~Organ();
bool init(const char* name);
};
#endif
|