Permalink
Browse files

trailing whitespace

  • Loading branch information...
1 parent 379ef56 commit 1a4b00bfb651663bdda09a8486527d2a34404569 sinamas committed Feb 20, 2013
Showing 2,215 changed files with 44,685 additions and 44,685 deletions.
View
@@ -21,36 +21,36 @@
usec_t AdaptiveSleep::sleepUntil(usec_t base, usec_t inc) {
usec_t now = getusecs();
usec_t diff = now - base;
-
+
if (diff >= inc)
return diff - inc;
-
+
diff = inc - diff;
-
+
if (diff > oversleep + oversleepVar) {
diff -= oversleep + oversleepVar;
usecsleep(diff);
const usec_t ideal = now + diff;
now = getusecs();
-
+
{
usec_t curOversleep = now - ideal;
-
+
if (negate(curOversleep) < curOversleep)
curOversleep = 0;
-
+
oversleepVar = (oversleepVar * 15 + (curOversleep < oversleep ? oversleep - curOversleep : curOversleep - oversleep) + 8) >> 4;
oversleep = (oversleep * 15 + curOversleep + 8) >> 4;
}
-
+
noSleep = 60;
} else if (--noSleep == 0) {
noSleep = 60;
oversleep = oversleepVar = 0;
}
-
+
while (now - base < inc)
now = getusecs();
-
+
return 0;
}
View
@@ -25,7 +25,7 @@ class AdaptiveSleep {
usec_t oversleep;
usec_t oversleepVar;
unsigned noSleep;
-
+
public:
AdaptiveSleep() : oversleep(0), oversleepVar(0), noSleep(60) {}
usec_t sleepUntil(usec_t base, usec_t inc);
View
@@ -27,7 +27,7 @@ template<typename T>
class Array : Uncopyable {
T *a;
std::size_t sz;
-
+
public:
explicit Array(std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {}
~Array() { delete[] defined_ptr(a); }
@@ -40,7 +40,7 @@ class Array : Uncopyable {
template<typename T>
class ScopedArray : Uncopyable {
T *a_;
-
+
public:
explicit ScopedArray(T *a = 0) : a_(a) {}
~ScopedArray() { delete[] defined_ptr(a_); }
@@ -25,18 +25,18 @@
class Resampler {
long inRate_;
long outRate_;
-
+
protected:
void setRate(const long inRate, const long outRate) { inRate_ = inRate; outRate_ = outRate; }
Resampler() : inRate_(0), outRate_(0) {}
-
+
public:
/** Returns the sampling rate of the input that this resampler expects. */
long inRate() const { return inRate_; }
-
+
/** Returns the approximate sampling rate of the output. */
long outRate() const { return outRate_; }
-
+
/** Can be used to adjust the input and output sampling rates slightly with minimal disturbance in the output.
* Should only be used for slight changes or the quality could detoriate.
* It can for instance be useful to tweak the output rate slightly to synchronize production speed to playback
@@ -47,20 +47,20 @@ class Resampler {
* @param outRate Desired new output sampling rate.
*/
virtual void adjustRate(long inRate, long outRate) = 0;
-
+
/** Returns the exact ratio that this resampler is configured to use,
* such that the actual output sampling rate is (input rate) * mul / div.
* outRate() / inRate() is not necessarily equal to mul / div.
* Many resampler are intended for real-time purposes where it does not matter
* much whether the output sampling rate is 100% exact. Playback hardware is also slightly off.
*/
virtual void exactRatio(unsigned long &mul, unsigned long &div) const = 0;
-
+
/** Returns an upper bound on how many samples are produced for 'inlen' input samples.
* Can be used to calculate buffer sizes.
*/
virtual std::size_t maxOut(std::size_t inlen) const = 0;
-
+
/** Resamples the samples in 'in' and puts the resulting samples in 'out'.
*
* @param inlen The number of samples in 'in' to be resampled/consumed.
@@ -29,21 +29,21 @@
struct ResamplerInfo {
/** Short character string description of the resampler. */
const char *desc;
-
+
/** Points to a function that can be used to create an instance of the resampler.
* @param inRate The input sampling rate.
* @param outRate The desired output sampling rate.
* @param periodSz The maximum number of input samples to resample at a time. That is the maximal inlen passed to Resampler::resample.
* @return Pointer to the created instance (on the heap). Caller must free this with the delete operator.
*/
Resampler* (*create)(long inRate, long outRate, std::size_t periodSz);
-
+
/** Returns the number of ResamplerInfos that can be gotten with get(). */
static std::size_t num() { return num_; }
-
+
/** Returns ResamplerInfo number n. Where n is less than num(). */
static const ResamplerInfo& get(std::size_t n) { return resamplers[n]; }
-
+
private:
static const ResamplerInfo resamplers[];
static const std::size_t num_;
@@ -48,27 +48,27 @@ class BlackmanSinc : public SubResampler {
const float widthTimesTaps = 4.5f;
return std::max(static_cast<unsigned>(std::ceil(widthTimesTaps / rollOffWidth)), 4u);
}
-
+
static float toFc(const float rollOffStart, const int taps) {
const float startToFcDeltaTimesTaps = 1.69f;
return startToFcDeltaTimesTaps / taps + rollOffStart;
}
-
+
public:
const unsigned taps;
const float fc;
-
+
RollOff(float rollOffStart, float rollOffWidth) : taps(toTaps(rollOffWidth)), fc(toFc(rollOffStart, taps)) {}
};
BlackmanSinc(unsigned div, unsigned phaseLen, double fc)
: kernel(phaseLen * phases), convoluter_(kernel, phaseLen, div)
{ makeSincKernel(kernel, phases, phaseLen, fc, blackmanWin, 1.0); }
-
+
BlackmanSinc(unsigned div, RollOff ro, double gain)
: kernel(ro.taps * phases), convoluter_(kernel, ro.taps, div)
{ makeSincKernel(kernel, phases, ro.taps, ro.fc, blackmanWin, gain);}
-
+
std::size_t resample(short *out, const short *in, std::size_t inlen) { return convoluter_.filter(out, in, inlen); }
void adjustDiv(unsigned div) { convoluters_.adjustDiv(div); }
unsigned mul() const { return MUL; }
@@ -63,17 +63,17 @@ void ChainResampler::downinitAddSincResamplers(double ratio, float const outRate
// For high outRate: Start roll-off at 36000 Hz continue until outRate Hz, then wrap around back down to 40000 Hz.
const float outPeriod = 1.0f / outRate;
const float finalRollOffLen = std::max((outRate - 36000.0f + outRate - 40000.0f) * outPeriod, 0.2f);
-
+
{
const float midRollOffStart = std::min(36000.0f * outPeriod, 1.0f);
const float midRollOffEnd = std::min(40000.0f * outPeriod, 1.0f); // after wrap at folding freq.
const float midRollOffStartPlusEnd = midRollOffStart + midRollOffEnd;
const float ideal2ChainMidRatio = get2ChainMidRatio(ratio, finalRollOffLen, midRollOffStartPlusEnd);
-
+
int div_2c = int(ratio * smallSincMul / ideal2ChainMidRatio + 0.5f);
double ratio_2c = ratio * smallSincMul / div_2c;
float cost_2c = get2ChainCost(ratio, finalRollOffLen, ratio_2c, midRollOffStartPlusEnd);
-
+
if (cost_2c < get1ChainCost(ratio, finalRollOffLen)) {
const float ideal3ChainRatio1 = get3ChainRatio1(ratio_2c, finalRollOffLen,
ratio, midRollOffStartPlusEnd);
@@ -83,7 +83,7 @@ void ChainResampler::downinitAddSincResamplers(double ratio, float const outRate
midRollOffStartPlusEnd);
const int div2_3c = int(ratio1_3c * smallSincMul / ideal3ChainRatio2 + 0.5f);
const double ratio2_3c = ratio1_3c * smallSincMul / div2_3c;
-
+
if (get3ChainCost(ratio, finalRollOffLen, ratio1_3c,
ratio2_3c, midRollOffStartPlusEnd) < cost_2c) {
list.push_back(createSmallSinc(div1_3c,
@@ -95,7 +95,7 @@ void ChainResampler::downinitAddSincResamplers(double ratio, float const outRate
ratio_2c = ratio2_3c;
gain = 1.0;
}
-
+
list.push_back(createSmallSinc(div_2c,
0.5f * midRollOffStart / ratio,
(ratio_2c - 0.5f * midRollOffStartPlusEnd) / ratio,
@@ -104,7 +104,7 @@ void ChainResampler::downinitAddSincResamplers(double ratio, float const outRate
gain = 1.0;
}
}
-
+
list.push_back(bigSinc =
createBigSinc(int(bigSincMul * ratio + 0.5),
0.5f * (1.0f + std::max((outRate - 40000.0f) * outPeriod, 0.0f) - finalRollOffLen) / ratio,
@@ -115,24 +115,24 @@ std::size_t ChainResampler::reallocateBuffer() {
std::size_t bufSz[2] = { 0, 0 };
std::size_t inSz = periodSize;
int i = -1;
-
+
for (list_t::iterator it = list.begin(); it != list.end(); ++it) {
inSz = (inSz * (*it)->mul() - 1) / (*it)->div() + 1;
-
+
++i;
-
+
if (inSz > bufSz[i&1])
bufSz[i&1] = inSz;
}
-
+
if (inSz >= bufSz[i&1])
bufSz[i&1] = 0;
-
+
if (buffer.size() < (bufSz[0] + bufSz[1]) * channels)
buffer.reset((bufSz[0] + bufSz[1]) * channels);
-
+
buffer2 = bufSz[1] ? buffer + bufSz[0] * channels : 0;
-
+
return (maxOut_ = inSz);
}
@@ -148,7 +148,7 @@ void ChainResampler::adjustRate(const long inRate, const long outRate) {
void ChainResampler::exactRatio(unsigned long &mul, unsigned long &div) const {
mul = 1;
div = 1;
-
+
for (list_t::const_iterator it = list.begin(); it != list.end(); ++it) {
mul *= (*it)->mul();
div *= (*it)->div();
@@ -157,21 +157,21 @@ void ChainResampler::exactRatio(unsigned long &mul, unsigned long &div) const {
std::size_t ChainResampler::resample(short *const out, const short *const in, std::size_t inlen) {
assert(inlen <= periodSize);
-
+
short *const buf = buffer != buffer2 ? buffer : out;
short *const buf2 = buffer2 ? buffer2 : out;
-
+
const short *inbuf = in;
short *outbuf = 0;
-
+
for (list_t::iterator it = list.begin(); it != list.end(); ++it) {
outbuf = ++list_t::iterator(it) == list.end()
? out
: (inbuf == buf ? buf2 : buf);
inlen = (*it)->resample(outbuf, inbuf, inlen);
inbuf = outbuf;
}
-
+
return inlen;
}
Oops, something went wrong.

0 comments on commit 1a4b00b

Please sign in to comment.