summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.h
blob: 12257b590349e4583cdc10344312a4f523e56523 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
  ZynAddSubFX - a software synthesizer
 
  Controller.h - (Midi) Controllers implementation
  Copyright (C) 2002-2005 Nasca Octavian Paul
  Author: Nasca Octavian Paul

  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License 
  as published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License (version 2) for more details.

  You should have received a copy of the GNU General Public License (version 2)
  along with this program; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

*/


#ifndef CONTROLLER_H
#define CONTROLLER_H

#include "../globals.h"
#include "../Misc/XMLwrapper.h"

class Controller{
    public:
	Controller();
	~Controller();
	void resetall();

        void add2XML(XMLwrapper *xml);
	void defaults();
        void getfromXML(XMLwrapper *xml);

    //Controllers functions
	void setpitchwheel(int value);
	void setpitchwheelbendrange(unsigned short int value);
	void setexpression(int value);
	void setpanning(int value);
	void setfiltercutoff(int value);
	void setfilterq(int value);
	void setbandwidth(int value);
	void setmodwheel(int value);
	void setfmamp(int value);
	void setvolume(int value);
	void setsustain(int value);
        void setportamento(int value);
	void setresonancecenter(int value);
	void setresonancebw(int value);


	void setparameternumber(unsigned int type,int value);//used for RPN and NRPN's
	int getnrpn(int *parhi, int *parlo, int *valhi, int *vallo);

	int initportamento(REALTYPE oldfreq,REALTYPE newfreq);//returns 1 if the portamento's conditions are true, else return 0
	void updateportamento(); //update portamento values 

    // Controllers values 
    struct {//Pitch Wheel
	int data;
	short int bendrange;//bendrange is in cents
	REALTYPE relfreq;//the relative frequency (default is 1.0)
    } pitchwheel;
    
    struct{//Expression
	int data;
	REALTYPE relvolume;
	unsigned char receive;
    } expression;

    struct{//Panning
	int data;
	REALTYPE pan;
	unsigned char depth;
    } panning;
    	

    struct{//Filter cutoff
	int data;
	REALTYPE relfreq;
	unsigned char depth;
    } filtercutoff;

    struct{//Filter Q
	int data;
	REALTYPE relq;
	unsigned char depth;
    } filterq;

    struct{//Bandwidth
	int data;
	REALTYPE relbw;
	unsigned char depth;
	unsigned char exponential;
    } bandwidth;

    struct {//Modulation Wheel
	int data;
	REALTYPE relmod;
	unsigned char depth;
	unsigned char exponential;
    } modwheel;

    struct{//FM amplitude
	int data;
	REALTYPE relamp;
	unsigned char receive;
    } fmamp;

    struct{//Volume
	int data;
	REALTYPE volume;
	unsigned char receive;
    } volume;

    struct{//Sustain
	int data,sustain;
	unsigned char receive;
    } sustain;

    struct{//Portamento
	//parameters
	int data;
	unsigned char portamento;
	
	//pitchthresh is the threshold of enabling protamento
	//pitchthreshtype -> enable the portamento only below(0)/above(1) the threshold
	unsigned char receive,time,pitchthresh,pitchthreshtype;

	//'up portanemto' means when the frequency is rising (eg: the portamento is from 200Hz to 300 Hz)
	//'down portanemto' means when the frequency is lowering (eg: the portamento is from 300Hz to 200 Hz)
	unsigned char updowntimestretch;//this value represent how the portamento time is reduced
	//0 - for down portamento, 1..63 - the up portamento's time is smaller than the down portamento
	//64 - the portamento time is always the same
	//64-126 - the down portamento's time is smaller than the up portamento
	//127 - for upper portamento

	REALTYPE freqrap;//this value is used to compute the actual portamento
	int noteusing;//this is used by the Part:: for knowing which note uses the portamento
	int used;//if a the portamento is used by a note
	//internal data
	REALTYPE x,dx;//x is from 0.0 (start portamento) to 1.0 (finished portamento), dx is x increment
	REALTYPE origfreqrap;// this is used for computing oldfreq value from x
    } portamento;
    
    struct{//Resonance Center Frequency
	int data;
	REALTYPE relcenter;
	unsigned char depth;
    } resonancecenter;

    struct{//Resonance Bandwidth
	int data;
	REALTYPE relbw;
	unsigned char depth;
    } resonancebandwidth;
    

    /* RPN and NPRPN */
    struct{//nrpn
	int parhi,parlo;
	int valhi,vallo;
	unsigned char receive;//this is saved to disk by Master
    } NRPN;
    
    private:
};





#endif