00001 #ifndef INCLUDE_MORPHER_H
00002 #define INCLUDE_MORPHER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "PartialList.h"
00036 #include "Partial.h"
00037
00038 #include <memory>
00039
00040
00041 namespace Loris {
00042
00043 class Envelope;
00044
00045
00046
00047
00066
00067 class Morpher
00068 {
00069
00070
00071 std::auto_ptr< Envelope > _freqFunction;
00072 std::auto_ptr< Envelope > _ampFunction;
00073 std::auto_ptr< Envelope > _bwFunction;
00074
00075 PartialList _partials;
00076
00077 Partial::label_type _refLabel0;
00078 Partial::label_type _refLabel1;
00079
00080
00081
00082 double _freqFixThresholdDb;
00083
00084
00085
00086 double _ampMorphShape;
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 double _minBreakpointGapSec;
00099
00100
00101
00102
00103
00104
00105
00106
00107 public:
00108
00109
00115 Morpher( const Envelope & f );
00116
00123 Morpher( const Envelope & ff, const Envelope & af, const Envelope & bwf );
00124
00128 Morpher( const Morpher & rhs );
00129
00131 ~Morpher( void );
00132
00136 Morpher & operator= ( const Morpher & rhs );
00137
00138
00139
00140
00141
00158 Partial morphPartial( const Partial & src, const Partial & tgt,
00159 int assignLabel );
00160
00181 void morph( PartialList::const_iterator beginSrc,
00182 PartialList::const_iterator endSrc,
00183 PartialList::const_iterator beginTgt,
00184 PartialList::const_iterator endTgt );
00185
00211 void crossfade( PartialList::const_iterator beginSrc,
00212 PartialList::const_iterator endSrc,
00213 PartialList::const_iterator beginTgt,
00214 PartialList::const_iterator endTgt,
00215 Partial::label_type label = 0 );
00216
00217
00229
00230 Breakpoint
00231 morphBreakpoints( const Breakpoint & srcBkpt, const Breakpoint & tgtBkpt,
00232 double time ) const;
00233
00248 Breakpoint
00249 morphSrcBreakpoint( const Breakpoint & bp, const Partial & tgtPartial,
00250 double time ) const;
00251
00266 Breakpoint
00267 morphTgtBreakpoint( const Breakpoint & bp, const Partial & srcPartial,
00268 double time ) const;
00269
00280 Breakpoint fadeSrcBreakpoint( Breakpoint bp, double time ) const;
00281
00292 Breakpoint fadeTgtBreakpoint( Breakpoint bp, double time ) const;
00293
00294
00295
00297 void setFrequencyFunction( const Envelope & f );
00298
00300 void setAmplitudeFunction( const Envelope & f );
00301
00303 void setBandwidthFunction( const Envelope & f );
00304
00306 const Envelope & frequencyFunction( void ) const;
00307
00309 const Envelope & amplitudeFunction( void ) const;
00310
00312 const Envelope & bandwidthFunction( void ) const;
00313
00327 double amplitudeShape( void ) const;
00328
00344 void setAmplitudeShape( double x );
00345
00353 double minBreakpointGap( void ) const;
00354
00366 void setMinBreakpointGap( double x );
00367
00368
00369
00370
00379 Partial::label_type sourceReferenceLabel( void ) const;
00380
00389 Partial::label_type targetReferenceLabel( void ) const;
00390
00399 void setSourceReferenceLabel( Partial::label_type l );
00400
00409 void setTargetReferenceLabel( Partial::label_type l );
00410
00411
00412
00414 PartialList & partials( void );
00415
00417 const PartialList & partials( void ) const;
00418
00419 private:
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429 struct PartialPtrPair
00430 {
00431 const Partial * first;
00432 const Partial * second;
00433 PartialPtrPair( void ) : first(0), second(0) {}
00434
00435 };
00436 typedef std::map< Partial::label_type, PartialPtrPair > PartialCorrespondence;
00437
00441 void morph_aux( PartialCorrespondence & correspondence );
00442
00446 Partial makePartialFromReference( Partial scaleMe, double fscale );
00447
00465
00466 void appendMorphedSrc( const Breakpoint & srcBkpt, const Partial & tgtPartial,
00467 double time, Partial & newp );
00468
00486
00487 void appendMorphedTgt( const Breakpoint & tgtBkpt, const Partial & srcPartial,
00488 double time, Partial & newp );
00489
00490
00491 };
00492
00493 }
00494
00495 #endif