Audaspace  1.4.0
A high level audio library.
ADSRReader.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #pragma once
18 
25 #include "fx/EffectReader.h"
26 
28 
33 {
34 private:
35  enum ADSRState
36  {
37  ADSR_STATE_INVALID = 0,
38  ADSR_STATE_ATTACK = 1,
39  ADSR_STATE_DECAY = 2,
40  ADSR_STATE_SUSTAIN = 3,
41  ADSR_STATE_RELEASE = 4
42  };
43 
47  float m_attack;
48 
52  float m_decay;
53 
57  float m_sustain;
58 
62  float m_release;
63 
67  ADSRState m_state;
68 
72  float m_level;
73 
74  // delete copy constructor and operator=
75  ADSRReader(const ADSRReader&) = delete;
76  ADSRReader& operator=(const ADSRReader&) = delete;
77 
78  void AUD_LOCAL nextState(ADSRState state);
79 
80 public:
89  ADSRReader(std::shared_ptr<IReader> reader, float attack, float decay, float sustain, float release);
90 
91  virtual ~ADSRReader();
92 
93  virtual void read(int& length, bool& eos, sample_t* buffer);
94 
98  void release();
99 };
100 
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
This reader is a base class for all effect readers that take one other reader as input.
Definition: EffectReader.h:35
The EffectReader class.
float sample_t
Sample type.(float samples)
Definition: Audaspace.h:126
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
This class is an ADSR filters.
Definition: ADSRReader.h:32
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition: Audaspace.h:80
virtual void read(int &length, bool &eos, sample_t *buffer)
Request to read the next length samples out of the source.