Loris::Synthesizer Class Reference

#include <Synthesizer.h>

List of all members.

Classes

struct  Parameters

Public Types

enum  { Default_FadeTime_Ms = 1, Default_SampleRate_Hz = 44100 }

Public Member Functions

 Synthesizer (std::vector< double > &buffer)
 Synthesizer (Parameters params, std::vector< double > &buffer)
 Synthesizer (double srate, std::vector< double > &buffer)
 Synthesizer (double srate, std::vector< double > &buffer, double fadeTime)
void synthesize (Partial p)
void operator() (const Partial &p)
 Function call operator: same as synthesize( p ).
template<typename Iter >
void synthesize (Iter begin_partials, Iter end_partials)
template<typename Iter >
void operator() (Iter begin_partials, Iter end_partials)
const std::vector< double > & samples (void) const
std::vector< double > & samples (void)
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.
void setFadeTime (double partialFadeTime)
void setSampleRate (double rate)
Filterfilter (void)

Static Public Member Functions

static const ParametersDefaultParameters (void)
static void SetDefaultParameters (const Parameters &params)
static bool IsValidParameters (const Parameters &params)

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 ( std::vector< double > &  buffer  ) 

Construct a Synthesizer using the default parameters and sample buffer (a standard library vector). 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.

See also:
Synthesizer::Parameters
Parameters:
buffer The vector (of doubles) into which rendered samples should be accumulated.
Exceptions:
InvalidArgument if any of the parameters is invalid.
Loris::Synthesizer::Synthesizer ( Parameters  params,
std::vector< double > &  buffer 
)

Construct a Synthesizer using the specified parameters and sample buffer (a standard library vector). 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.

Parameters:
params A Parameters struct storing the configuration of Synthesizer parameters.
buffer The vector (of doubles) into which rendered samples should be accumulated.
Exceptions:
InvalidArgument if any of the parameters is invalid.
Loris::Synthesizer::Synthesizer ( double  srate,
std::vector< double > &  buffer 
)

Construct a Synthesizer using the specified sampling rate, sample buffer (a standard library vector), and the default fade time stored in the DefaultParameters. 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.

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.
Exceptions:
InvalidArgument if the specfied sample rate is non-positive.
Loris::Synthesizer::Synthesizer ( double  srate,
std::vector< double > &  buffer,
double  fadeTime 
)

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.

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

static const Parameters& Loris::Synthesizer::DefaultParameters ( void   )  [static]

Default configuration of a Loris::Synthesizer. Modify the values in this structure to alter the configuration of all Synthesizers, including those used by the AiffFile class to render Partials.

Filter& Loris::Synthesizer::filter ( void   ) 

Return access to the Filter used by this Synthesizer's Oscillator to implement bandwidth-enhanced sinusoidal synthesis. (Can use this access to make changes to the filter coefficients.)

static bool Loris::Synthesizer::IsValidParameters ( const Parameters params  )  [static]

Check the validty of a Parameters structure. Returns true if the struct represents a valid Synthesizer configuration, otherwise raise InvalidArgument reporting the specific error.

Parameters:
params A Parameters struct describing a configuration for Synthesizers.
Exceptions:
InvalidArgument if params reprsents an invalid configuration.
template<typename Iter >
void Loris::Synthesizer::operator() ( Iter  begin_partials,
Iter  end_partials 
) [inline]

Function call operator: same as synthesize( begin_partials, end_partials ).

Function call operator: same as synthesize( begin_partials, end_partials, timeShift ).

std::vector<double>& Loris::Synthesizer::samples ( void   ) 

Return a reference to the sample buffer used (not owned) by this Synthesizer.

const std::vector<double>& Loris::Synthesizer::samples ( void   )  const

Return a const reference to the sample buffer used (not owned) by this Synthesizer.

static void Loris::Synthesizer::SetDefaultParameters ( const Parameters params  )  [static]

Assign a new default configuration of a Loris::Synthesizer to alter the configuration of all Synthesizers, including those used by the AiffFile class to render Partials.

Parameters:
params A Parameters struct describing the new default configuration for Synthesizers.
Exceptions:
InvalidArgument if params reprsents an invalid configuration.
void Loris::Synthesizer::setFadeTime ( double  partialFadeTime  ) 

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

Parameters:
partialFadeTime The new Partial fade time.
Exceptions:
InvalidArgument if the specified fade time is negative.
void Loris::Synthesizer::setSampleRate ( double  rate  ) 

Set this Synthesizer's sample rate to the specified value (in Hz, must be positive).

Parameters:
rate The new synthesis sample rate.
Exceptions:
InvalidArgument if the specified rate is nonpositive.
template<typename Iter >
void Loris::Synthesizer::synthesize ( Iter  begin_partials,
Iter  end_partials 
) [inline]

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.

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.

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 ( 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.

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2