123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- #ifndef TDStretch_H
- #define TDStretch_H
- #include <stddef.h>
- #include "STTypes.h"
- #include "RateTransposer.h"
- #include "FIFOSamplePipe.h"
- namespace soundtouch
- {
- #define DEFAULT_SEQUENCE_MS USE_AUTO_SEQUENCE_LEN
- #define USE_AUTO_SEQUENCE_LEN 0
- #define DEFAULT_SEEKWINDOW_MS USE_AUTO_SEEKWINDOW_LEN
- #define USE_AUTO_SEEKWINDOW_LEN 0
- #define DEFAULT_OVERLAP_MS 8
- class TDStretch : public FIFOProcessor
- {
- protected:
- int channels;
- int sampleReq;
- int overlapLength;
- int seekLength;
- int seekWindowLength;
- int overlapDividerBitsNorm;
- int overlapDividerBitsPure;
- int slopingDivider;
- int sampleRate;
- int sequenceMs;
- int seekWindowMs;
- int overlapMs;
- unsigned long maxnorm;
- float maxnormf;
- double tempo;
- double nominalSkip;
- double skipFract;
- bool bQuickSeek;
- bool bAutoSeqSetting;
- bool bAutoSeekSetting;
- bool isBeginning;
- SAMPLETYPE *pMidBuffer;
- SAMPLETYPE *pMidBufferUnaligned;
- FIFOSampleBuffer outputBuffer;
- FIFOSampleBuffer inputBuffer;
- void acceptNewOverlapLength(int newOverlapLength);
- virtual void clearCrossCorrState();
- void calculateOverlapLength(int overlapMs);
- virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm);
- virtual double calcCrossCorrAccumulate(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm);
- virtual int seekBestOverlapPositionFull(const SAMPLETYPE *refPos);
- virtual int seekBestOverlapPositionQuick(const SAMPLETYPE *refPos);
- virtual int seekBestOverlapPosition(const SAMPLETYPE *refPos);
- virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
- virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
- virtual void overlapMulti(SAMPLETYPE *output, const SAMPLETYPE *input) const;
- void clearMidBuffer();
- void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
- void calcSeqParameters();
- void adaptNormalizer();
-
-
-
-
- void processSamples();
-
- public:
- TDStretch();
- virtual ~TDStretch() override;
-
-
- static void *operator new(size_t s);
-
-
-
- static TDStretch *newInstance();
-
-
- FIFOSamplePipe *getOutput() { return &outputBuffer; };
-
- FIFOSamplePipe *getInput() { return &inputBuffer; };
-
-
- void setTempo(double newTempo);
-
- virtual void clear() override;
-
- void clearInput();
-
- void setChannels(int numChannels);
-
-
- void enableQuickSeek(bool enable);
-
- bool isQuickSeekEnabled() const;
-
-
-
-
-
-
-
-
- void setParameters(int sampleRate,
- int sequenceMS = -1,
- int seekwindowMS = -1,
- int overlapMS = -1
- );
-
-
-
- void getParameters(int *pSampleRate, int *pSequenceMs, int *pSeekWindowMs, int *pOverlapMs) const;
-
-
- virtual void putSamples(
- const SAMPLETYPE *samples,
- uint numSamples
-
- ) override;
-
- int getInputSampleReq() const
- {
- return (int)(nominalSkip + 0.5);
- }
-
- int getOutputBatchSize() const
- {
- return seekWindowLength - overlapLength;
- }
-
- int getLatency() const
- {
- return sampleReq;
- }
- };
- #ifdef SOUNDTOUCH_ALLOW_MMX
-
- class TDStretchMMX : public TDStretch
- {
- protected:
- double calcCrossCorr(const short *mixingPos, const short *compare, double &norm) override;
- double calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm) override;
- virtual void overlapStereo(short *output, const short *input) const override;
- virtual void clearCrossCorrState() override;
- };
- #endif
- #ifdef SOUNDTOUCH_ALLOW_SSE
-
- class TDStretchSSE : public TDStretch
- {
- protected:
- double calcCrossCorr(const float *mixingPos, const float *compare, double &norm) override;
- double calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm) override;
- };
- #endif
- }
- #endif
|