1 //========================================================= 2 // MusE 3 // Linux Music Editor 4 // $Id: mess.h,v 1.3.2.3 2009/11/19 04:20:33 terminator356 Exp $ 5 // (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; version 2 of 10 // the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 // 21 //========================================================= 22 23 #ifndef __MESS_H__ 24 #define __MESS_H__ 25 26 #define MESS_MAJOR_VERSION 1 27 #define MESS_MINOR_VERSION 1 28 29 #include "mpevent.h" 30 31 struct MessP; 32 33 //--------------------------------------------------------- 34 // MessConfig 35 // Information to be passed to MESS::instantiate(). 36 // The plugin is free to store these values as it wishes 37 // without relying on any particular libraries. 38 //--------------------------------------------------------- 39 40 struct MessConfig { 41 unsigned int _segmentSize; 42 int _sampleRate; 43 int _minMeterVal; 44 bool _useDenormalBias; 45 float _denormalBias; 46 bool _leftMouseButtonCanDecrease; 47 const char* _configPath; 48 const char* _cachePath; 49 const char* _globalLibPath; 50 const char* _globalSharePath; 51 const char* _userPath; 52 const char* _projectPath; 53 MessConfigMessConfig54 MessConfig() { 55 _segmentSize = 1024; 56 _sampleRate = 44100; 57 _minMeterVal = 0; 58 _useDenormalBias = false; 59 _denormalBias = 0.0; 60 _leftMouseButtonCanDecrease = false; 61 _configPath = 0; 62 _cachePath = 0; 63 _globalLibPath = 0; 64 _globalSharePath = 0; 65 _userPath = 0; 66 _projectPath = 0; 67 } 68 MessConfigMessConfig69 MessConfig(unsigned int segmentSize, 70 int sampleRate, 71 int minMeterVal, 72 bool useDenormalBias, 73 float denormalBias, 74 bool leftMouseButtonCanDecrease, 75 const char* configPath, 76 const char* cachePath, 77 const char* globalLibPath, 78 const char* globalSharePath, 79 const char* userPath, 80 const char* projectPath) 81 { 82 _segmentSize = segmentSize; 83 _sampleRate = sampleRate; 84 _minMeterVal = minMeterVal; 85 _useDenormalBias = useDenormalBias; 86 _denormalBias = denormalBias; 87 _leftMouseButtonCanDecrease = leftMouseButtonCanDecrease; 88 _configPath = configPath; 89 _cachePath = cachePath; 90 _globalLibPath = globalLibPath; 91 _globalSharePath = globalSharePath; 92 _userPath = userPath; 93 _projectPath = projectPath; 94 } 95 }; 96 97 //--------------------------------------------------------- 98 // MidiPatch 99 //--------------------------------------------------------- 100 101 #define MP_TYPE_GM 1 102 #define MP_TYPE_GS 2 103 #define MP_TYPE_XG 4 104 #define MP_TYPE_LBANK 8 105 #define MP_TYPE_HBANK 16 106 107 struct MidiPatch { 108 signed char typ; // 1 - GM 2 - GS 4 - XG 109 signed char hbank, lbank, prog; 110 const char* name; 111 }; 112 113 //--------------------------------------------------------- 114 // Mess 115 // MusE experimental software synth 116 // Instance virtual interface class 117 // NOTICE: If implementing sysex support, be sure to make a unique ID and use 118 // it to filter out unrecognized sysexes. Headers should be constructed as: 119 // MUSE_SYNTH_SYSEX_MFG_ID The MusE SoftSynth Manufacturer ID byte (0x7C) found in midi.h 120 // 0xNN The synth's unique ID byte 121 //--------------------------------------------------------- 122 123 class Mess { 124 MessP* d; 125 126 int _sampleRate; 127 int _channels; // 1 - mono, 2 - stereo 128 129 public: 130 Mess(int channels); 131 virtual ~Mess(); 132 133 // This is only a kludge required to support old songs' midistates. Do not use in any new synth. oldMidiStateHeader(const unsigned char **)134 virtual int oldMidiStateHeader(const unsigned char** /*data*/) const { return 0; } 135 channels()136 int channels() const { return _channels; } sampleRate()137 int sampleRate() const { return _sampleRate; } setSampleRate(int r)138 void setSampleRate(int r) { _sampleRate = r; } 139 processMessages()140 virtual void processMessages() { }; 141 virtual void process(unsigned pos, float** data, int offset, int len) = 0; 142 143 // the synti has to (re-)implement processEvent() or provide 144 // some of the next three functions: 145 146 virtual bool processEvent(const MusECore::MidiPlayEvent&); setController(int,int,int)147 virtual bool setController(int, int, int) { return false; } playNote(int,int,int)148 virtual bool playNote(int, int, int) { return false; } sysex(int,const unsigned char *)149 virtual bool sysex(int, const unsigned char*) { return false; } 150 getInitData(int * n,const unsigned char **)151 virtual void getInitData(int* n, const unsigned char**) /*const*/ { *n = 0; } // No const: Synths may need to allocate member pointers. getControllerInfo(int,const char **,int *,int *,int *,int *)152 virtual int getControllerInfo(int, const char**, int*, int*, int*, int*) const {return 0;} getPatchName(int,int,bool)153 virtual const char* getPatchName(int, int, bool) const { return "?"; } getPatchInfo(int,const MidiPatch *)154 virtual const MidiPatch* getPatchInfo(int, const MidiPatch*) const { return 0; } 155 // Returns true if a note name list is found for the given patch. 156 // If true, name either contains the note name, or is NULL if no note name was found. getNoteSampleName(bool,int,int,int,const char **)157 virtual bool getNoteSampleName(bool /*drum*/, int /*channel*/, 158 int /*patch*/, int /*note*/, 159 const char** /*name*/) const { return false; } 160 161 // synthesizer -> host communication 162 void sendEvent(MusECore::MidiPlayEvent); // called from synti 163 MusECore::MidiPlayEvent receiveEvent(); // called from host 164 int eventsPending() const; 165 166 // GUI interface routines hasNativeGui()167 virtual bool hasNativeGui() const { return false; } nativeGuiVisible()168 virtual bool nativeGuiVisible() const { return false; } showNativeGui(bool)169 virtual void showNativeGui(bool) {} 170 virtual void getNativeGeometry(int* x, int* y, int* w, int* h) const; setNativeGeometry(int,int,int,int)171 virtual void setNativeGeometry(int, int, int, int) {} guiHeartBeat()172 virtual void guiHeartBeat() {} 173 }; 174 175 //--------------------------------------------------------- 176 // MESS 177 // Class descriptor 178 //--------------------------------------------------------- 179 180 struct MESS { 181 const char* name; 182 const char* description; 183 const char* version; 184 int majorMessVersion, minorMessVersion; 185 Mess* (*instantiate)(unsigned long long parentWinId, const char* name, const MessConfig* config); 186 }; 187 188 extern "C" { 189 const MESS* mess_descriptor(); 190 } 191 192 typedef const MESS* (*MESS_Descriptor_Function)(); 193 194 #endif 195 196