File: minstrument.h

package info (click to toggle)
muse 0.6.3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,936 kB
  • ctags: 7,446
  • sloc: cpp: 66,262; sh: 8,355; makefile: 755; ansic: 172
file content (114 lines) | stat: -rw-r--r-- 3,272 bytes parent folder | download
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
//=========================================================
//  MusE
//  Linux Music Editor
//  $Id: minstrument.h,v 1.1.1.1 2003/10/29 10:05:10 wschweer Exp $
//
//  (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================

#ifndef __MINSTRUMENT_H__
#define __MINSTRUMENT_H__

#include "globaldefs.h"
#include <list>
#include <vector>
#include <qstring.h>

class MidiPort;
class QPopupMenu;
class MidiPlayEvent;
class Xml;
class EventList;

//---------------------------------------------------------
//   Patch
//---------------------------------------------------------

struct Patch {
      signed char typ;                     // 1 - GM  2 - GS  4 - XG
      signed char hbank, lbank, prog;
      QString name;
      bool drum;
      void read(Xml&);
      };

//---------------------------------------------------------
//   MidiInstrument
//---------------------------------------------------------

class MidiInstrument {

   protected:
      EventList* _midiInit;
      EventList* _midiReset;
      EventList* _midiState;
      QString _name;

   public:
      MidiInstrument();
      virtual ~MidiInstrument();
      MidiInstrument(const QString& txt);
      const QString& iname() const      { return _name; }
      void setIName(const QString& txt) { _name = txt; }

      EventList* midiInit() const       { return _midiInit; }
      EventList* midiReset() const      { return _midiReset; }
      EventList* midiState() const      { return _midiState; }

      void readMidiState(Xml& xml);
      virtual bool guiVisible() const   { return false; }
      virtual void showGui(bool)        {}
      virtual bool hasGui() const       { return false; }
      virtual void writeToGui(const MidiPlayEvent*) {}

      virtual void reset(int, MType);
      virtual const char* getPatchName(int,int,int,int,MType);
      virtual void populatePatchPopup(QPopupMenu*, int, MType) {}
      };

//---------------------------------------------------------
//   MidiInstrumentList
//---------------------------------------------------------

class MidiInstrumentList : public std::list<MidiInstrument*> {

   public:
      MidiInstrumentList() {}
      };

typedef std::list<MidiInstrument*>::iterator iMidiInstrument;
typedef std::list<Patch> PatchList;

//---------------------------------------------------------
//   PatchGroup
//---------------------------------------------------------

struct PatchGroup {
      QString name;
      PatchList patches;
      void read(Xml&);
      };

//---------------------------------------------------------
//   MidiIDFInstrument
//---------------------------------------------------------

class MidiIDFInstrument : public MidiInstrument {
      std::vector<PatchGroup> pg;

   public:
      MidiIDFInstrument() {};
      virtual void reset(int port, MType type);
      virtual const char* getPatchName(int, int, int, int, MType);
      virtual void populatePatchPopup(QPopupMenu*, int, MType);
      void read(Xml&);
      };

extern MidiInstrumentList midiInstruments;
extern MidiInstrument* genericMidiInstrument;
extern void initMidiInstruments();
extern MidiInstrument* registerMidiInstrument(const QString&);
extern void removeMidiInstrument(const QString& name);

#endif