File: foo-yc20.h

package info (click to toggle)
foo-yc20 1.3.0-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch
  • size: 1,820 kB
  • ctags: 1,964
  • sloc: cpp: 25,199; ansic: 207; makefile: 113
file content (141 lines) | stat: -rw-r--r-- 3,566 bytes parent folder | download | duplicates (2)
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
/*
    Foo-YC20 
    Copyright (C) 2010  Sampo Savolainen <v2@iki.fi>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    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 for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _FOO_YC20_H
#define _FOO_YC20_H

#include <map>
#include <string>

#include <faust-dsp.h>

#ifdef __SSE__
    #include <xmmintrin.h>
    #ifdef __SSE2__
        #define TURNOFFDENORMALS { _mm_setcsr(_mm_getcsr() | 0x8040); }
    #else
        #define TURNOFFDENORMALS { _mm_setcsr(_mm_getcsr() | 0x8000); }
    #endif
#else
    #define TURNOFFDENORMALS 
#endif

class YC20Exposable
{
	public:
		virtual ~YC20Exposable() {};
		virtual void queueExpose(int) = 0;
		virtual void updateControlsFromState() = 0;
};

class MidiCC 
{
public:
        MidiCC(int a, int b) { cc = a; value = b;}

        int cc;
        int value;
};

class Control;

class Control
{
	public:

		Control(int cc, float min, float max) { 
			controlChange = cc; minValue = min; maxValue = max; 
		}

		Control(int cc) {
			controlChange = cc; minValue = 0.0; maxValue = 1.0;
		}

		int getCC() const { return controlChange; }
		float getMin() const { return minValue; }
		float getMax() const { return maxValue; }

		void setValueFromCC(int value) const { *zone = minValue + (maxValue - minValue) * ((float)value)/127.0; }
		float *getZone() const { return zone; }
		void  setZone(float *z) { zone = z; }

	private:
		int controlChange;
		float minValue;
		float maxValue;
		float *zone;
};


class YC20Processor : public UI
{
	public:
		YC20Processor();
		virtual ~YC20Processor();

		void setUI(YC20Exposable *interface) { ui = interface; }
	
		// from Faust UI
		void addButton(const char* label, float* zone);
		void addToggleButton(const char* label, float* zone) {};
		void addCheckButton(const char* label, float* zone) {};
		void addVerticalSlider(const char* label, float* zone, float init, float min, float max, float step);
		void addHorizontalSlider(const char* label, float* zone, float init, float min, float max, float step);
		void addNumEntry(const char* label, float* zone, float init, float min, float max, float step) {};

		void openFrameBox(const char* label) {};
		void openTabBox(const char* label) {};
		void openHorizontalBox(const char* label) {};
		void openVerticalBox(const char* label) {};
		void closeBox() {};

		void declare(float* zone, const char* key, const char* value) {};

		dsp *getDSP() const { return processor; }
		void setDSP(dsp *);

		// MIDI callback
		void setKey(int key, float value) { *keys[key] = value; }

		Control *getControl(const std::string &label) { return controlPerLabel[label]; }

		// Configuration stuff
		void loadConfiguration(std::string &file);
		void loadConfiguration();
		void saveConfiguration();

	protected:

		// Pointers to DSP key values
		float *keys[61];

		// Controls
		std::map<std::string, Control *> controlPerLabel;

		// The actual DSP processor
		dsp *processor;

		// The UI if there is one
		YC20Exposable *ui;

		std::string configFile;

};


#endif /* _FOO_YC20_H */