MuseScore  3.4
Music composition and notation
model.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003-2008 Fons Adriaensen <fons@kokkinizita.net>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 
20 #ifndef __MODEL_H
21 #define __MODEL_H
22 
23 
24 #include "messages.h"
25 #include "addsynth.h"
26 #include "rankwave.h"
27 #include "global.h"
28 
29 class Aeolus;
30 
31 class Asect
32 {
33 public:
34 
35  Asect (void) { *_label = 0; }
36 
37  char _label [64];
38 };
39 
40 
41 class Rank
42 {
43 public:
44 
45  int _count;
48 };
49 
50 
51 class Divis
52  {
53  public:
54 
55  enum { HAS_SWELL = 1, HAS_TREM = 2, NRANK = 32 };
56  enum { SWELL, TFREQ, TMODD, NPARAM };
57 
58  Divis();
59 
60  char _label [16];
61  int _flags;
62  int _dmask;
63  int _nrank;
64  int _asect;
65  int _keybd;
66  SyntiParameter _param [NPARAM];
67  Rank _ranks [NRANK];
68  };
69 
70 class Keybd
71 {
72 public:
73 
74  enum { IS_PEDAL = 256 };
75 
76  Keybd ();
77 
78  char _label [16];
79  int _flags;
80 };
81 
82 
83 class Ifelm
84 {
85 public:
86 
87  enum { DIVRANK, KBDRANK, COUPLER, TREMUL };
88 
89  Ifelm ();
90 
91  char _label [32];
92  char _mnemo [8];
93  int _type;
94  int _keybd;
95  int _state;
96  uint32_t _action0;
97  uint32_t _action1;
98 };
99 
100 class Group
101  {
102  public:
103 
104  enum { NIFELM = 32 };
105 
106  Group();
107 
108  char _label [16];
109  int _nifelm;
110  Ifelm _ifelms [NIFELM];
111  };
112 
113 class Chconf
114  {
115  public:
116 
117  Chconf () { memset (_bits, 0, 16 * sizeof (uint16_t)); }
118 
119  uint16_t _bits [16];
120  };
121 
122 //---------------------------------------------------------
123 // Preset
124 //---------------------------------------------------------
125 
126 class Preset
127  {
128  public:
129 
130  Preset () { memset (_bits, 0, NGROUP * sizeof (uint32_t)); }
131 
132  uint32_t _bits [NGROUP];
133  };
134 
135 //---------------------------------------------------------
136 // Model
137 //---------------------------------------------------------
138 
139 class Model
140  {
142  uint16_t* _midimap;
143  const char* _stops;
144  char _instr [1024];
145  const char* _waves;
146  bool _ready;
147 
148  Asect _asect [NASECT];
149  Keybd _keybd [NKEYBD];
150  Divis _divis [NDIVIS];
151  Group _group [NGROUP];
152 
153  int _nasect;
154  int _ndivis;
155  int _nkeybd;
156  int _ngroup;
157  float _fbase;
158  int _itemp;
159  int _count;
160  int _bank;
161  int _pres;
162  int _client;
163  int _portid;
164  int _sc_cmode; // stop control command mode
165  int _sc_group; // stop control group number
166  Chconf _chconf [8];
167  Preset* _preset [NBANK][NPRES];
168 
169  void init_audio();
170  void init_iface();
171  void init_ranks(int comm);
172  void proc_rank(int g, int i, int comm);
173  void set_mconf(int i, uint16_t *d);
174  void get_state(uint32_t *bits);
175  void set_state(int bank, int pres);
176  void midi_off(int mask);
177  void retune(float freq, int temp);
178  void recalc(int g, int i);
179  void save();
180  Rank* find_rank(int g, int i);
181  int read_instr();
182  int write_instr();
183  int get_preset(int bank, int pres, uint32_t *bits);
184  void set_preset(int bank, int pres, uint32_t *bits);
185  void ins_preset(int bank, int pres, uint32_t *bits);
186  void del_preset(int bank, int pres);
187  int read_presets();
188  bool writePresets();
189 
190  public:
191  Model (Aeolus* aeolus, uint16_t* midimap, const char* stops,
192  const char* instr, const char* waves);
193 
194  virtual ~Model() {}
195 
196  void set_ifelm (int g, int i, int m);
197  void clr_group (int g);
198  void init ();
199  };
200 
201 #endif
202 
uint32_t _action0
Definition: model.h:96
Definition: global.h:62
int _client
Definition: model.h:162
Definition: model.h:139
Aeolus * _aeolus
Definition: model.h:141
Definition: model.h:70
Chconf()
Definition: model.h:117
int _ngroup
Definition: model.h:156
int _keybd
Definition: model.h:94
uint32_t _action1
Definition: model.h:97
int _state
Definition: model.h:95
float _fbase
Definition: model.h:157
int _itemp
Definition: model.h:158
Definition: model.h:51
int _nrank
Definition: model.h:63
virtual ~Model()
Definition: model.h:194
Definition: addsynth.h:85
Definition: model.h:100
Definition: model.h:126
const char * _waves
Definition: model.h:145
Definition: global.h:64
Definition: model.h:31
int _portid
Definition: model.h:163
int _nasect
Definition: model.h:153
Asect(void)
Definition: model.h:35
Definition: global.h:59
Definition: rankwave.h:88
bool _ready
Definition: model.h:146
int _count
Definition: model.h:159
int _nkeybd
Definition: model.h:155
int _keybd
Definition: model.h:65
Definition: global.h:61
int _nifelm
Definition: model.h:109
Definition: sparm.h:42
Preset()
Definition: model.h:130
Rankwave * _wave
Definition: model.h:47
int _sc_cmode
Definition: model.h:164
const char * _stops
Definition: model.h:143
Definition: model.h:41
int _asect
Definition: model.h:64
Definition: global.h:60
Definition: aeolus.h:49
int _sc_group
Definition: model.h:165
char _label[64]
Definition: model.h:37
int _pres
Definition: model.h:161
int _flags
Definition: model.h:61
int _dmask
Definition: model.h:62
Addsynth * _sdef
Definition: model.h:46
Definition: model.h:83
Definition: global.h:65
Definition: model.h:56
int _flags
Definition: model.h:79
int _ndivis
Definition: model.h:154
int _count
Definition: model.h:45
int _bank
Definition: model.h:160
uint16_t * _midimap
Definition: model.h:142
int _type
Definition: model.h:93
Definition: model.h:113