1 //=============================================================================
2 //  MuseSynth
3 //  Music Software Synthesizer
4 //
5 //  Copyright (C) 2013 Werner Schweer
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License version 2
9 //  as published by the Free Software Foundation and appearing in
10 //  the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __ZONE_H__
14 #define __ZONE_H__
15 
16 class Sample;
17 class Channel;
18 
19 //---------------------------------------------------------
20 //   Trigger
21 //---------------------------------------------------------
22 
23 enum class Trigger : char {
24       ATTACK, RELEASE, FIRST, LEGATO, CC
25       };
26 
27 //---------------------------------------------------------
28 //   LoopMode
29 //---------------------------------------------------------
30 
31 enum class LoopMode : char {
32       NO_LOOP, ONE_SHOT, CONTINUOUS, SUSTAIN
33       };
34 
35 //---------------------------------------------------------
36 //   OffMode
37 //---------------------------------------------------------
38 
39 enum class OffMode : char {
40       FAST, NORMAL
41       };
42 
43 enum class FilterType {
44       lpf_2p, //default, double-pole low-pass filter
45       lpf_1p, //single-pole low-pass filter
46       hpf_2p, //double-pole high-pass filter
47       hpf_1p, //single-pole high-pass filter
48       bpf_2p, //double-pole band-pass filter
49       brf_2p //double-pole band-reject filter
50       };
51 
52 //---------------------------------------------------------
53 //   Zone
54 //---------------------------------------------------------
55 
56 struct Zone {
57       Sample* sample = 0;
58       long long offset  = 0; //[0, 4294967295]
59       int  seq     = 0;
60       int seqLen   = 0;
61       int seqPos   = 0;
62 
63       char keyLo   = 0;
64       char keyHi   = 127;
65       char veloLo  = 0;
66       char veloHi  = 127;
67       char keyBase = 60;
68       int tune     = 0;       // fine tuning in cent (-100 - +100)
69       double pitchKeytrack = 100.0;
70       float volume = 1.0;
71       float lVol   = .5;
72       float rVol   = .5;
73       float ampVeltrack  = 100;      // amplifier velocity tracking
74       float ampegDelay   = 0.0;
75       float ampegStart   = 0.0;
76       float ampegAttack  = 1.0;
77       float ampegHold    = 0.0;
78       float ampegDecay   = 0.0;
79       float ampegSustain = 1.0;
80       float ampegRelease = 200.0;     // release time in ms
81       float ampegVel2Delay    = 0.0;
82       float ampegVel2Attack   = 0.0;
83       float ampegVel2Hold     = 0.0;
84       float ampegVel2Decay    = 0.0;
85       float ampegVel2Sustain  = 0.0;
86       float ampegVel2Release  = 0.0;
87       float rtDecay = 0.0;
88       float delay = 0.0;
89       int pan = 0;
90       float group_volume = 1.0;
91       float global_volume = 1.0;
92 
93       //filters
94       bool isCutoffDefined;
95       float cutoff; //[0, sampleRate / 2] Hz
96       int fil_keytrack; //[0, 1200] cents
97       int fil_keycenter; //[0, 127]
98       int fil_veltrack; //[-9600, 9600] cents
99       FilterType fil_type = FilterType::lpf_2p;
100 
101       Trigger trigger = Trigger::ATTACK;
102       LoopMode loopMode = LoopMode::NO_LOOP;
103       OffMode offMode = OffMode::FAST;
104       int group = 0;
105       int offBy = 0;
106       long long loopStart, loopEnd;
107       double loRand = 0.0;
108       double hiRand = 1.0;
109 
110       std::map<int, double> gainOnCC;
111       double ccGain = 1.0;
112 
113       int onLocc[128];
114       int onHicc[128];
115       int locc[128];
116       int hicc[128];
117       bool useCC = false;
118 
119       Zone();
120       ~Zone();
121       bool match(Channel*, int key, int velo, Trigger, double rand, int cc, int ccVal);
122       void updateCCGain(Channel* c);
123       };
124 
125 #endif
126 
127