~ubuntu-branches/ubuntu/trusty/aeolus/trusty

« back to all changes in this revision

Viewing changes to model.h

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2007-05-14 22:18:54 UTC
  • Revision ID: james.westby@ubuntu.com-20070514221854-274rj6fqs5tegu7q
Tags: upstream-0.6.6+2
ImportĀ upstreamĀ versionĀ 0.6.6+2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2005 Fons Adriaensen <fons.adriaensen@skynet.be>
 
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 <clthreads.h>
 
25
#include "messages.h"
 
26
#include "lfqueue.h"
 
27
#include "addsynth.h"
 
28
#include "rankwave.h"
 
29
#include "global.h"
 
30
 
 
31
 
 
32
class Asect
 
33
{
 
34
public:
 
35
 
 
36
    Asect (void) { *_label = 0; }
 
37
 
 
38
    char    _label [64];
 
39
};
 
40
 
 
41
 
 
42
class Rank
 
43
{
 
44
public:
 
45
 
 
46
    int         _count;
 
47
    Addsynth   *_sdef;
 
48
    Rankwave   *_wave;
 
49
};
 
50
 
 
51
    
 
52
class Divis
 
53
{
 
54
public:
 
55
 
 
56
    enum { HAS_SWELL = 1, HAS_TREM = 2, NRANK = 32 };
 
57
    enum { SWELL, TFREQ, TMODD, NPARAM };
 
58
 
 
59
    Divis (void);
 
60
 
 
61
    char        _label [16];
 
62
    int         _flags;
 
63
    int         _dmask;
 
64
    int         _nrank;
 
65
    int         _asect;
 
66
    int         _keybd;
 
67
    Fparm       _param [NPARAM];
 
68
    Rank        _ranks [NRANK];
 
69
};
 
70
 
 
71
    
 
72
class Keybd
 
73
{
 
74
public:
 
75
 
 
76
    enum { IS_PEDAL = 256 };
 
77
 
 
78
    Keybd (void) : _flags (0) { *_label = 0; }
 
79
 
 
80
    char    _label [16];
 
81
    int     _flags;
 
82
};
 
83
 
 
84
    
 
85
class Ifelm
 
86
{
 
87
public:
 
88
 
 
89
    enum { DIVRANK, KBDRANK, COUPLER, TREMUL };
 
90
 
 
91
    Ifelm (void) : _state (0) { *_label = *_mnemo = 0; }
 
92
 
 
93
    char    _label [32];
 
94
    char    _mnemo [8];
 
95
    int     _type;
 
96
    int     _keybd;
 
97
    int     _state;
 
98
    U32     _action0;
 
99
    U32     _action1;
 
100
};
 
101
 
 
102
    
 
103
class Group
 
104
{
 
105
public:
 
106
 
 
107
    enum { NIFELM = 32 };
 
108
 
 
109
    Group (void) : _nifelm (0) { *_label = 0; }
 
110
 
 
111
    char     _label [16];
 
112
    int      _nifelm;
 
113
    Ifelm    _ifelms [NIFELM]; 
 
114
};
 
115
 
 
116
 
 
117
class Chconf
 
118
{
 
119
public:
 
120
 
 
121
    Chconf (void) { memset (_bits, 0, 16 * sizeof (U16)); }
 
122
 
 
123
    U16   _bits [16];
 
124
};
 
125
 
 
126
 
 
127
class Preset
 
128
{
 
129
public:
 
130
 
 
131
    Preset (void) { memset (_bits, 0, NGROUP * sizeof (U32)); }
 
132
 
 
133
    U32   _bits [NGROUP];
 
134
};
 
135
 
 
136
    
 
137
 
 
138
class Model : public A_thread
 
139
{
 
140
public:
 
141
 
 
142
    Model (Lfq_u32 *commq, const char *appid, const char *stops, const char *instr, const char *waves, bool uhome);
 
143
    virtual ~Model (void);
 
144
   
 
145
    U16 *chconf (void) const { return (U16 *) _chbits; }
 
146
    void terminate (void) {  put_event (EV_EXIT, 1); }
 
147
 
 
148
    void print (void);
 
149
 
 
150
private:
 
151
 
 
152
    virtual void thr_main (void);
 
153
 
 
154
    void init (void);
 
155
    void fini (void);
 
156
    void proc_mesg (ITC_mesg *M);
 
157
    void init_audio (void);
 
158
    void init_iface (void);
 
159
    void init_ranks (int comm);
 
160
    void proc_rank (int g, int i, int comm);
 
161
    void set_ifelm (int g, int i, int m);
 
162
    void clr_group (int g);
 
163
    void set_aupar (int s, int a, int p, float v);
 
164
    void set_dipar (int s, int d, int p, float v);
 
165
    void set_mconf (int i, U16 *d);
 
166
    void get_state (U32 *bits);
 
167
    void set_state (int bank, int pres);
 
168
    void midi_off (int mask);
 
169
    void retune (float freq, int temp);
 
170
    void recalc (int g, int i);
 
171
    void save (void);
 
172
    Rank *find_rank (int g, int i);
 
173
    int  read_instr (void);
 
174
    int  write_instr (void);
 
175
    int  get_preset (int bank, int pres, U32 *bits);
 
176
    void set_preset (int bank, int pres, U32 *bits);
 
177
    void ins_preset (int bank, int pres, U32 *bits);
 
178
    void del_preset (int bank, int pres);
 
179
    int  read_presets (void);
 
180
    int  write_presets (void);
 
181
 
 
182
    Lfq_u32        *_commq; 
 
183
    const char     *_appid;
 
184
    const char     *_stops;
 
185
    char            _instr [1024];
 
186
    char            _waves [1024];
 
187
    bool            _uhome;
 
188
    bool            _ready;
 
189
 
 
190
    Asect           _asect [NASECT];
 
191
    Keybd           _keybd [NKEYBD];
 
192
    Divis           _divis [NDIVIS];
 
193
    Group           _group [NGROUP];
 
194
 
 
195
    int             _nasect;
 
196
    int             _ndivis;
 
197
    int             _nkeybd;
 
198
    int             _ngroup;
 
199
    float           _fbase;
 
200
    int             _itemp;
 
201
    int             _count;
 
202
    int             _bank;
 
203
    int             _pres;
 
204
    int             _client;
 
205
    int             _portid;
 
206
    U16             _chbits [16];
 
207
    Chconf          _chconf [8];
 
208
    Preset         *_preset [NBANK][NPRES];
 
209
    M_audio_info   *_audio;
 
210
    M_midi_info    *_midi;
 
211
};
 
212
 
 
213
 
 
214
#endif
 
215