/[svn]/linuxsampler/trunk/src/engines/common/Voice.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/common/Voice.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (hide annotations) (download) (as text)
Mon Apr 25 08:12:36 2011 UTC (13 years ago) by persson
File MIME type: text/x-c++hdr
File size: 7461 byte(s)
* sfz engine: implemeted filters. Filter types: lowpass, bandpass,
  bandreject and highpass. 1, 2, 4 and 6 pole filters. Opcodes:
  fil_type, cutoff, resonance, fil_veltrack, fil_keytrack,
  fil_keycenter, cutoff_cc, cutoff_chanaft.
* sfz engine: bugfix: zero ampeg_sustain didn't work
* gig engine: bugfix: pitch LFO controller "internal+aftertouch" was broken
* gig engine: bugfix: filter keyboard tracking was broken
* gig engine: filter performance fix (an unnecessary copy was made of
  the filter parameters in each sub fragment)
* ASIO driver: fixes for newer gcc versions (fix from PortAudio)

1 iliev 2012 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck *
6 persson 2175 * Copyright (C) 2005-2011 Christian Schoenebeck *
7 iliev 2012 * *
8     * This program is free software; you can redistribute it and/or modify *
9     * it under the terms of the GNU General Public License as published by *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifndef __LS_VOICE_H__
25 persson 2115 #define __LS_VOICE_H__
26 iliev 2012
27     #include "Event.h"
28 persson 2175 #include "../gig/Filter.h"
29 iliev 2012 #include "../../common/Pool.h"
30    
31 iliev 2015 #include <gig.h> // TODO: remove gig dependency
32    
33 iliev 2012 namespace LinuxSampler {
34    
35     class Voice {
36     public:
37     enum playback_state_t {
38     playback_state_end = 0,
39     playback_state_init = 1,
40     playback_state_ram = 2,
41     playback_state_disk = 3
42     };
43    
44 persson 2115 // Type bits. Mostly mutual exclusive, but a voice may both be of one shot type and require a release trigger at the same time.
45 iliev 2012 enum type_t {
46 persson 2115 type_normal = 0,
47     type_release_trigger_required = 1 << 1, ///< If the key of this voice will be released, it causes a release triggered voice to be spawned
48     type_release_trigger = 1 << 2, ///< Release triggered voice which cannot be killed by releasing its key
49     type_one_shot = 1 << 3, ///< Voice should not be released by note off
50     type_controller_triggered = 1 << 4 ///< Voice is triggered by MIDI CC instead of a note on
51 iliev 2012 };
52 iliev 2015
53     struct PitchInfo {
54     float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice
55     float PitchBend; ///< Current pitch value of the pitchbend wheel
56     float PitchBendRange; ///< The pitch range of the pitchbend wheel, value is in cents / 8192
57     };
58    
59     struct EGInfo {
60     double Attack;
61     double Decay;
62     double Release;
63     };
64    
65     struct SampleInfo {
66     uint SampleRate;
67     uint ChannelCount;
68     uint FrameSize;
69     uint TotalFrameCount;
70     uint BitDepth;
71     bool HasLoops;
72     uint LoopStart;
73     uint LoopLength;
74     uint LoopPlayCount; ///< Number of times the loop should be played (a value of 0 = infinite).
75     bool Unpitched; ///< sound which is not characterized by a perceived frequency
76     };
77    
78     struct RegionInfo {
79     uint8_t UnityNote; ///< The MIDI key number of the recorded pitch of the sample
80     int16_t FineTune;
81     int Pan; ///< Panorama / Balance (-64..0..63 <-> left..middle..right)
82     uint SampleStartOffset; ///< Number of samples the sample start should be moved
83    
84     double EG1PreAttack; ///< Preattack value of the sample amplitude EG (in permilles)
85     double EG1Attack; ///< Attack time of the sample amplitude EG (in seconds)
86     double EG1Hold; ///< If true, Decay1 stage should be postponed until the sample reached the sample loop start
87     double EG1Decay1; ///< Decay time of the sample amplitude EG (in seconds)
88     double EG1Decay2; ///< Only if (EG1InfiniteSustain == false): 2nd decay stage time of the sample amplitude EG (in seconds)
89     double EG1Sustain; ///< Sustain value of the sample amplitude EG (in permilles)
90     bool EG1InfiniteSustain; ///< If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released.
91     double EG1Release; ///< Release time of the sample amplitude EG (in seconds)
92    
93     double EG2PreAttack; ///< Preattack value of the filter cutoff EG (in permilles)
94     double EG2Attack; ///< Attack time of the filter cutoff EG (in seconds)
95     double EG2Decay1; ///< Decay time of the filter cutoff EG (in seconds)
96     double EG2Decay2; ///< Only if (EG2InfiniteSustain == false): 2nd decay stage time of the filter cutoff EG (in seconds)
97     double EG2Sustain; ///< Sustain value of the filter cutoff EG (in permilles)
98     bool EG2InfiniteSustain; ///< If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released.
99     double EG2Release; ///< Release time of the filter cutoff EG (in seconds)
100    
101     double EG3Attack; ///< Attack time of the sample pitch EG (in seconds)
102     int EG3Depth; ///< Depth of the sample pitch EG (-1200 - +1200)
103 persson 2061 double ReleaseTriggerDecay; ///< How much release sample volume depends on note length. Release sample amplitude is multiplied with (1 - ReleaseTriggerDecay * note length).
104 iliev 2015
105     bool VCFEnabled; ///< If filter should be used.
106 persson 2175 Filter::vcf_type_t VCFType; ///< Defines the general filter characteristic (lowpass, highpass, bandpass, etc.).
107 iliev 2015 uint8_t VCFResonance; ///< Firm internal filter resonance weight.
108     };
109    
110     struct InstrumentInfo {
111     int FineTune; // in cents
112     uint PitchbendRange; ///< Number of semitones pitchbend controller can pitch
113     };
114    
115     /// Reflects a MIDI controller
116     struct midi_ctrl {
117     uint8_t controller; ///< MIDI control change controller number
118     uint8_t value; ///< Current MIDI controller value
119     float fvalue; ///< Transformed / effective value (e.g. volume level or filter cutoff frequency)
120     };
121    
122     Voice() { }
123     virtual ~Voice() { }
124 iliev 2012 };
125 persson 2115
126     // |= operator for the type_t enum
127     inline Voice::type_t operator|=(Voice::type_t& lhs, Voice::type_t rhs) {
128     return lhs = static_cast<Voice::type_t>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
129     }
130    
131 iliev 2012 } // namespace LinuxSampler
132    
133 persson 2115 #endif /* __LS_VOICE_H__ */

  ViewVC Help
Powered by ViewVC