MuseScore  3.4
Music composition and notation
synthesizer.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2012 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __SYNTHESIZER_H__
14 #define __SYNTHESIZER_H__
15 
17 
18 namespace Ms {
19 
20 struct MidiPatch;
21 class PlayEvent;
22 class Synth;
23 class SynthesizerGui;
24 
25 //---------------------------------------------------------
26 // SoundFontInfo
27 //---------------------------------------------------------
28 
29 struct SoundFontInfo {
30  QString fileName;
31  QString fontName;
32 
33  SoundFontInfo(QString _fileName) : fileName(_fileName), fontName(_fileName) {}
34  SoundFontInfo(QString _fileName, QString _fontName) : fileName(_fileName), fontName(_fontName) {}
35  };
36 
37 //---------------------------------------------------------
38 // Synthesizer
39 //---------------------------------------------------------
40 
41 class Synthesizer {
42  bool _active;
43 
44  protected:
45  float _sampleRate;
47 
48  public:
49  Synthesizer() : _active(false) { _gui = 0; }
50  virtual ~Synthesizer() {}
51  virtual void init(float sr) { _sampleRate = sr; }
52  float sampleRate() const { return _sampleRate; }
53 
54  virtual const char* name() const = 0;
55 
56  virtual void setMasterTuning(double) {}
57  virtual double masterTuning() const { return 440.0; }
58 
59  virtual bool loadSoundFonts(const QStringList&) = 0;
60  virtual bool addSoundFont(const QString&) { return false; }
61  virtual bool removeSoundFont(const QString&) { return false; }
62 
63  virtual std::vector<SoundFontInfo> soundFontsInfo() const = 0;
64 
65  virtual void process(unsigned, float*, float*, float*) = 0;
66  virtual void play(const PlayEvent&) = 0;
67 
68  virtual const QList<MidiPatch*>& getPatchInfo() const = 0;
69 
70  // get/set synthesizer state
71  virtual SynthesizerGroup state() const = 0;
72  virtual bool setState(const SynthesizerGroup&) = 0;
73  virtual void setValue(int, double) {}
74  virtual double value(int) const { return 0.0; }
75 
76  void reset() { _active = false; }
77  bool active() const { return _active; }
78  void setActive(bool val = true) { _active = val; }
79 
80  virtual void allSoundsOff(int /*channel*/) {}
81  virtual void allNotesOff(int /*channel*/) {}
82 
83  virtual SynthesizerGui* gui() { return _gui; }
84  };
85 
86 }
87 #endif
88 
virtual void setValue(int, double)
Definition: synthesizer.h:73
Definition: synthesizer.h:41
virtual bool removeSoundFont(const QString &)
Definition: synthesizer.h:61
float _sampleRate
Definition: synthesizer.h:45
bool _active
Definition: synthesizer.h:42
SoundFontInfo(QString _fileName)
Definition: synthesizer.h:33
void reset()
Definition: synthesizer.h:76
Definition: synthesizer.h:29
Definition: synthesizergui.h:24
QString fileName
Definition: synthesizer.h:30
virtual void allNotesOff(int)
Definition: synthesizer.h:81
virtual double value(int) const
Definition: synthesizer.h:74
Definition: aeolus.cpp:26
float sampleRate() const
Definition: synthesizer.h:52
SynthesizerGui * _gui
Definition: synthesizer.h:46
Definition: synthesizerstate.h:40
Synthesizer()
Definition: synthesizer.h:49
virtual bool addSoundFont(const QString &)
Definition: synthesizer.h:60
virtual void init(float sr)
Definition: synthesizer.h:51
bool active() const
Definition: synthesizer.h:77
virtual void allSoundsOff(int)
Definition: synthesizer.h:80
void setActive(bool val=true)
Definition: synthesizer.h:78
virtual SynthesizerGui * gui()
Definition: synthesizer.h:83
virtual void setMasterTuning(double)
Definition: synthesizer.h:56
Definition: event.h:219
virtual ~Synthesizer()
Definition: synthesizer.h:50
QString fontName
Definition: synthesizer.h:31
SoundFontInfo(QString _fileName, QString _fontName)
Definition: synthesizer.h:34
virtual double masterTuning() const
Definition: synthesizer.h:57