#include <Morpher.h>
Classes | |
struct | MorphingPair |
Public Member Functions | |
Morpher (const Envelope &f) | |
Morpher (const Envelope &ff, const Envelope &af, const Envelope &bwf) | |
Morpher (const Morpher &rhs) | |
~Morpher (void) | |
Destroy this Morpher. | |
Morpher & | operator= (const Morpher &rhs) |
Partial | morphPartials (Partial src, Partial tgt, int assignLabel) |
Partial | morphPartial (Partial src, Partial tgt, int assignLabel) |
void | morph (PartialList::const_iterator beginSrc, PartialList::const_iterator endSrc, PartialList::const_iterator beginTgt, PartialList::const_iterator endTgt) |
void | crossfade (PartialList::const_iterator beginSrc, PartialList::const_iterator endSrc, PartialList::const_iterator beginTgt, PartialList::const_iterator endTgt, Partial::label_type label=0) |
Breakpoint | morphBreakpoints (Breakpoint srcBkpt, Breakpoint tgtBkpt, double time) const |
Breakpoint | morphSrcBreakpoint (const Breakpoint &bp, const Partial &tgtPartial, double time) const |
Breakpoint | morphTgtBreakpoint (const Breakpoint &bp, const Partial &srcPartial, double time) const |
Breakpoint | fadeSrcBreakpoint (Breakpoint bp, double time) const |
Breakpoint | fadeTgtBreakpoint (Breakpoint bp, double time) const |
void | setFrequencyFunction (const Envelope &f) |
Assign a new frequency morphing envelope to this Morpher. | |
void | setAmplitudeFunction (const Envelope &f) |
Assign a new amplitude morphing envelope to this Morpher. | |
void | setBandwidthFunction (const Envelope &f) |
Assign a new bandwidth morphing envelope to this Morpher. | |
const Envelope & | frequencyFunction (void) const |
Return a reference to this Morpher's frequency morphing envelope. | |
const Envelope & | amplitudeFunction (void) const |
Return a reference to this Morpher's amplitude morphing envelope. | |
const Envelope & | bandwidthFunction (void) const |
Return a reference to this Morpher's bandwidth morphing envelope. | |
double | amplitudeShape (void) const |
DEPRECATED. | |
void | setAmplitudeShape (double x) |
DEPRECATED. | |
void | enableLogAmpMorphing (bool enable=true) |
void | enableLogFreqMorphing (bool enable=true) |
double | minBreakpointGap (void) const |
void | setMinBreakpointGap (double x) |
const Partial & | sourceReferencePartial (void) const |
Partial & | sourceReferencePartial (void) |
const Partial & | targetReferencePartial (void) const |
Partial & | targetReferencePartial (void) |
void | setSourceReferencePartial (const Partial &p=Partial()) |
void | setSourceReferencePartial (const PartialList &partials, Partial::label_type refLabel) |
void | setTargetReferencePartial (const Partial &p=Partial()) |
void | setTargetReferencePartial (const PartialList &partials, Partial::label_type refLabel) |
PartialList & | partials (void) |
Return a reference to this Morpher's list of morphed Partials. | |
const PartialList & | partials (void) const |
Return a const reference to this Morpher's list of morphed Partials. | |
Static Public Attributes | |
static const double | DefaultFixThreshold |
static const double | DefaultAmpShape |
static const double | DefaultBreakpointGap |
Class Morpher performs sound morphing and Partial parameter envelope interpolation according to a trio of frequency, amplitude, and bandwidth morphing functions, described by Envelopes. Sound morphing is achieved by interpolating the time-varying frequencies, amplitudes, and bandwidths of corresponding partials obtained from reassigned bandwidth-enhanced analysis of the source and target sounds. Partial correspondences may be established by labeling, using instances of the Channelizer and Distiller classes.
The Morpher collects morphed Partials in a PartialList, that is accessible to clients.
For more information about sound morphing using the Reassigned Bandwidth-Enhanced Additive Sound Model, refer to the Loris website: www.cerlsoundgroup.org/Loris/.
Morpher is a leaf class, do not subclass.
Loris::Morpher::Morpher | ( | const Envelope & | f | ) |
Construct a new Morpher using the specified morphing envelopes for frequency, amplitude, and bandwidth (noisiness).
Loris::Morpher::Morpher | ( | const Morpher & | rhs | ) |
double Loris::Morpher::amplitudeShape | ( | void | ) | const |
DEPRECATED.
Return the shaping parameter for the amplitude moprhing function (only used in log-amplitude morphing).
void Loris::Morpher::crossfade | ( | PartialList::const_iterator | beginSrc, | |
PartialList::const_iterator | endSrc, | |||
PartialList::const_iterator | beginTgt, | |||
PartialList::const_iterator | endTgt, | |||
Partial::label_type | label = 0 | |||
) |
Crossfade Partials with no correspondences.
Unlabeled Partials (having the specified label) are considered to have no correspondences, so they are just faded out, and not actually morphed. Consistent with the morphing behavior, crossfaded Partials are thinned, if necssary, so that no two Breakpoints are closer in time than the minBreakpointGap.
The Partials in the first range are treated as components of the source sound, corresponding to a morph function value of 0, and those in the second are treated as components of the target sound, corresponding to a morph function value of 1.
The crossfaded Partials are stored in the Morpher's PartialList.
beginSrc | is the beginning of the sequence of Partials corresponding to a morph function value of 0. | |
endSrc | is (one past) the end of the sequence of Partials corresponding to a morph function value of 0. | |
beginTgt | is the beginning of the sequence of Partials corresponding to a morph function value of 1. | |
endTgt | is (one past) the end of the sequence of Partials corresponding to a morph function value of 1. | |
label | is the label to associate with unlabeled Partials (default is 0). |
void Loris::Morpher::enableLogAmpMorphing | ( | bool | enable = true |
) | [inline] |
Enable (or disable) log-domain amplitude and bandwidth morphing. Default is true.
void Loris::Morpher::enableLogFreqMorphing | ( | bool | enable = true |
) | [inline] |
Enable (or disable) log-domain frequency morphing. Default is false.
Breakpoint Loris::Morpher::fadeSrcBreakpoint | ( | Breakpoint | bp, | |
double | time | |||
) | const |
Compute morphed parameter values at the specified time, using the source Breakpoint, assumed to correspond exactly to the specified time, and assuming that there is no corresponding target Partial, so the source Breakpoint should be simply faded.
bp | is the Breakpoint corresponding to a morph function value of 0. | |
time | is the time corresponding to bp (used to evaluate the morphing functions). |
Breakpoint Loris::Morpher::fadeTgtBreakpoint | ( | Breakpoint | bp, | |
double | time | |||
) | const |
Compute morphed parameter values at the specified time, using the target Breakpoint, assumed to correspond exactly to the specified time, and assuming that there is not corresponding source Partial, so the target Breakpoint should be simply faded.
bp | is the Breakpoint corresponding to a morph function value of 1. | |
time | is the time corresponding to bp (used to evaluate the morphing functions). |
double Loris::Morpher::minBreakpointGap | ( | void | ) | const |
Return the minimum time gap (secs) between two Breakpoints in the morphed Partials. Morphing two Partials can generate a third Partial having Breakpoints arbitrarily close together in time, and this makes morphs huge. Raising this threshold limits the Breakpoint density in the morphed Partials. Default is 1/10 ms.
void Loris::Morpher::morph | ( | PartialList::const_iterator | beginSrc, | |
PartialList::const_iterator | endSrc, | |||
PartialList::const_iterator | beginTgt, | |||
PartialList::const_iterator | endTgt | |||
) |
Morph two sounds (collections of Partials labeled to indicate correspondences) into a single labeled collection of Partials. Unlabeled Partials (having label 0) are crossfaded. The morphed and crossfaded Partials are stored in the Morpher's PartialList.
The Partials in the first range are treated as components of the source sound, corresponding to a morph function value of 0, and those in the second are treated as components of the target sound, corresponding to a morph function value of 1.
beginSrc | is the beginning of the sequence of Partials corresponding to a morph function value of 0. | |
endSrc | is (one past) the end of the sequence of Partials corresponding to a morph function value of 0. | |
beginTgt | is the beginning of the sequence of Partials corresponding to a morph function value of 1. | |
endTgt | is (one past) the end of the sequence of Partials corresponding to a morph function value of 1. |
Breakpoint Loris::Morpher::morphBreakpoints | ( | Breakpoint | srcBkpt, | |
Breakpoint | tgtBkpt, | |||
double | time | |||
) | const |
Compute morphed parameter values at the specified time, using the source and target Breakpoints (assumed to correspond exactly to the specified time).
srcBkpt | is the Breakpoint corresponding to a morph function value of 0. | |
tgtBkpt | is the Breakpoint corresponding to a morph function value of 1. | |
time | is the time corresponding to srcBkpt (used to evaluate the morphing functions and tgtPartial). |
Bad legacy name for morphPartials.
Morph a pair of Partials to yield a new morphed Partial. Dummy Partials (having no Breakpoints) don't contribute to the morph, except to cause their opposite to fade out. Either (or neither) the source or target Partial may be a dummy Partial (no Breakpoints), but not both. The morphed Partial has Breakpoints at times corresponding to every Breakpoint in both source Partials, omitting Breakpoints that would be closer than the minBreakpointGap to their predecessor. The new morphed Partial is assigned the specified label and returned.
src | is the Partial corresponding to a morph function value of 0, evaluated at the specified time. | |
tgt | is the Partial corresponding to a morph function value of 1, evaluated at the specified time. | |
assignLabel | is the label assigned to the morphed Partial |
Breakpoint Loris::Morpher::morphSrcBreakpoint | ( | const Breakpoint & | bp, | |
const Partial & | tgtPartial, | |||
double | time | |||
) | const |
Compute morphed parameter values at the specified time, using the source Breakpoint (assumed to correspond exactly to the specified time) and the target Partial (whose parameters are examined at the specified time).
DEPRECATED do not use.
bp | is the Breakpoint corresponding to a morph function value of 0. | |
tgtPartial | is the Partial corresponding to a morph function value of 1, evaluated at the specified time. | |
time | is the time corresponding to srcBkpt (used to evaluate the morphing functions and tgtPartial). |
Breakpoint Loris::Morpher::morphTgtBreakpoint | ( | const Breakpoint & | bp, | |
const Partial & | srcPartial, | |||
double | time | |||
) | const |
Compute morphed parameter values at the specified time, using the target Breakpoint (assumed to correspond exactly to the specified time) and the source Partial (whose parameters are examined at the specified time).
DEPRECATED do not use.
bp | is the Breakpoint corresponding to a morph function value of 1. | |
srcPartial | is the Partial corresponding to a morph function value of 0, evaluated at the specified time. | |
time | is the time corresponding to srcBkpt (used to evaluate the morphing functions and tgtPartial). |
void Loris::Morpher::setAmplitudeShape | ( | double | x | ) |
DEPRECATED.
Set the shaping parameter for the amplitude moprhing function (only used in log-amplitude morphing). Only relevant when _doLogAmpMorphing is true. Don't use this for anything, just leave it at the default.
void Loris::Morpher::setMinBreakpointGap | ( | double | x | ) |
Set the minimum time gap (secs) between two Breakpoints in the morphed Partials. Morphing two Partials can generate a third Partial having Breakpoints arbitrarily close together in time, and this makes morphs huge. Raising this threshold limits the Breakpoint density in the morphed Partials. Default is 1/10 ms.
x | is the new minimum gap in seconds, it must be positive |
InvalidArgument | if the specified gap is not positive |
void Loris::Morpher::setSourceReferencePartial | ( | const PartialList & | partials, | |
Partial::label_type | refLabel | |||
) |
Specify the Partial to be used as a reference Partial for the source sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the source sequence.
Specify the Partial to be used as a reference Partial for the source sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. The specified Partial must be labeled with its harmonic number. A default (empty) Partial indicates that no reference Partial should be used for the source sequence.
void Loris::Morpher::setTargetReferencePartial | ( | const PartialList & | partials, | |
Partial::label_type | refLabel | |||
) |
Specify the Partial to be used as a reference Partial for the target sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the target sequence.
Specify the Partial to be used as a reference Partial for the target sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. The specified Partial must be labeled with its harmonic number. A default (empty) Partial indicates that no reference Partial should be used for the target sequence.
Partial& Loris::Morpher::sourceReferencePartial | ( | void | ) |
Return the Partial to be used as a reference Partial for the source sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the source sequence.
const Partial& Loris::Morpher::sourceReferencePartial | ( | void | ) | const |
Return the Partial to be used as a reference Partial for the source sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the source sequence.
Partial& Loris::Morpher::targetReferencePartial | ( | void | ) |
Return the Partial to be used as a reference Partial for the target sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the target sequence.
const Partial& Loris::Morpher::targetReferencePartial | ( | void | ) | const |
Return the Partial to be used as a reference Partial for the target sequence in a morph of two Partial sequences. The reference partial is used to compute frequencies for very low-amplitude Partials whose frequency estimates are not considered reliable. The reference Partial is considered to have good frequency estimates throughout. A default (empty) Partial indicates that no reference Partial should be used for the target sequence.
const double Loris::Morpher::DefaultAmpShape [static] |
Default amplitude shaping parameter, used in interpolateLogAmplitudes to perform logarithmic amplitude morphs.
Compile Loris with LINEAR_AMP_MORPHS defined for legacy-style linear amplitude morphs by default.
Change from default using setAmplitudeShape.
const double Loris::Morpher::DefaultBreakpointGap [static] |
Default minimum time (sec) between Breakpoints in morphed Partials. Change from default using setMinBreakpointGap.
const double Loris::Morpher::DefaultFixThreshold [static] |