summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.h
blob: a2328e86bd8b0c33b2d0f56c44afc26031a82e7d (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
/*
  ZynAddSubFX - a software synthesizer
 
  PADnoteParameters.h - Parameters for PADnote (PADsynth)  
  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 PAD_NOTE_PARAMETERS_H
#define PAD_NOTE_PARAMETERS_H

#include "../Misc/XMLwrapper.h"
#include "../DSP/FFTwrapper.h"
#include "../globals.h"
#include "../Synth/OscilGen.h"
#include "../Synth/Resonance.h"
#include "../Misc/Util.h"

#include "EnvelopeParams.h"
#include "LFOParams.h"
#include "FilterParams.h"
#include "Presets.h"

class Master;

class PADnoteParameters:public Presets{
    public:
	PADnoteParameters(FFTwrapper *fft_,Master* master);
	~PADnoteParameters();
	
	void defaults();
	void add2XML(XMLwrapper *xml);
        void getfromXML(XMLwrapper *xml);
	
	//returns a value between 0.0-1.0 that represents the estimation perceived bandwidth
	REALTYPE getprofile(REALTYPE *smp,int size);
	
	//parameters
	
	//the mode: 0 - bandwidth, 1 - discrete (bandwidth=0), 2 - continous
	//the harmonic profile is used only on mode 0
	unsigned char Pmode;
	
	//Harmonic profile (the frequency distribution of a single harmonic)
	struct {
	    struct{//base function 
		unsigned char type;
		unsigned char par1;
	    }base;
	    unsigned char freqmult;//frequency multiplier of the distribution
	    struct{//the modulator of the distribution 
		unsigned char par1;
		unsigned char freq;
	    }modulator;
	    
	    unsigned char width;//the width of the resulting function after the modulation
	    struct{//the amplitude multiplier of the harmonic profile
		unsigned char mode;
		unsigned char type;
		unsigned char par1;
		unsigned char par2;
	    }amp;
	    bool autoscale;//if the scale of the harmonic profile is computed automaticaly
	    unsigned char onehalf;//what part of the base function is used to make the distribution
	}Php;

	
	unsigned int Pbandwidth;//the values are from 0 to 1000 
	unsigned char Pbwscale;//how the bandwidth is increased according to the harmonic's frequency
	
	struct{//where are positioned the harmonics (on integer multimplier or different places)
	    unsigned char type;
	    unsigned char par1,par2,par3;//0..255
	}Phrpos;

	struct {//quality of the samples (how many samples, the length of them,etc.)
	    unsigned char samplesize;
	    unsigned char basenote,oct,smpoct;
	} Pquality;
	
	//frequency parameters
	//If the base frequency is fixed to 440 Hz
	unsigned char Pfixedfreq;

	/* Equal temperate (this is used only if the Pfixedfreq is enabled)
	   If this parameter is 0, the frequency is fixed (to 440 Hz);
	   if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
	unsigned char PfixedfreqET;
	unsigned short int PDetune;//fine detune
	unsigned short int PCoarseDetune;//coarse detune+octave
	unsigned char PDetuneType;//detune type

	EnvelopeParams *FreqEnvelope; //Frequency Envelope
    	LFOParams *FreqLfo;//Frequency LFO

	//Amplitude parameters
	unsigned char PStereo;
	/* Panning -  0 - random 
		      1 - left
		     64 - center
		    127 - right */
	unsigned char PPanning;

	unsigned char PVolume;

	unsigned char PAmpVelocityScaleFunction;

	EnvelopeParams *AmpEnvelope;
   
	LFOParams *AmpLfo;   

	unsigned char PPunchStrength,PPunchTime,PPunchStretch,PPunchVelocitySensing;

	//Filter Parameters
	FilterParams *GlobalFilter;

	// filter velocity sensing
	unsigned char PFilterVelocityScale; 

	// filter velocity sensing
	unsigned char PFilterVelocityScaleFunction;
    
	EnvelopeParams *FilterEnvelope;
	LFOParams *FilterLfo;
	


	
	REALTYPE setPbandwidth(int Pbandwidth);//returns the BandWidth in cents
	REALTYPE getNhr(int n);//gets the n-th overtone position relatively to N harmonic

	void applyparameters(bool lockmutex);

	OscilGen *oscilgen;
	Resonance *resonance;
	
	struct{
	    int size;
	    REALTYPE basefreq;
	    REALTYPE *smp;
	}sample[PAD_MAX_SAMPLES],newsample;
	
    private:
	void generatespectrum_bandwidthMode(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust);
	void generatespectrum_otherModes(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust);
	void deletesamples();
	void deletesample(int n);
    
	FFTwrapper *fft;
	Master* master;
};



#endif