Nsound
0.9.4
Main Page
Namespaces
Classes
Files
File List
File Members
Nsound
EnvelopeAdsr.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// $Id: EnvelopeAdsr.h 874 2014-09-08 02:21:29Z weegreenblobbie $
4
//
5
// Nsound is a C++ library and Python module for audio synthesis featuring
6
// dynamic digital filters. Nsound lets you easily shape waveforms and write
7
// to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8
// use.
9
//
10
// Copyright (c) 2005-2006 Nick Hilton
11
//
12
// weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13
//
14
//-----------------------------------------------------------------------------
15
16
//-----------------------------------------------------------------------------
17
//
18
// This program is free software; you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation; either version 2 of the License, or
21
// (at your option) any later version.
22
//
23
// This program is distributed in the hope that it will be useful,
24
// but WITHOUT ANY WARRANTY; without even the implied warranty of
25
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
// GNU Library General Public License for more details.
27
//
28
// You should have received a copy of the GNU General Public License
29
// along with this program; if not, write to the Free Software
30
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31
//
32
//-----------------------------------------------------------------------------
33
34
//-----------------------------------------------------------------------------
35
//
36
// This class will generate an Attack Delay Sustain Release (ADSR) envlepe.
37
//
38
// 1.0 | /|
39
// | / |
40
// | / |
41
// | / |
42
// | / |-----sustain-amplitude------|
43
// | / |
44
// | / |
45
// | / |
46
// |/ |
47
// 0.0 ------------------------------------------------
48
// |--------|
49
// Attack |------|
50
// Delay |--------------------------|
51
// Sustain |-----|
52
// Release
53
//
54
// Currently the curves are linear.
55
//
56
//-----------------------------------------------------------------------------
57
58
#ifndef _NSOUND_ENVELOPE_ADSR_H_
59
#define _NSOUND_ENVELOPE_ADSR_H_
60
61
namespace
Nsound
62
{
63
64
// Forward declarations
65
class
AudioStream;
66
class
Buffer;
67
68
//-----------------------------------------------------------------------------
69
class
EnvelopeAdsr
70
{
71
public
:
72
74
EnvelopeAdsr
(
75
const
float64
& sample_rate,
76
const
float64
& attack_time,
77
const
float64
& delay_time,
78
const
float64
& sustain_amplitude,
79
const
float64
& release_time);
80
81
void
reset
();
82
83
void
setAttackTime
(
const
float64
& time);
84
void
setDelayTime
(
const
float64
& time);
85
void
setSustainAmplitude
(
const
float64
& amp);
86
void
setReleaseTime
(
const
float64
& time);
87
89
AudioStream
shape
(
const
AudioStream
& as);
90
92
Buffer
shape
(
const
Buffer
& buf);
93
95
float64
shape
(
float64
sample,
bool
key_on);
96
bool
is_done
()
const
{
return
mode_
==
done
; }
97
98
protected
:
99
100
float64
sample_rate_
;
101
float64
attack_slope_
;
102
float64
attack_time_
;
103
float64
delay_slope_
;
104
float64
delay_time_
;
105
float64
sustain_amp_
;
106
float64
release_slope_
;
107
float64
release_time_
;
108
float64
scale_
;
109
110
enum
Mode
{
attacking
,
delaying
,
sustaining
,
releasing
,
done
};
111
112
Mode
mode_
;
113
114
};
115
116
};
117
118
#endif
Nsound::EnvelopeAdsr::setReleaseTime
void setReleaseTime(const float64 &time)
Definition:
EnvelopeAdsr.cc:122
Nsound::EnvelopeAdsr::attack_time_
float64 attack_time_
Definition:
EnvelopeAdsr.h:102
Nsound::EnvelopeAdsr::sustaining
Definition:
EnvelopeAdsr.h:110
Nsound::EnvelopeAdsr::sustain_amp_
float64 sustain_amp_
Definition:
EnvelopeAdsr.h:105
Nsound::EnvelopeAdsr::scale_
float64 scale_
Definition:
EnvelopeAdsr.h:108
Nsound::EnvelopeAdsr
Definition:
EnvelopeAdsr.h:69
Nsound::EnvelopeAdsr::done
Definition:
EnvelopeAdsr.h:110
Nsound::EnvelopeAdsr::setSustainAmplitude
void setSustainAmplitude(const float64 &)
Definition:
EnvelopeAdsr.cc:113
Nsound::float64
double float64
Definition:
Nsound.h:146
Nsound::EnvelopeAdsr::delay_slope_
float64 delay_slope_
Definition:
EnvelopeAdsr.h:103
Nsound::EnvelopeAdsr::releasing
Definition:
EnvelopeAdsr.h:110
Nsound::EnvelopeAdsr::release_time_
float64 release_time_
Definition:
EnvelopeAdsr.h:107
Nsound::EnvelopeAdsr::EnvelopeAdsr
EnvelopeAdsr(const float64 &sample_rate, const float64 &attack_time, const float64 &delay_time, const float64 &sustain_amplitude, const float64 &release_time)
Constructor.
Definition:
EnvelopeAdsr.cc:39
Nsound::EnvelopeAdsr::sample_rate_
float64 sample_rate_
Definition:
EnvelopeAdsr.h:100
Nsound::EnvelopeAdsr::attacking
Definition:
EnvelopeAdsr.h:110
Nsound::EnvelopeAdsr::is_done
bool is_done() const
Definition:
EnvelopeAdsr.h:96
Nsound::EnvelopeAdsr::reset
void reset()
Definition:
EnvelopeAdsr.cc:73
Nsound::EnvelopeAdsr::Mode
Mode
Definition:
EnvelopeAdsr.h:110
Nsound::AudioStream
Definition:
AudioStream.h:52
Nsound::EnvelopeAdsr::shape
AudioStream shape(const AudioStream &as)
Shapes the AudioStream inplace.
Definition:
EnvelopeAdsr.cc:138
Nsound::EnvelopeAdsr::delaying
Definition:
EnvelopeAdsr.h:110
Nsound::EnvelopeAdsr::setAttackTime
void setAttackTime(const float64 &time)
Definition:
EnvelopeAdsr.cc:81
Nsound::Buffer
A Buffer for storing audio samples.
Definition:
Buffer.h:60
Nsound::EnvelopeAdsr::mode_
Mode mode_
Definition:
EnvelopeAdsr.h:112
Nsound::EnvelopeAdsr::attack_slope_
float64 attack_slope_
Definition:
EnvelopeAdsr.h:101
Nsound::EnvelopeAdsr::setDelayTime
void setDelayTime(const float64 &time)
Definition:
EnvelopeAdsr.cc:97
Nsound::EnvelopeAdsr::delay_time_
float64 delay_time_
Definition:
EnvelopeAdsr.h:104
Nsound::EnvelopeAdsr::release_slope_
float64 release_slope_
Definition:
EnvelopeAdsr.h:106
Generated on Sun Aug 23 2015 11:51:50 for Nsound by
1.8.6