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 _srcRefPartial;
00078 Partial _tgtRefPartial;
00079
00080
00081
00082
00083 double _freqFixThresholdDb;
00084
00085
00086
00087 double _ampMorphShape;
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 double _minBreakpointGapSec;
00100
00101
00102
00103
00104
00105
00106
00107
00108 public:
00109
00110
00116 Morpher( const Envelope & f );
00117
00124 Morpher( const Envelope & ff, const Envelope & af, const Envelope & bwf );
00125
00129 Morpher( const Morpher & rhs );
00130
00132 ~Morpher( void );
00133
00137 Morpher & operator= ( const Morpher & rhs );
00138
00139
00140
00141
00142
00159 Partial morphPartials( Partial src, Partial tgt, int assignLabel );
00160
00163 Partial morphPartial( Partial src, Partial tgt, int assignLabel )
00164 { return morphPartials( src, tgt, assignLabel ); }
00165
00186 void morph( PartialList::const_iterator beginSrc,
00187 PartialList::const_iterator endSrc,
00188 PartialList::const_iterator beginTgt,
00189 PartialList::const_iterator endTgt );
00190
00216 void crossfade( PartialList::const_iterator beginSrc,
00217 PartialList::const_iterator endSrc,
00218 PartialList::const_iterator beginTgt,
00219 PartialList::const_iterator endTgt,
00220 Partial::label_type label = 0 );
00221
00222
00234
00235 Breakpoint
00236 morphBreakpoints( Breakpoint srcBkpt, Breakpoint tgtBkpt,
00237 double time ) const;
00238
00255 Breakpoint
00256 morphSrcBreakpoint( const Breakpoint & bp, const Partial & tgtPartial,
00257 double time ) const;
00258
00275 Breakpoint
00276 morphTgtBreakpoint( const Breakpoint & bp, const Partial & srcPartial,
00277 double time ) const;
00278
00289 Breakpoint fadeSrcBreakpoint( Breakpoint bp, double time ) const;
00290
00301 Breakpoint fadeTgtBreakpoint( Breakpoint bp, double time ) const;
00302
00303
00304
00306 void setFrequencyFunction( const Envelope & f );
00307
00309 void setAmplitudeFunction( const Envelope & f );
00310
00312 void setBandwidthFunction( const Envelope & f );
00313
00315 const Envelope & frequencyFunction( void ) const;
00316
00318 const Envelope & amplitudeFunction( void ) const;
00319
00321 const Envelope & bandwidthFunction( void ) const;
00322
00336 double amplitudeShape( void ) const;
00337
00353 void setAmplitudeShape( double x );
00354
00362 double minBreakpointGap( void ) const;
00363
00375 void setMinBreakpointGap( double x );
00376
00377
00378
00379
00388 const Partial & sourceReferencePartial( void ) const;
00389
00398 Partial & sourceReferencePartial( void );
00399
00408 const Partial & targetReferencePartial( void ) const;
00409
00418 Partial & targetReferencePartial( void );
00419
00429 void setSourceReferencePartial( const Partial & p = Partial() );
00430
00444 void setSourceReferencePartial( const PartialList & partials,
00445 Partial::label_type refLabel );
00446
00456 void setTargetReferencePartial( const Partial & p = Partial() );
00457
00471 void setTargetReferencePartial( const PartialList & partials,
00472 Partial::label_type refLabel );
00473
00474
00475
00477 PartialList & partials( void );
00478
00480 const PartialList & partials( void ) const;
00481
00482
00483
00488 static const double DefaultFixThreshold;
00489
00498 static const double DefaultAmpShape;
00499
00503 static const double DefaultBreakpointGap;
00504
00505 private:
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 struct MorphingPair
00516 {
00517 Partial src;
00518 Partial tgt;
00519 };
00520 typedef std::map< Partial::label_type, MorphingPair > PartialCorrespondence;
00521
00525 void morph_aux( PartialCorrespondence & correspondence );
00526
00544
00545 void appendMorphedSrc( Breakpoint srcBkpt, const Partial & tgtPartial,
00546 double time, Partial & newp );
00547
00565
00566 void appendMorphedTgt( Breakpoint tgtBkpt, const Partial & srcPartial,
00567 double time, Partial & newp );
00568
00569
00570 };
00571
00572 }
00573
00574 #endif