summaryrefslogtreecommitdiff
path: root/synth/note.h
blob: 3c61aa81d1a026d8b395cb7831630fbe3d4b4181 (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
/*
    Copyright (C) 2010-2012 Florian Jung
     
    This file is part of flo's FM synth.

    flo's FM synth 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.

    flo's FM synth 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 flo's FM synth.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __NOTE_H__
#define __NOTE_H__

#include <jack/jack.h>

#include <list>

#include "programs.h"
#include "envelope.h"
#include "fixed.h"
#include "filter.h"
#include "note_skel.h"

class Note : public NoteSkel
{
	public:
		Note(int n, float v,program_t &prg, jack_nframes_t pf, fixed_t pb, int prg_no, float vol_fac);
		~Note();
		fixed_t get_sample();

		void release_quickly(jack_nframes_t maxt);
		void release();
		void reattack();
		bool still_active();
		void set_param(const parameter_t &p, fixed_t v);
		
		void recalc_actual_freq();
		
		void destroy();
		
	private:
		void do_ksl();
		void do_ksr();

		void recalc_factors();
		void apply_pfactor();
		
		void recalc_oscillator_phase_increment(int osc);

		Envelope **envelope;
		
		int env_frame_counter;
		
		double *freqfactor_factor;
		Envelope **factor_env;
		
		fixed_t *envval;
		fixed_t *oscval;
		fixed_t *old_oscval;
		int n_oscillators;
		oscillator_t *oscillator;
		fixed_t* oscillator_phase_increment;
		std::list<int>* fm_oscs;
		
		fixed_t sync_factor;
		fixed_t sync_phase;
		fixed_t sync_phase_increment;

		fixed_t actual_freq;
		
		pfactor_value_t pfactor;
		
		LowPassFilter filter;
		Envelope *filter_envelope;
		filter_params_t filter_params;
		int filter_update_counter;
		
		struct
		{
			oscillator_t *oscillator;
			filter_params_t filter_params;
		} orig;
};


#endif