File: zone.h

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-11
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 210,672 kB
  • sloc: cpp: 291,093; xml: 200,238; sh: 3,779; ansic: 1,447; python: 393; makefile: 240; perl: 82; pascal: 79
file content (126 lines) | stat: -rw-r--r-- 3,632 bytes parent folder | download | duplicates (8)
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
//=============================================================================
//  MuseSynth
//  Music Software Synthesizer
//
//  Copyright (C) 2013 Werner Schweer
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2
//  as published by the Free Software Foundation and appearing in
//  the file LICENCE.GPL
//=============================================================================

#ifndef __ZONE_H__
#define __ZONE_H__

class Sample;
class Channel;

//---------------------------------------------------------
//   Trigger
//---------------------------------------------------------

enum class Trigger : char {
      ATTACK, RELEASE, FIRST, LEGATO, CC
      };

//---------------------------------------------------------
//   LoopMode
//---------------------------------------------------------

enum class LoopMode : char {
      NO_LOOP, ONE_SHOT, CONTINUOUS, SUSTAIN
      };

//---------------------------------------------------------
//   OffMode
//---------------------------------------------------------

enum class OffMode : char {
      FAST, NORMAL
      };

enum class FilterType {
      lpf_2p, //default, double-pole low-pass filter
      lpf_1p, //single-pole low-pass filter
      hpf_2p, //double-pole high-pass filter
      hpf_1p, //single-pole high-pass filter
      bpf_2p, //double-pole band-pass filter
      brf_2p //double-pole band-reject filter
      };

//---------------------------------------------------------
//   Zone
//---------------------------------------------------------

struct Zone {
      Sample* sample = 0;
      long long offset  = 0; //[0, 4294967295]
      int  seq     = 0;
      int seqLen   = 0;
      int seqPos   = 0;

      char keyLo   = 0;
      char keyHi   = 127;
      char veloLo  = 0;
      char veloHi  = 127;
      char keyBase = 60;
      int tune     = 0;       // fine tuning in cent (-100 - +100)
      double pitchKeytrack = 100.0;
      float volume = 1.0;
      float lVol   = .5;
      float rVol   = .5;
      float ampVeltrack  = 100;      // amplifier velocity tracking
      float ampegDelay   = 0.0;
      float ampegStart   = 0.0;
      float ampegAttack  = 1.0;
      float ampegHold    = 0.0;
      float ampegDecay   = 0.0;
      float ampegSustain = 1.0;
      float ampegRelease = 200.0;     // release time in ms
      float ampegVel2Delay    = 0.0;
      float ampegVel2Attack   = 0.0;
      float ampegVel2Hold     = 0.0;
      float ampegVel2Decay    = 0.0;
      float ampegVel2Sustain  = 0.0;
      float ampegVel2Release  = 0.0;
      float rtDecay = 0.0;
      float delay = 0.0;
      int pan = 0;
      float group_volume = 1.0;
      float global_volume = 1.0;

      //filters
      bool isCutoffDefined;
      float cutoff; //[0, sampleRate / 2] Hz
      int fil_keytrack; //[0, 1200] cents
      int fil_keycenter; //[0, 127]
      int fil_veltrack; //[-9600, 9600] cents
      FilterType fil_type = FilterType::lpf_2p;

      Trigger trigger = Trigger::ATTACK;
      LoopMode loopMode = LoopMode::NO_LOOP;
      OffMode offMode = OffMode::FAST;
      int group = 0;
      int offBy = 0;
      long long loopStart, loopEnd;
      double loRand = 0.0;
      double hiRand = 1.0;

      std::map<int, double> gainOnCC;
      double ccGain = 1.0;

      int onLocc[128];
      int onHicc[128];
      int locc[128];
      int hicc[128];
      bool useCC = false;

      Zone();
      ~Zone();
      bool match(Channel*, int key, int velo, Trigger, double rand, int cc, int ccVal);
      void updateCCGain(Channel* c);
      };

#endif