#include <Resampler.h>
Public Member Functions | |
Resampler (double sampleInterval) | |
void | setPhaseCorrect (bool correctPhase) |
void | resample (Partial &p) const |
void | operator() (Partial &p) const |
Function call operator: same as resample( p ). | |
void | resample (Partial &p, const LinearEnvelope &timingEnv) const |
void | quantize (Partial &p) const |
template<typename Iter > | |
void | resample (Iter begin, Iter end) const |
template<typename Iter > | |
void | operator() (Iter begin, Iter end) const |
Function call operator: same as resample( begin, end ). | |
template<typename Iter > | |
void | resample (Iter begin, Iter end, const LinearEnvelope &timingEnv) const |
template<typename Iter > | |
void | quantize (Iter begin, Iter end) const |
Static Public Member Functions | |
template<typename Iter > | |
static void | resample (Iter begin, Iter end, double sampleInterval, bool denseResampling=false) |
Class Resampler represents an algorithm for resampling Partial envelopes at regular time intervals. Resampling makes the envelope data more suitable for exchange (as SDIF data, for example) with other applications that cannot process raw (continuously-distributed) reassigned data. Resampling will often greatly reduce the size of the data (by greatly reducing the number of Breakpoints in the Partials) without adversely affecting the quality of the reconstruction.
Loris::Resampler::Resampler | ( | double | sampleInterval | ) | [explicit] |
Initialize a Resampler having the specified uniform sampling interval. Enable phase-correct resampling, in which frequencies of resampled Partials are modified (using fixFrequency) such that the resampled phases are achieved in synthesis. Phase- correct resampling can be disabled using setPhaseCorrect.
Resampled Partials will be composed of Breakpoints at every integer multiple of the resampling interval.
sampleInterval | is the resampling interval in seconds, Breakpoint data is computed at integer multiples of sampleInterval seconds. |
InvalidArgument | if sampleInterval is not positive. |
void Loris::Resampler::quantize | ( | Iter | begin, | |
Iter | end | |||
) | const [inline] |
Quantize all Partials in the specified (half-open) range. Each Breakpoint in the Partials is replaced by a Breakpoint constructed by resampling the Partial at the nearest integer multiple of the of the resampling interval.
begin | is the beginning of the range of Partials to quantize | |
end | is (one-past) the end of the range of Partials to quantize |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
void Loris::Resampler::quantize | ( | Partial & | p | ) | const |
Quantize the Breakpoint times using the specified Partial using the stored quanitization interval. Each Breakpoint in the Partial is replaced by a Breakpoint constructed by resampling the Partial at the nearest integer multiple of the of the resampling interval.
Quantization is performed in-place.
p | is the Partial to resample |
void Loris::Resampler::resample | ( | Iter | begin, | |
Iter | end, | |||
double | sampleInterval, | |||
bool | denseResampling = false | |||
) | [inline, static] |
Static member that constructs an instance and applies it to a sequence of Partials. Construct a Resampler using the specified resampling interval, and use it to channelize a sequence of Partials.
begin | is the beginning of a sequence of Partials to resample. | |
end | is the end of a sequence of Partials to resample. | |
sampleInterval | is the resampling interval in seconds, Breakpoint data is computed at integer multiples of sampleInterval seconds. | |
denseResampling | is a boolean flag indicating that dense resamping (Breakpoint at every integer multiple of the resampling interval) should be performed. If false (the default), sparse resampling (Breakpoints only at multiples of the resampling interval near Breakpoint times in the original Partial) is performed. |
InvalidArgument | if sampleInterval is not positive. |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
Static member that constructs an instance and applies phase-correct resampling to a sequence of Partials. Construct a Resampler using the specified resampling interval, and use it to channelize a sequence of Partials.
begin | is the beginning of a sequence of Partials to resample. | |
end | is the end of a sequence of Partials to resample. | |
sampleInterval | is the resampling interval in seconds, Breakpoint data is computed at integer multiples of sampleInterval seconds. | |
denseResampling | is a boolean flag indicating that dense resamping (Breakpoint at every integer multiple of the resampling interval) should be performed. If false (the default), sparse resampling (Breakpoints only at multiples of the resampling interval near Breakpoint times in the original Partial) is performed. |
InvalidArgument | if sampleInterval is not positive. |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
void Loris::Resampler::resample | ( | Iter | begin, | |
Iter | end, | |||
const LinearEnvelope & | timingEnv | |||
) | const [inline] |
Resample all Partials in the specified (half-open) range using this Resampler's stored quanitization interval. The Breakpoint times in resampled Partials will comprise a contiguous sequence of all integer multiples of the sampling interval, starting and ending with the nearest multiples to the ends of the Partial. If phase correct resampling is specified (the default)≤ frequencies and phases are corrected to be in agreement and to match as nearly as possible the resampled phases.
The timing envelope represents a warping of the time axis that is applied during resampling. The Breakpoint times in resampled Partials will a comprise contiguous sequence of all integer multiples of the sampling interval between the first and last breakpoints in the timing envelope, and each Breakpoint will represent the parameters of the original Partial at the time that is the value of the timing envelope at that instant.
Resampling is performed in-place.
begin | is the beginning of the range of Partials to resample | |
end | is (one-past) the end of the range of Partials to resample | |
timingEnv | is the timing envelope, a map of Breakpoint times in resampled Partials onto parameter sampling instants in the original Partials. If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials. |
Resample all Partials in the specified (half-open) range using this Resampler's stored sampling interval, so that the Breakpoints in the Partial envelopes will all lie on a common temporal grid. The Breakpoint times in the resampled Partial will comprise a contiguous sequence of integer multiples of the sampling interval, beginning with the multiple nearest to the Partial's start time and ending with the multiple nearest to the Partial's end time. Resampling is performed in-place.
begin | is the beginning of the range of Partials to resample | |
end | is (one-past) the end of the range of Partials to resample | |
timingEnv | is the timing envelope, a map of Breakpoint times in resampled Partials onto parameter sampling instants in the original Partials. |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
void Loris::Resampler::resample | ( | Iter | begin, | |
Iter | end | |||
) | const [inline] |
Resample all Partials in the specified (half-open) range using this Resampler's stored quanitization interval. The Breakpoint times in resampled Partials will comprise a contiguous sequence of all integer multiples of the sampling interval, starting and ending with the nearest multiples to the ends of the Partial. If phase correct resampling is specified (the default)≤ frequencies and phases are corrected to be in agreement and to match as nearly as possible the resampled phases.
Resampling is performed in-place.
begin | is the beginning of the range of Partials to resample | |
end | is (one-past) the end of the range of Partials to resample |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
Resample all Partials in the specified (half-open) range using this Resampler's stored sampling interval, so that the Breakpoints in the Partial envelopes will all lie on a common temporal grid. The Breakpoint times in the resampled Partial will comprise a contiguous sequence of integer multiples of the sampling interval, beginning with the multiple nearest to the Partial's start time and ending with the multiple nearest to the Partial's end time. Resampling is performed in-place.
begin | is the beginning of the range of Partials to resample | |
end | is (one-past) the end of the range of Partials to resample |
If compiled with NO_TEMPLATE_MEMBERS defined, then begin and end must be PartialList::iterators, otherwise they can be any type of iterators over a sequence of Partials.
void Loris::Resampler::resample | ( | Partial & | p, | |
const LinearEnvelope & | timingEnv | |||
) | const |
Resample the specified Partial using the stored quanitization interval. The Breakpoint times will comprise a contiguous sequence of all integer multiples of the sampling interval, starting and ending with the nearest multiples to the ends of the Partial. If phase correct resampling is specified (the default)≤ frequencies and phases are corrected to be in agreement and to match as nearly as possible the resampled phases.
The timing envelope represents a warping of the time axis that is applied during resampling. The Breakpoint times in resampled Partials will a comprise contiguous sequence of all integer multiples of the sampling interval between the first and last breakpoints in the timing envelope, and each Breakpoint will represent the parameters of the original Partial at the time that is the value of the timing envelope at that instant.
Resampling is performed in-place.
p | is the Partial to resample | |
timingEnv | is the timing envelope, a map of Breakpoint times in resampled Partials onto parameter sampling instants in the original Partials. |
InvalidArgument | if timingEnv has any negative breakpoint times or values. |
void Loris::Resampler::resample | ( | Partial & | p | ) | const |
Resample the specified Partial using the stored quanitization interval. The Breakpoint times will comprise a contiguous sequence of all integer multiples of the sampling interval, starting and ending with the nearest multiples to the ends of the Partial. If phase correct resampling is specified (the default)≤ frequencies and phases are corrected to be in agreement and to match as nearly as possible the resampled phases.
Resampling is performed in-place.
p | is the Partial to resample |
void Loris::Resampler::setPhaseCorrect | ( | bool | correctPhase | ) |
Specify phase-corrected resampling, or not. If phase correct, Partial frequencies are altered slightly to match, as nearly as possible, the Breakpoint phases after resampling. Phases are updated so that the Partial frequencies and phases are consistent after resampling.
correctPhase | is a boolean flag specifying that (if true) frequency/phase correction should be applied after resampling. |