MuseScore  3.4
Music composition and notation
addsynth.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 __ADDSYNTH_H
21 #define __ADDSYNTH_H
22 
23 #define N_NOTE 11
24 #define N_HARM 64
25 #define NOTE_MIN 36
26 #define NOTE_MAX 96
27 
28 
29 //---------------------------------------------------------
30 // N_func
31 //---------------------------------------------------------
32 
33 class N_func
34  {
35  int _b;
36  float _v [N_NOTE];
37 
38  public:
39 
40  N_func();
41  void reset (float v);
42  void setv (int i, float v);
43  void clrv (int i);
44  float vs (int i) const { return _v [i]; }
45  int st (int i) const { return (_b & (1 << i)) ? 1 : 0; }
46  float vi (int n) const {
47  int i = n / 6;
48  int k = n - 6 * i;
49  float v = _v [i];
50  if (k)
51  v += k * (_v [i + 1] - v) / 6;
52  return v;
53  }
54  void write(FILE*);
55  void read(QFile*);
56  };
57 
58 //---------------------------------------------------------
59 // HN_func
60 //---------------------------------------------------------
61 
62 class HN_func
63  {
64  N_func _h [N_HARM];
65 
66  public:
67 
68  HN_func() {}
69  void reset (float v);
70  void setv (int i, float v);
71  void clrv (int i);
72  void setv (int h, int i, float v) { _h [h].setv (i, v); }
73  void clrv (int h, int i) { _h [h].clrv (i); }
74  float vs (int h, int i) const { return _h [h].vs (i); }
75  int st (int h, int i) const { return _h [h].st (i); }
76  float vi (int h, int n) const { return _h [h].vi (n); }
77  void write (FILE *F, int k);
78  void read (QFile *F, int k);
79  };
80 
81 //---------------------------------------------------------
82 // Addsynth
83 //---------------------------------------------------------
84 
85 class Addsynth
86  {
87  public:
88  Addsynth();
89 
90  void reset();
91  int save (const char *sdir);
92  int load (const char *sdir);
93 
94  char _filename [64];
95  char _stopname [32];
96  char _copyrite [56];
97  char _mnemonic [8];
98  char _comments [56];
99  char _reserved [8];
100  int32_t _n0;
101  int32_t _n1;
102  int32_t _fn;
103  int32_t _fd;
116 
117  char _pan;
118  int32_t _del;
119  };
120 
121 
122 #endif
123 
int32_t _fd
Definition: addsynth.h:103
int32_t _del
Definition: addsynth.h:118
void setv(int h, int i, float v)
Definition: addsynth.h:72
char _pan
Definition: addsynth.h:117
float vs(int h, int i) const
Definition: addsynth.h:74
N_func _n_dcd
Definition: addsynth.h:111
HN_func _h_atp
Definition: addsynth.h:115
int _b
Definition: addsynth.h:35
int32_t _fn
Definition: addsynth.h:102
float vi(int n) const
Definition: addsynth.h:46
int st(int h, int i) const
Definition: addsynth.h:75
N_func _n_ran
Definition: addsynth.h:106
int32_t _n1
Definition: addsynth.h:101
Definition: addsynth.h:85
int32_t _n0
Definition: addsynth.h:100
HN_func()
Definition: addsynth.h:68
Definition: addsynth.h:62
HN_func _h_att
Definition: addsynth.h:114
N_func _n_ins
Definition: addsynth.h:107
N_func()
Definition: addsynth.cpp:33
void write(FILE *)
Definition: addsynth.cpp:127
HN_func _h_lev
Definition: addsynth.h:112
void read(QFile *)
Definition: addsynth.cpp:157
void setv(int i, float v)
Definition: addsynth.cpp:53
N_func _n_vol
Definition: addsynth.h:104
Definition: addsynth.h:33
#define N_HARM
Definition: addsynth.h:24
void clrv(int i)
Definition: addsynth.cpp:89
float vs(int i) const
Definition: addsynth.h:44
float _v[N_NOTE]
Definition: addsynth.h:36
void reset(float v)
Definition: addsynth.cpp:42
int st(int i) const
Definition: addsynth.h:45
N_func _n_atd
Definition: addsynth.h:109
N_func _n_off
Definition: addsynth.h:105
N_func _n_dct
Definition: addsynth.h:110
void clrv(int h, int i)
Definition: addsynth.h:73
#define N_NOTE
Definition: addsynth.h:23
float vi(int h, int n) const
Definition: addsynth.h:76
HN_func _h_ran
Definition: addsynth.h:113
N_func _n_att
Definition: addsynth.h:108