summaryrefslogtreecommitdiff
path: root/src/loris/Breakpoint.h
blob: 31123dd87387c5ce7a3504f69f2aebee50d0d7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef INCLUDE_BREAKPOINT_H
#define INCLUDE_BREAKPOINT_H
/*
 * This is the Loris C++ Class Library, implementing analysis, 
 * manipulation, and synthesis of digitized sounds using the Reassigned 
 * Bandwidth-Enhanced Additive Sound Model.
 *
 * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY, without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 * Breakpoint.h
 *
 * Definition of class Loris::Breakpoint.
 *
 * Kelly Fitz, 16 Aug 99
 * loris@cerlsoundgroup.org
 *
 * http://www.cerlsoundgroup.org/Loris/
 *
 */

//	begin namespace
namespace Loris {


// ---------------------------------------------------------------------------
//	class Breakpoint
//	
//!	Class Breakpoint represents a single breakpoint in the
//!	Partial parameter (frequency, amplitude, bandwidth) envelope.
//!	Instantaneous phase is also stored, but is only used at the onset of 
//!	a partial, or when it makes a transition from zero to nonzero amplitude.
//!	
//!	Loris Partials represent reassigned bandwidth-enhanced model components.
//!	A Partial consists of a chain of Breakpoints describing the time-varying
//!	frequency, amplitude, and bandwidth (noisiness) of the component.
//!	For more information about Reassigned Bandwidth-Enhanced 
//!	Analysis and the Reassigned Bandwidth-Enhanced Additive Sound 
//!	Model, refer to the Loris website: 
//!	www.cerlsoundgroup.org/Loris/.
//!	
//!	Breakpoint is a leaf class, do not subclass.
//
class Breakpoint
{
//	-- instance variables --
	double _frequency;	//!	in Hertz
	double _amplitude;	//!	absolute
	double _bandwidth;	//!	fraction of total energy that is noise energy
	double _phase;		//!	radians
	
//	-- public Breakpoint interface --

public:
//	-- construction --

	//!	Construct a new Breakpoint with all parameters initialized to 0
	//!	(needed for STL containability).
 	Breakpoint( void );	

	//!	Construct a new Breakpoint with the specified parameters.
	//!	
	//!	\param 	f is the intial frequency.
	//!	\param 	a is the initial amplitude.
	//!	\param 	b is the initial bandwidth.
	//!	\param 	p is the initial phase, if specified (if unspecified, 0 
	//!			is assumed).
 	Breakpoint( double f, double a, double b, double p = 0. );

	//	(use compiler-generated destructor, copy, and assign)
	
//	-- access --
	//!	Return the amplitude of this Breakpoint.
 	double amplitude( void ) const { return _amplitude; }

	//!	Return the bandwidth (noisiness) coefficient of this Breakpoint.
 	double bandwidth( void ) const { return _bandwidth; }

	//!	Return the frequency of this Breakpoint.
  	double frequency( void ) const { return _frequency; }

	//!	Return the phase of this Breakpoint.
	double phase( void ) const { return _phase; }
	
//	-- mutation --
	//!	Set the amplitude of this Breakpoint.
	//!
	//!	\param x is the new amplitude
 	void setAmplitude( double x ) { _amplitude = x; }

	//!	Set the bandwidth (noisiness) coefficient of this Breakpoint.
	//!
	//!	\param x is the new bandwidth
 	void setBandwidth( double x ) { _bandwidth = x; }

	//!	Set the frequency of this Breakpoint.
	//!
	//!	\param x is the new frequency.
 	void setFrequency( double x ) { _frequency = x; }

	//!	Set the phase of this Breakpoint.
	//!
	//!	\param x is the new phase.
 	void setPhase( double x ) { _phase = x; }
	 
	//!	Add noise (bandwidth) energy to this Breakpoint by computing new 
	//!	amplitude and bandwidth values. enoise may be negative, but 
	//!	noise energy cannot be removed (negative energy added) in excess 
	//!	of the current noise energy.
	//!	
	//!	\param 	enoise is the amount of noise energy to add to
	//!			this Breakpoint.
	void addNoiseEnergy( double enoise );
	
};	//	end of class Breakpoint

}	//	end of namespace Loris

#endif /* ndef INCLUDE_BREAKPOINT_H */