HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::TimeStretcher Class Reference

changes the playback speed of the audio data without changing the pitch. More...

#include <TimeStretcher.h>

Inheritance diagram for HephAudio::TimeStretcher:
HephAudio::OlaEffect HephAudio::DoubleBufferedAudioEffect HephAudio::AudioEffect

Public Member Functions

 TimeStretcher ()
 
 TimeStretcher (double speed)
 
 TimeStretcher (double speed, size_t hopSize)
 
 TimeStretcher (double speed, size_t hopSize, const Window &wnd)
 
virtual ~TimeStretcher ()=default
 
virtual std::string Name () const override
 
virtual bool HasRTSupport () const override
 
virtual size_t CalculateRequiredFrameCount (size_t outputFrameCount, const AudioFormatInfo &formatInfo) const override
 
virtual size_t CalculateOutputFrameCount (size_t inputFrameCount, const AudioFormatInfo &formatInfo) const override
 
virtual double GetSpeed () const
 
virtual void SetSpeed (double speed)
 
- Public Member Functions inherited from HephAudio::OlaEffect
virtual ~OlaEffect ()=default
 
virtual void ResetInternalState () override
 
virtual void Process (AudioBuffer &buffer, size_t startIndex, size_t frameCount) override
 
virtual size_t GetHopSize () const
 
virtual void SetHopSize (size_t hopSize)
 
virtual size_t GetWindowSize () const
 
virtual void SetWindow (const Window &wnd)
 
virtual void Process (AudioBuffer &buffer)
 
virtual void Process (AudioBuffer &buffer, size_t startIndex)
 
- Public Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
virtual ~DoubleBufferedAudioEffect ()=default
 
- Public Member Functions inherited from HephAudio::AudioEffect
virtual ~AudioEffect ()=default
 
virtual bool HasMTSupport () const
 
virtual size_t GetThreadCount () const
 
virtual void SetThreadCount (size_t threadCount)
 
virtual size_t CalculateAdvanceSize (size_t renderFrameCount, const AudioFormatInfo &formatInfo) const
 

Protected Member Functions

virtual void ProcessST (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) override
 
- Protected Member Functions inherited from HephAudio::OlaEffect
 OlaEffect ()
 
 OlaEffect (size_t hopSize)
 
 OlaEffect (size_t hopSize, const Window &wnd)
 
virtual size_t CalculateMaxNumberOfOverlaps () const
 
virtual size_t CalculatePastSamplesSize () const
 
- Protected Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
 DoubleBufferedAudioEffect ()
 
virtual AudioBuffer CreateOutputBuffer (const AudioBuffer &inputBuffer, size_t startIndex, size_t frameCount) const
 
virtual void InitializeOutputBuffer (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) const
 
- Protected Member Functions inherited from HephAudio::AudioEffect
 AudioEffect ()
 
virtual void ProcessMT (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount)
 

Protected Attributes

double speed
 
- Protected Attributes inherited from HephAudio::OlaEffect
size_t hopSize
 
Heph::DoubleBuffer wnd
 
size_t currentIndex
 
AudioBuffer pastSamples
 
- Protected Attributes inherited from HephAudio::AudioEffect
size_t threadCount
 

Detailed Description

changes the playback speed of the audio data without changing the pitch.

Constructor & Destructor Documentation

◆ TimeStretcher() [1/4]

HephAudio::TimeStretcher::TimeStretcher ( )

creates a new instance and initializes it with default values.

◆ TimeStretcher() [2/4]

HephAudio::TimeStretcher::TimeStretcher ( double speed)
explicit

creates a new instance and initializes it with the provided values.

Parameters
speedplayback speed factor.

◆ TimeStretcher() [3/4]

HephAudio::TimeStretcher::TimeStretcher ( double speed,
size_t hopSize )

creates a new instance and initializes it with the provided values.

Parameters
speedplayback speed factor.
hopSizenumber of frames to advance each iteration.

◆ TimeStretcher() [4/4]

HephAudio::TimeStretcher::TimeStretcher ( double speed,
size_t hopSize,
const Window & wnd )

creates a new instance and initializes it with the provided values.

Parameters
speedplayback speed factor.
hopSizenumber of frames to advance each iteration.
wndwindow that will be applied for overlap-add.

◆ ~TimeStretcher()

virtual HephAudio::TimeStretcher::~TimeStretcher ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

virtual std::string HephAudio::TimeStretcher::Name ( ) const
overridevirtual

gets the name of the audio effect.

Implements HephAudio::AudioEffect.

◆ HasRTSupport()

virtual bool HephAudio::TimeStretcher::HasRTSupport ( ) const
overridevirtual

checks whether the effect can be applied in real-time.

Reimplemented from HephAudio::AudioEffect.

◆ CalculateRequiredFrameCount()

virtual size_t HephAudio::TimeStretcher::CalculateRequiredFrameCount ( size_t outputFrameCount,
const AudioFormatInfo & formatInfo ) const
overridevirtual

calculates the number of frames required to obtain the number of frames desired for the output buffer.

Parameters
outputFrameCountthe number of frames desired for the output buffer.
formatInfothe format info of the input buffer.

Reimplemented from HephAudio::OlaEffect.

◆ CalculateOutputFrameCount()

virtual size_t HephAudio::TimeStretcher::CalculateOutputFrameCount ( size_t inputFrameCount,
const AudioFormatInfo & formatInfo ) const
overridevirtual

calculates the number of frames the buffer will contain after applying the effect.

Parameters
inputFrameCountthe number of frames of the input buffer.
formatInfothe format info of the input buffer.

Reimplemented from HephAudio::AudioEffect.

◆ GetSpeed()

virtual double HephAudio::TimeStretcher::GetSpeed ( ) const
virtual

gets the speed factor.

◆ SetSpeed()

virtual void HephAudio::TimeStretcher::SetSpeed ( double speed)
virtual

sets the speed factor.

Parameters
speedplayback speed factor.

◆ ProcessST()

virtual void HephAudio::TimeStretcher::ProcessST ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount )
overrideprotectedvirtual

applies the effect using single thread.

Parameters
inputBuffercontains the audio data which will be processed.
outputBuffercontains the processed audio data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Implements HephAudio::AudioEffect.

Member Data Documentation

◆ speed

double HephAudio::TimeStretcher::speed
protected

playback speed factor.