/[svn]/linuxsampler/trunk/src/eg_vca.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/eg_vca.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (show annotations) (download) (as text)
Mon Feb 16 19:30:42 2004 UTC (20 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3491 byte(s)
* implemented bidirectional voice state transition, means voice state can
  switch arbitrary times between 'Sustained'<-->'Released' within it's life
  time, thus the release process of a voice can be cancelled
* src/eg_vca.cpp: extended envelope generator by additional states
  ('Attack_Hold', 'Decay_1' and 'Decay_2')
* applied patch from Vladimir Senkov which adds new command line parameters
  ('--jackout', '--alsaout' and '--samplerate')
* configure.in: fixed compiler warning

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck *
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 as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __EG_VCA_H__
24 #define __EG_VCA_H__
25
26 #include <math.h>
27
28 #include "global.h"
29 #include "gig.h"
30 #include "rtelmemorypool.h"
31 #include "modulationsystem.h"
32
33 #define EG_ENVELOPE_LIMIT 0.001
34 #define EG_MIN_RELEASE_TIME 0.005
35
36 /**
37 * VCA Envelope Generator
38 *
39 * This EG controls volume attenuation.
40 */
41 class EG_VCA {
42 public:
43 enum stage_t {
44 stage_attack,
45 stage_attack_hold,
46 stage_decay1,
47 stage_decay2,
48 stage_sustain,
49 stage_release,
50 stage_end
51 };
52
53 EG_VCA();
54 void Process(uint Samples, RTEList<ModulationSystem::Event>* pEvents, ModulationSystem::Event* pTriggerEvent, double SamplePos, double CurrentPitch);
55 void Trigger(uint PreAttack, double AttackTime, bool HoldAttack, long LoopStart, double Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, double ReleaseTime, uint Delay);
56 inline EG_VCA::stage_t GetStage() { return Stage; }
57 protected:
58 uint TriggerDelay; ///< number of sample points triggering should be delayed
59 float Level;
60 stage_t Stage;
61 float AttackCoeff;
62 long AttackStepsLeft; ///< number of sample points til end of attack stage
63 bool HoldAttack;
64 long LoopStart;
65 float Decay1Coeff;
66 long Decay1StepsLeft; ///< number of sample points in Decay1 stage
67 float Decay2Coeff;
68 bool InfiniteSustain;
69 float SustainLevel;
70 float ReleaseCoeff;
71 long ReleaseStepsLeft; ///< number of sample points til end of release stage
72 bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet.
73
74 inline long Min(long A, long B) {
75 return (A > B) ? B : A;
76 }
77 };
78
79 #endif // __EG_VCA_H__

  ViewVC Help
Powered by ViewVC