Copyright | (c) Celina Pawlińska 2020 Marek Materzok 2021 |
---|---|
License | BSD2 |
Safe Haskell | None |
Language | Haskell2010 |
This module implements the phase vocoder algorithms. The implementation is designed to be used directly or to be integrated into some convenient abstraction (streaming or FRP).
Synopsis
- type Moduli = Vector Double
- type Phase = Vector Double
- type PhaseInc = Vector Double
- type Frame = Vector Double
- type Window = Frame
- type HopSize = Int
- type Length = Int
- type STFTFrame = (Moduli, PhaseInc)
- type FFTOutput = Vector (Complex Double)
- data VocoderParams
- vocoderParams :: Length -> HopSize -> Window -> VocoderParams
- vocFrameLength :: VocoderParams -> Length
- vocInputFrameLength :: VocoderParams -> Length
- vocFreqFrameLength :: VocoderParams -> Length
- vocHopSize :: VocoderParams -> HopSize
- vocWindow :: VocoderParams -> Window
- doFFT :: VocoderParams -> Frame -> FFTOutput
- doIFFT :: VocoderParams -> FFTOutput -> Frame
- analysisBlock :: VocoderParams -> Phase -> Frame -> (Phase, STFTFrame)
- analysisStep :: HopSize -> Length -> Phase -> FFTOutput -> (Phase, STFTFrame)
- analysisStage :: Traversable t => VocoderParams -> Phase -> t Frame -> (Phase, t STFTFrame)
- synthesisBlock :: VocoderParams -> Phase -> STFTFrame -> (Phase, Frame)
- synthesisStep :: HopSize -> Phase -> STFTFrame -> (Phase, FFTOutput)
- synthesisStage :: Traversable t => VocoderParams -> Phase -> t STFTFrame -> (Phase, t Frame)
- zeroPhase :: VocoderParams -> Phase
- volumeCoeff :: VocoderParams -> Double
- frameFromComplex :: FFTOutput -> STFTFrame
- frameToComplex :: STFTFrame -> FFTOutput
- addFrames :: STFTFrame -> STFTFrame -> STFTFrame
Documentation
type PhaseInc = Vector Double Source #
Phase increments. Represent the deviation of the phase difference between successive frames from the expected difference for the center frequencies of the FFT bins.
data VocoderParams Source #
Configuration parameters for the phase vocoder algorithm.
vocoderParams :: Length -> HopSize -> Window -> VocoderParams Source #
Create a vocoder configuration.
vocFrameLength :: VocoderParams -> Length Source #
FFT frame length. Can be larger than vocInputFrameLength
for zero-padding.
vocInputFrameLength :: VocoderParams -> Length Source #
STFT frame length.
vocFreqFrameLength :: VocoderParams -> Length Source #
FFT frequency frame length.
vocHopSize :: VocoderParams -> HopSize Source #
STFT hop size.
vocWindow :: VocoderParams -> Window Source #
Window function used during analysis and synthesis.
doFFT :: VocoderParams -> Frame -> FFTOutput Source #
Perform FFT processing, which includes the actual FFT, rewinding, zero-paddding and windowing.
doIFFT :: VocoderParams -> FFTOutput -> Frame Source #
Perform IFFT processing, which includes the actual IFFT, rewinding, removing padding and windowing.
analysisBlock :: VocoderParams -> Phase -> Frame -> (Phase, STFTFrame) Source #
Perform FFT transform and frequency-domain analysis.
analysisStep :: HopSize -> Length -> Phase -> FFTOutput -> (Phase, STFTFrame) Source #
Analyze a frequency domain frame. Phase from a previous frame must be supplied. It returns the phase of the analyzed frame and the result.
analysisStage :: Traversable t => VocoderParams -> Phase -> t Frame -> (Phase, t STFTFrame) Source #
Perform analysis on a sequence of frames. This consists of FFT processing and performing analysis on frequency domain frames.
synthesisBlock :: VocoderParams -> Phase -> STFTFrame -> (Phase, Frame) Source #
Perform frequency-domain synthesis and IFFT transform.
synthesisStep :: HopSize -> Phase -> STFTFrame -> (Phase, FFTOutput) Source #
Synthesize a frequency domain frame. Phase from the previously synthesized frame must be supplied. It returns the phase of the synthesized frame and the result.
synthesisStage :: Traversable t => VocoderParams -> Phase -> t STFTFrame -> (Phase, t Frame) Source #
Perform synthesis on a sequence of frames. This consists of performing synthesis and IFFT processing.
zeroPhase :: VocoderParams -> Phase Source #
Zero phase for a given vocoder configuration. Can be used to initialize the synthesis stage.
volumeCoeff :: VocoderParams -> Double Source #
An amplitude change coefficient for the processing pipeline. Can be used to ensure that the output has the same volume as the input.
frameFromComplex :: FFTOutput -> STFTFrame Source #
Converts frame representation to magnitude and phase.
frameToComplex :: STFTFrame -> FFTOutput Source #
Converts frame representation to complex numbers.