/[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 3052 - (hide annotations) (download) (as text)
Wed Dec 14 17:34:54 2016 UTC (7 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6634 byte(s)
- Preparations for Xcode project update.

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 schoenebeck 3052 // TODO: remove gig dependency
32     #if AC_APPLE_UNIVERSAL_BUILD
33     # include <libgig/gig.h>
34     #else
35     # include <gig.h>
36     #endif
37 iliev 2015
38 iliev 2012 namespace LinuxSampler {
39    
40     class Voice {
41     public:
42     enum playback_state_t {
43     playback_state_end = 0,
44     playback_state_init = 1,
45     playback_state_ram = 2,
46     playback_state_disk = 3
47     };
48    
49 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.
50 iliev 2012 enum type_t {
51 persson 2115 type_normal = 0,
52     type_release_trigger_required = 1 << 1, ///< If the key of this voice will be released, it causes a release triggered voice to be spawned
53     type_release_trigger = 1 << 2, ///< Release triggered voice which cannot be killed by releasing its key
54     type_one_shot = 1 << 3, ///< Voice should not be released by note off
55     type_controller_triggered = 1 << 4 ///< Voice is triggered by MIDI CC instead of a note on
56 iliev 2012 };
57 iliev 2015
58     struct PitchInfo {
59     float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice
60     float PitchBend; ///< Current pitch value of the pitchbend wheel
61     float PitchBendRange; ///< The pitch range of the pitchbend wheel, value is in cents / 8192
62     };
63    
64     struct EGInfo {
65     double Attack;
66     double Decay;
67     double Release;
68     };
69    
70     struct SampleInfo {
71     uint SampleRate;
72     uint ChannelCount;
73     uint FrameSize;
74     uint TotalFrameCount;
75     uint BitDepth;
76     bool HasLoops;
77     uint LoopStart;
78     uint LoopLength;
79     uint LoopPlayCount; ///< Number of times the loop should be played (a value of 0 = infinite).
80     bool Unpitched; ///< sound which is not characterized by a perceived frequency
81     };
82    
83     struct RegionInfo {
84     uint8_t UnityNote; ///< The MIDI key number of the recorded pitch of the sample
85     int16_t FineTune;
86     int Pan; ///< Panorama / Balance (-64..0..63 <-> left..middle..right)
87     uint SampleStartOffset; ///< Number of samples the sample start should be moved
88    
89     double EG2PreAttack; ///< Preattack value of the filter cutoff EG (in permilles)
90     double EG2Attack; ///< Attack time of the filter cutoff EG (in seconds)
91     double EG2Decay1; ///< Decay time of the filter cutoff EG (in seconds)
92     double EG2Decay2; ///< Only if (EG2InfiniteSustain == false): 2nd decay stage time of the filter cutoff EG (in seconds)
93     double EG2Sustain; ///< Sustain value of the filter cutoff EG (in permilles)
94     bool EG2InfiniteSustain; ///< If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released.
95     double EG2Release; ///< Release time of the filter cutoff EG (in seconds)
96    
97     double EG3Attack; ///< Attack time of the sample pitch EG (in seconds)
98     int EG3Depth; ///< Depth of the sample pitch EG (-1200 - +1200)
99 persson 2061 double ReleaseTriggerDecay; ///< How much release sample volume depends on note length. Release sample amplitude is multiplied with (1 - ReleaseTriggerDecay * note length).
100 iliev 2015
101     bool VCFEnabled; ///< If filter should be used.
102 persson 2175 Filter::vcf_type_t VCFType; ///< Defines the general filter characteristic (lowpass, highpass, bandpass, etc.).
103 iliev 2015 uint8_t VCFResonance; ///< Firm internal filter resonance weight.
104     };
105    
106     struct InstrumentInfo {
107     int FineTune; // in cents
108     uint PitchbendRange; ///< Number of semitones pitchbend controller can pitch
109     };
110    
111     /// Reflects a MIDI controller
112     struct midi_ctrl {
113     uint8_t controller; ///< MIDI control change controller number
114     uint8_t value; ///< Current MIDI controller value
115     float fvalue; ///< Transformed / effective value (e.g. volume level or filter cutoff frequency)
116     };
117    
118     Voice() { }
119     virtual ~Voice() { }
120 iliev 2012 };
121 persson 2115
122     // |= operator for the type_t enum
123     inline Voice::type_t operator|=(Voice::type_t& lhs, Voice::type_t rhs) {
124     return lhs = static_cast<Voice::type_t>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
125     }
126    
127 iliev 2012 } // namespace LinuxSampler
128    
129 persson 2115 #endif /* __LS_VOICE_H__ */

  ViewVC Help
Powered by ViewVC