Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/CepstrumF0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CepstrumF0
mCepstrum.setZero();
}

void processFrame(const RealVectorView& input, RealVectorView output,
void processFrame(const InputRealVectorView& input, RealVectorView output,
double minFreq, double maxFreq, double sampleRate, Allocator& alloc)
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/ChromaFilterBank.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ChromaFilterBank
mSampleRate = sampleRate;
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
double minFreq = 0, double maxFreq = -1, index normalize = 0)
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/DCT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DCT
mInitialized = true;
}

void processFrame(const RealVectorView in, RealVectorView out)
void processFrame(const InputRealVectorView in, RealVectorView out)
{
assert(mInitialized && "DCT: processFrame() called before init()");
assert(in.size() == mInputSize &&
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/HPS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HPS
{

public:
void processFrame(const RealVectorView& input, RealVectorView output,
void processFrame(const InputRealVectorView& input, RealVectorView output,
index nHarmonics, double minFreq, double maxFreq,
double sampleRate, Allocator& alloc)
{
Expand Down
13 changes: 6 additions & 7 deletions include/flucoma/algorithms/public/KDTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class KDTree
using string = std::string;

using DataSet = FluidDataSet<string, double, 1>;
using ConstRealVectorView = FluidTensorView<const double, 1>;
struct Node;
using NodePtr = std::shared_ptr<Node>;
using knnCandidate = std::pair<double, const Node*>;
Expand Down Expand Up @@ -72,13 +71,13 @@ class KDTree
mInitialized = true;
}

void addNode(string id, ConstRealVectorView data)
void addNode(string id, const InputRealVectorView data)
{
mRoot = addNode(mRoot.get(), id, data, 0);
mNPoints++;
}

KNNResult kNearest(ConstRealVectorView data, index k = 1, double radius = 0,
KNNResult kNearest(const InputRealVectorView data, index k = 1, double radius = 0,
Allocator& alloc = FluidDefaultAllocator()) const
{
assert(data.size() == mDims);
Expand Down Expand Up @@ -156,12 +155,12 @@ class KDTree
return current;
}

NodePtr makeNode(string id, ConstRealVectorView data) const
NodePtr makeNode(string id, const InputRealVectorView data) const
{
return std::make_shared<Node>(Node{id, RealVector{data}, nullptr, nullptr});
}

NodePtr addNode(Node* current, string id, ConstRealVectorView data,
NodePtr addNode(Node* current, string id, const InputRealVectorView data,
const index depth) const
{
if (current == nullptr) { return makeNode(id, data); }
Expand All @@ -176,7 +175,7 @@ class KDTree
return NodePtr(current);
}

double distance(ConstRealVectorView p1, ConstRealVectorView p2) const
double distance(const InputRealVectorView p1, const InputRealVectorView p2) const
{
using namespace Eigen;
auto v1 = _impl::asEigen<Array>(p1);
Expand All @@ -201,7 +200,7 @@ class KDTree
print(current->right.get(), depth + 1);
}

void kNearest(const Node* current, ConstRealVectorView data, knnQueue& knn,
void kNearest(const Node* current, const InputRealVectorView data, knnQueue& knn,
index k, double radius, index depth) const
{
if (current == nullptr) return;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/Loudness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Loudness
mInitialized = true;
}

void processFrame(const RealVectorView& input, RealVectorView output,
void processFrame(const InputRealVectorView& input, RealVectorView output,
bool weighting, bool truePeak, Allocator& alloc = FluidDefaultAllocator())
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/MelBands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MelBands
mNBins = nBins;
}

void processFrame(const RealVectorView in, RealVectorView out, bool magNorm,
void processFrame(const InputRealVectorView in, RealVectorView out, bool magNorm,
bool usePower, bool logOutput, Allocator&)
Comment on lines +79 to 80
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/NMF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NMF
}

// processFrame computes activations of a dictionary W in a given frame
void processFrame(const RealVectorView x, const RealMatrixView W0,
void processFrame(const InputRealVectorView x, const RealMatrixView W0,
RealVectorView out, index nIterations, RealVectorView v,
index randomSeed, Allocator& alloc)
{
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/Normalization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Normalization
mInitialized = true;
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
bool inverse = false) const
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/NoveltyFeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NoveltyFeature
mInitialized = true;
}

double processFrame(const RealVectorView input, Allocator& alloc)
double processFrame(const InputRealVectorView input, Allocator& alloc)
{
assert(mInitialized);
double novelty =
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/NoveltySegmentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NoveltySegmentation
mPeakBuffer.setZero();
}

double processFrame(const RealVectorView input, double threshold,
double processFrame(const InputRealVectorView input, double threshold,
index minSliceLength, Allocator& alloc = FluidDefaultAllocator())
{
double detected = 0.;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/PCA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PCA
mInitialized = true;
}

void processFrame(const RealVectorView in, RealVectorView out, index k,
void processFrame(const InputRealVectorView in, RealVectorView out, index k,
bool whiten = false) const
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/RobustScaling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RobustScaling
mInitialized = true;
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
bool inverse = false) const
{
using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/RunningStats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RunningStats
}

template<typename T>
void process(FluidTensorView<T, 1> in, FluidTensorView<T, 1> meanOut,
void process(FluidTensorView<const T, 1> in, FluidTensorView<T, 1> meanOut,
FluidTensorView<T, 1> stdDevOut)
{
// Moving average and _sample_ standard deviation
Expand Down
19 changes: 7 additions & 12 deletions include/flucoma/algorithms/public/STFT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,31 @@ class STFT
mFFT.resize(fftSize);
}

static void magnitude(const FluidTensorView<std::complex<double>, 2> in,
FluidTensorView<double, 2> out)
static void magnitude(const InputComplexMatrixView in, RealMatrixView out)
{
_impl::asEigen<Eigen::Array>(out) =
_impl::asEigen<Eigen::Array>(in).abs().real();
}

static void magnitude(const FluidTensorView<std::complex<double>, 1> in,
FluidTensorView<double, 1> out)
static void magnitude(const InputComplexVectorView in, RealVectorView out)
{
_impl::asEigen<Eigen::Array>(out) =
_impl::asEigen<Eigen::Array>(in).abs().real();
}

static void phase(const FluidTensorView<std::complex<double>, 2> in,
FluidTensorView<double, 2> out)
static void phase(const InputComplexMatrixView in, RealMatrixView out)
{
_impl::asEigen<Eigen::Array>(out) =
_impl::asEigen<Eigen::Array>(in).arg().real();
}

static void phase(const FluidTensorView<std::complex<double>, 1> in,
FluidTensorView<double, 1> out)
static void phase(const InputComplexVectorView in, RealVectorView out)
{
phase(FluidTensorView<std::complex<double>, 2>(in),
FluidTensorView<double, 2>(out));
phase(InputComplexMatrixView(in), RealMatrixView(out));
}


void process(const RealVectorView audio, ComplexMatrixView spectrogram)
void process(const InputRealVectorView audio, ComplexMatrixView spectrogram)
{
index halfWindow = mWindowSize / 2;
ArrayXdMap window(mWindowBuffer.data(), mWindowSize);
Expand All @@ -107,7 +102,7 @@ class STFT
spectrogram <<= _impl::asFluid(result);
}

void processFrame(const RealVectorView frame, ComplexVectorView out)
void processFrame(const InputRealVectorView frame, ComplexVectorView out)
{
assert(frame.size() == mWindowSize);
ArrayXdMap window(mWindowBuffer.data(), mWindowSize);
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/SpectralShape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SpectralShape
mOutputBuffer(6) = 20 * log10(max(crest, epsilon));
}

void processFrame(const RealVectorView input, RealVectorView output,
void processFrame(const InputRealVectorView input, RealVectorView output,
double sampleRate, double minFreq, double maxFreq,
double rolloffTarget, bool logFreq, bool usePower,
Allocator& alloc)
Expand Down
4 changes: 2 additions & 2 deletions include/flucoma/algorithms/public/Standardization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Standardization
mInitialized = true;
}

void init(const RealVectorView mean, const RealVectorView std)
void init(const InputRealVectorView mean, const InputRealVectorView std)
{
using namespace Eigen;
using namespace _impl;
Expand All @@ -48,7 +48,7 @@ class Standardization
mInitialized = true;
}

void processFrame(const RealVectorView in, RealVectorView out,
void processFrame(const InputRealVectorView in, RealVectorView out,
bool inverse = false) const
{
using namespace Eigen;
Expand Down
36 changes: 17 additions & 19 deletions include/flucoma/algorithms/public/TransientExtraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TransientExtraction
return mCount;
}

void process(const RealVectorView input, RealVectorView transients,
void process(const InputRealVectorView input, RealVectorView transients,
RealVectorView residual, Allocator& alloc = FluidDefaultAllocator())
{
assert(mInitialized && "Call init() before processing");
Expand All @@ -121,7 +121,7 @@ class TransientExtraction
interpolate(transients.data(), residual.data(), alloc);
}

void process(const RealVectorView input, const RealVectorView unknowns,
void process(const InputRealVectorView input, const InputRealVectorView unknowns,
RealVectorView transients, RealVectorView residual,
Allocator& alloc = FluidDefaultAllocator())
{
Expand Down Expand Up @@ -156,7 +156,7 @@ class TransientExtraction
void analyze(Allocator& alloc)
{
mModel.setMinVariance(0.0000001);
mModel.estimate(FluidTensorView<const double, 1>(
mModel.estimate(InputRealVectorView(
mInput.data(), modelOrder(), analysisSize()),
3, 3.0, alloc);
}
Expand All @@ -168,12 +168,12 @@ class TransientExtraction
// Forward and backward error
const double normFactor = 1.0 / sqrt(mModel.variance());

auto inputView = FluidTensorView<const double, 1>(mInput.data(),
auto inputView = InputRealVectorView(mInput.data(),
modelOrder() + padSize(),
blockSize() + modelOrder() + mDetectHalfWindow);
auto fwdError = FluidTensorView<double, 1>(
mForwardError.data(), 0, blockSize() + mDetectHalfWindow);
auto backError = FluidTensorView<double, 1>(
auto fwdError = RealVectorView(
mForwardError.data(), 0, blockSize() + mDetectHalfWindow);
auto backError = RealVectorView(
mBackwardError.data(), 0, blockSize() + mDetectHalfWindow);

errorCalculation<&ARModel::forwardErrorArray>(
Expand All @@ -183,9 +183,9 @@ class TransientExtraction

// Window error functions (brute force convolution)
auto fwdWindowedError =
FluidTensorView<double, 1>(mForwardWindowedError.data(), 0, hopSize());
RealVectorView(mForwardWindowedError.data(), 0, hopSize());
auto backWindowedError =
FluidTensorView<double, 1>(mBackwardWindowedError.data(), 0, hopSize());
RealVectorView(mBackwardWindowedError.data(), 0, hopSize());

windowError(fwdError(Slice(modelOrder())), fwdWindowedError);
windowError(backError(Slice(modelOrder())), backWindowedError);
Expand Down Expand Up @@ -263,7 +263,7 @@ class TransientExtraction
mCount = count;
}

template <double Method(const RealVectorView&)>
template <double Method(const InputRealVectorView&)>
double calcStat(const double* input, index size)
{
RealVectorView view(const_cast<double*>(input), 0, size);
Expand Down Expand Up @@ -334,7 +334,7 @@ class TransientExtraction
residual[i] = input[i + order];
}

// if (mRefine) refine(FluidTensorView<double, 1>(residual, 0, size), Au,
// if (mRefine) refine(RealVectorView(residual, 0, size), Au,
// u);

for (index i = 0; i < (size - order); i++)
Expand All @@ -345,8 +345,7 @@ class TransientExtraction
mInput.data() + padSize() + order + order);
}

void refine(
FluidTensorView<double, 1> io, Eigen::MatrixXd& Au, Eigen::MatrixXd& ls)
void refine(RealVectorView io, Eigen::MatrixXd& Au, Eigen::MatrixXd& ls)
{
const double energy = mModel.variance() * mCount;
double energyLS = 0.0;
Expand Down Expand Up @@ -394,10 +393,9 @@ class TransientExtraction
return sum;
}

template <void (ARModel::*Method)(
FluidTensorView<const double, 1>, FluidTensorView<double, 1>)>
void errorCalculation(FluidTensorView<const double, 1> input,
FluidTensorView<double, 1> error, double normFactor)
template <void (ARModel::*Method)(const InputRealVectorView, RealVectorView)>
void errorCalculation(InputRealVectorView input, RealVectorView error,
double normFactor)
{
(mModel.*Method)(input, error);

Expand All @@ -409,8 +407,8 @@ class TransientExtraction
// Triangle window
double calcWindow(double norm) { return std::min(norm, 1.0 - norm); }

void windowError(FluidTensorView<const double, 1> error,
FluidTensorView<double, 1> errorWindowed)
void windowError(const InputRealVectorView error,
RealVectorView errorWindowed)
{
assert(error.descriptor().start >= mDetectHalfWindow &&
"insufficient offset for filter size");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TransientSegmentation : public algorithm::TransientExtraction
mDebounce = 0;
}

void process(const RealVectorView input, RealVectorView output,
void process(const InputRealVectorView input, RealVectorView output,
Allocator& alloc = FluidDefaultAllocator())
{
detect(input.data(), input.extent(0), alloc);
Expand Down
2 changes: 1 addition & 1 deletion include/flucoma/algorithms/public/YINFFT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class YINFFT
: mFFT(2 * maxInputSize - 1, alloc)
{}

void processFrame(const RealVectorView& input, RealVectorView output,
void processFrame(const InputRealVectorView& input, RealVectorView output,
double minFreq, double maxFreq, double sampleRate,
Allocator& alloc = FluidDefaultAllocator())
{
Expand Down
Loading
Loading