Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Loris::Synthesizer Class Reference

A Synthesizer renders bandwidth-enhanced Partials into a buffer of samples. More...

#include <Synthesizer.h>

List of all members.

Public Member Functions

 Synthesizer (double srate, std::vector< double > &buffer, double fadeTime=.001)
 Construct a Synthesizer using the specified sampling rate, sample buffer (a standard library vector), and Partial fade time (in seconds).

void synthesize (const Partial &p)
 Synthesize a bandwidth-enhanced sinusoidal Partial.

void operator() (const Partial &p)
 Function call operator: same as synthesize( p ).

template<typename Iter> void synthesize (Iter begin_partials, Iter end_partials)
 Synthesize all Partials on the specified half-open (STL-style) range.

template<typename Iter> void operator() (Iter begin_partials, Iter end_partials)
 Function call operator: same as synthesize( begin_partials, end_partials, timeShift ).

double fadeTime (void) const
 Return this Synthesizer's Partial fade time, in seconds.

double sampleRate (void) const
 Return the sampling rate (in Hz) for this Synthesizer.

const std::vector< double > samples (void) const
 Return a const reference to the sample buffer used (not owned) by this Synthesizer.

std::vector< double > samples (void)
 Return a reference to the sample buffer used (not owned) by this Synthesizer.

void setFadeTime (double t)
 Set this Synthesizer's fade time to the specified value (in seconds, must be non-negative).


Detailed Description

A Synthesizer renders bandwidth-enhanced Partials into a buffer of samples.

Class Synthesizer represents an algorithm for rendering bandwidth-enhanced Partials as floating point (double) samples at a specified sampling rate, and accumulating them into a buffer.

The Synthesizer does not own the sample buffer, the client is responsible for its construction and destruction, and many Synthesizers may share a buffer.


Constructor & Destructor Documentation

Loris::Synthesizer::Synthesizer double  srate,
std::vector< double > &  buffer,
double  fadeTime = .001
 

Construct a Synthesizer using the specified sampling rate, sample buffer (a standard library vector), and Partial fade time (in seconds).

Since Partials generated by the Loris Analyzer generally begin and end at non-zero amplitude, zero-amplitude Breakpoints are inserted at either end of the Partial, at a temporal distance equal to the fade time, to reduce turn-on and turn-off artifacts. If the fade time is unspecified, the default value of one millisecond (0.001 seconds) is used.

Parameters:
srate The rate (Hz) at which to synthesize samples (must be positive).
buffer The vector (of doubles) into which rendered samples should be accumulated.
fadeTime The Partial fade time in seconds (must be non-negative).
Exceptions:
InvalidArgument if the specfied sample rate is non-positive.
InvalidArgument if the specified fade time is negative.


Member Function Documentation

void Loris::Synthesizer::setFadeTime double  t  ) 
 

Set this Synthesizer's fade time to the specified value (in seconds, must be non-negative).

Parameters:
t The new Partial fade time.
Exceptions:
InvalidArgument if the specified fade time is negative.

template<typename Iter>
void Loris::Synthesizer::synthesize Iter  begin_partials,
Iter  end_partials
 

Synthesize all Partials on the specified half-open (STL-style) range.

Null Breakpoints are inserted at either end of the Partial to reduce turn-on and turn-off artifacts, as described above. The synthesizer will resize the buffer as necessary to accommodate all the samples, including the fade outs. Previous contents of the buffer are not overwritten. Partials with start times earlier than the Partial fade time will have shorter onset fades. Partials are not rendered at frequencies above the half-sample rate.

Parameters:
begin_partials The beginning of the range of Partials to synthesize.
end_partials The end of the range of Partials to synthesize.
Returns:
Nothing.
Precondition:
The partials must have non-negative start times.
Postcondition:
This Synthesizer's sample buffer (vector) has been resized to accommodate the entire duration of all the Partials including fade out at the ends.
Exceptions:
InvalidPartial if any Partial has negative start time.

void Loris::Synthesizer::synthesize const Partial p  ) 
 

Synthesize a bandwidth-enhanced sinusoidal Partial.

Zero-amplitude Breakpoints are inserted at either end of the Partial to reduce turn-on and turn-off artifacts, as described above. The synthesizer will resize the buffer as necessary to accommodate all the samples, including the fade out. Previous contents of the buffer are not overwritten. Partials with start times earlier than the Partial fade time will have shorter onset fades. Partials are not rendered at frequencies above the half-sample rate.

Parameters:
p The Partial to synthesize.
Returns:
Nothing.
Precondition:
The partial must have non-negative start time.
Postcondition:
This Synthesizer's sample buffer (vector) has been resized to accommodate the entire duration of the Partial, p, including fade out at the end.
Exceptions:
InvalidPartial if the Partial has negative start time.


Generated on Thu Apr 14 22:01:56 2005 for Loris by doxygen 1.3.4