RateTransposer.cpp | RateTransposer.cpp | |||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
/// Sample rate transposer. Changes sample rate by using linear interpolati on | /// Sample rate transposer. Changes sample rate by using linear interpolati on | |||
/// together with anti-alias filtering (first order interpolation with anti - | /// together with anti-alias filtering (first order interpolation with anti - | |||
/// alias filtering should be quite adequate for this application) | /// alias filtering should be quite adequate for this application) | |||
/// | /// | |||
/// Author : Copyright (c) Olli Parviainen | /// Author : Copyright (c) Olli Parviainen | |||
/// Author e-mail : oparviai 'at' iki.fi | /// Author e-mail : oparviai 'at' iki.fi | |||
/// SoundTouch WWW: http://www.surina.net/soundtouch | /// SoundTouch WWW: http://www.surina.net/soundtouch | |||
/// | /// | |||
/////////////////////////////////////////////////////////////////////////// ///// | /////////////////////////////////////////////////////////////////////////// ///// | |||
// | // | |||
// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $ | // Last changed : $Date: 2015-07-26 17:45:48 +0300 (Sun, 26 Jul 2015) $ | |||
// File revision : $Revision: 4 $ | // File revision : $Revision: 4 $ | |||
// | // | |||
// $Id: RateTransposer.cpp 195 2014-04-06 15:57:21Z oparviai $ | // $Id: RateTransposer.cpp 225 2015-07-26 14:45:48Z oparviai $ | |||
// | // | |||
/////////////////////////////////////////////////////////////////////////// ///// | /////////////////////////////////////////////////////////////////////////// ///// | |||
// | // | |||
// License : | // License : | |||
// | // | |||
// SoundTouch audio processing library | // SoundTouch audio processing library | |||
// Copyright (c) Olli Parviainen | // Copyright (c) Olli Parviainen | |||
// | // | |||
// This library is free software; you can redistribute it and/or | // This library is free software; you can redistribute it and/or | |||
// modify it under the terms of the GNU Lesser General Public | // modify it under the terms of the GNU Lesser General Public | |||
skipping to change at line 91 | skipping to change at line 91 | |||
return bUseAAFilter; | return bUseAAFilter; | |||
} | } | |||
AAFilter *RateTransposer::getAAFilter() | AAFilter *RateTransposer::getAAFilter() | |||
{ | { | |||
return pAAFilter; | return pAAFilter; | |||
} | } | |||
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slow er | // Sets new target iRate. Normal iRate = 1.0, smaller values represent slow er | |||
// iRate, larger faster iRates. | // iRate, larger faster iRates. | |||
void RateTransposer::setRate(float newRate) | void RateTransposer::setRate(double newRate) | |||
{ | { | |||
double fCutoff; | double fCutoff; | |||
pTransposer->setRate(newRate); | pTransposer->setRate(newRate); | |||
// design a new anti-alias filter | // design a new anti-alias filter | |||
if (newRate > 1.0f) | if (newRate > 1.0) | |||
{ | { | |||
fCutoff = 0.5f / newRate; | fCutoff = 0.5 / newRate; | |||
} | } | |||
else | else | |||
{ | { | |||
fCutoff = 0.5f * newRate; | fCutoff = 0.5 * newRate; | |||
} | } | |||
pAAFilter->setCutoffFreq(fCutoff); | pAAFilter->setCutoffFreq(fCutoff); | |||
} | } | |||
// Adds 'nSamples' pcs of samples from the 'samples' memory position into | // Adds 'nSamples' pcs of samples from the 'samples' memory position into | |||
// the input of the object. | // the input of the object. | |||
void RateTransposer::putSamples(const SAMPLETYPE *samples, uint nSamples) | void RateTransposer::putSamples(const SAMPLETYPE *samples, uint nSamples) | |||
{ | { | |||
processSamples(samples, nSamples); | processSamples(samples, nSamples); | |||
} | } | |||
skipping to change at line 212 | skipping to change at line 212 | |||
void TransposerBase::setAlgorithm(TransposerBase::ALGORITHM a) | void TransposerBase::setAlgorithm(TransposerBase::ALGORITHM a) | |||
{ | { | |||
TransposerBase::algorithm = a; | TransposerBase::algorithm = a; | |||
} | } | |||
// Transposes the sample rate of the given samples using linear interpolati on. | // Transposes the sample rate of the given samples using linear interpolati on. | |||
// Returns the number of samples returned in the "dest" buffer | // Returns the number of samples returned in the "dest" buffer | |||
int TransposerBase::transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src ) | int TransposerBase::transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src ) | |||
{ | { | |||
int numSrcSamples = src.numSamples(); | int numSrcSamples = src.numSamples(); | |||
int sizeDemand = (int)((float)numSrcSamples / rate) + 8; | int sizeDemand = (int)((double)numSrcSamples / rate) + 8; | |||
int numOutput; | int numOutput; | |||
SAMPLETYPE *psrc = src.ptrBegin(); | SAMPLETYPE *psrc = src.ptrBegin(); | |||
SAMPLETYPE *pdest = dest.ptrEnd(sizeDemand); | SAMPLETYPE *pdest = dest.ptrEnd(sizeDemand); | |||
#ifndef USE_MULTICH_ALWAYS | #ifndef USE_MULTICH_ALWAYS | |||
if (numChannels == 1) | if (numChannels == 1) | |||
{ | { | |||
numOutput = transposeMono(pdest, psrc, numSrcSamples); | numOutput = transposeMono(pdest, psrc, numSrcSamples); | |||
} | } | |||
else if (numChannels == 2) | else if (numChannels == 2) | |||
skipping to change at line 253 | skipping to change at line 253 | |||
TransposerBase::~TransposerBase() | TransposerBase::~TransposerBase() | |||
{ | { | |||
} | } | |||
void TransposerBase::setChannels(int channels) | void TransposerBase::setChannels(int channels) | |||
{ | { | |||
numChannels = channels; | numChannels = channels; | |||
resetRegisters(); | resetRegisters(); | |||
} | } | |||
void TransposerBase::setRate(float newRate) | void TransposerBase::setRate(double newRate) | |||
{ | { | |||
rate = newRate; | rate = newRate; | |||
} | } | |||
// static factory function | // static factory function | |||
TransposerBase *TransposerBase::newInstance() | TransposerBase *TransposerBase::newInstance() | |||
{ | { | |||
#ifdef SOUNDTOUCH_INTEGER_SAMPLES | #ifdef SOUNDTOUCH_INTEGER_SAMPLES | |||
// Notice: For integer arithmetics support only linear algorithm (due t o simplest calculus) | // Notice: For integer arithmetics support only linear algorithm (due t o simplest calculus) | |||
return ::new InterpolateLinearInteger; | return ::new InterpolateLinearInteger; | |||
End of changes. 8 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |