-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
synti.h
118 lines (89 loc) · 3.51 KB
/
synti.h
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
//=============================================================================
// MusE Score
// Linux Music Score Editor
// $Id: synti.h 5660 2012-05-22 14:17:39Z wschweer $
//
// Copyright (C) 2002-2009 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 __SYNTI_H__
#define __SYNTI_H__
struct MidiPatch;
class Event;
class Synth;
#include "libmscore/sparm.h"
//---------------------------------------------------------
// Synth
//---------------------------------------------------------
class Synth {
bool _active;
protected:
public:
Synth() : _active(false) {}
virtual ~Synth() {}
virtual void init(int sampleRate) = 0;
virtual const char* name() const = 0;
virtual void setMasterTuning(double) {}
virtual double masterTuning() const { return 440.0; }
virtual bool loadSoundFonts(const QStringList&) = 0;
virtual bool addSoundFont(const QString&) { return false; }
virtual bool removeSoundFont(const QString&) { return false; }
virtual QStringList soundFonts() const = 0;
virtual void process(unsigned, float*, float) = 0;
virtual void play(const Event&) = 0;
virtual const QList<MidiPatch*>& getPatchInfo() const = 0;
// set/get a single parameter
virtual SyntiParameter parameter(int /*id*/) const { return SyntiParameter(); }
virtual void setParameter(int /*id*/, double /*val*/) {}
virtual void setParameter(int /*id*/, const QString&) {}
// get/set synthesizer state
virtual SyntiState state() const = 0;
virtual void setState(SyntiState&) {}
void reset();
bool active() const { return _active; }
void setActive(bool val = true) { _active = val; }
virtual void allSoundsOff(int /*channel*/) {}
virtual void allNotesOff(int /*channel*/) {}
};
//---------------------------------------------------------
// MasterSynth
//---------------------------------------------------------
class MasterSynth {
QList<Synth*> syntis;
float _gain;
public:
MasterSynth();
~MasterSynth();
void init(int sampleRate);
void process(unsigned, float*);
void play(const Event&, int);
double gain() const { return _gain; }
void setGain(float val) { _gain = val; }
void setMasterTuning(double) {}
double masterTuning() const { return 440.0; }
int synthNameToIndex(const QString&) const;
QString synthIndexToName(int) const;
QList<MidiPatch*> getPatchInfo() const;
// set/get a single parameter
SyntiParameter parameter(int id) const;
void setParameter(int id, double val);
// get/set synthesizer state
SyntiState state() const;
void setState(SyntiState&);
Synth* synth(const QString& name);
void reset();
void allSoundsOff(int channel);
void allNotesOff(int channel);
};
#endif