Skip to content

Commit 2011fc0

Browse files
committed
refactoring directory strucrture, includes to brackets for libraries, quotes for files. Assuming 'include' is in the include path
1 parent 7bbc5ec commit 2011fc0

20 files changed

Lines changed: 277 additions & 417 deletions

examples/test_fluidbuffer.cpp

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
2-
#include "FluidBuffers.hpp"
3-
#include "Windows.hpp"
4-
51
#include <cmath>
62

3+
#include "data/FluidBuffers.hpp"
4+
#include "algorithms/Windows.hpp"
5+
76
using fluid::FluidTensor;
87
using fluid::slice;
98
using fluid::FluidSource;
@@ -12,40 +11,40 @@ int main(int argc, char* argv[])
1211
{
1312
// using fluid::FluidSource;
1413
// using fluid::FluidSink;
15-
//
14+
//
1615
// FluidSource<double> source(100);
17-
//
16+
//
1817
// FluidTensor<double, 2> input(1,55);
1918
// std::iota(input.begin(), input.end(),0);
20-
// std::cout << input << '\n';
19+
// std::cout << input << '\n';
2120
// source.push(input);
2221
// source.push(input);
2322
//
2423
// source.reset();
25-
//
26-
//
24+
//
25+
//
2726
// FluidTensor<double, 2> ramp_to_99(1,100);
2827
// std::iota(ramp_to_99.begin(),ramp_to_99.end(),0);
29-
// source.push(ramp_to_99);
30-
//
28+
// source.push(ramp_to_99);
29+
//
3130
// for(int i = 0 ; i < 10; ++i)
3231
// {
3332
// FluidTensor<double,2> output = source.pull(10);
3433
// std::cout << output << '\n';
3534
// }
36-
//
37-
//
38-
//
35+
//
36+
//
37+
//
3938
// source.reset();
4039
// source.resize(1024);
41-
//
40+
//
4241
// FluidTensor<double, 2> cycle(1,64);
4342
// std::iota(cycle.begin(), cycle.end(), 0);
4443
// cycle.apply([](double&x){
4544
// x = std::cos(2 * M_PI * x * (1/64));
4645
// });
47-
//
48-
//
46+
//
47+
//
4948
// //Simulate data coming in smaller packets than being pulled out (implies a latency...)
5049
// //should see in the console that available grows, and then gets consumed
5150
// for(int i = 0; i < 64; ++i)
@@ -58,14 +57,14 @@ int main(int argc, char* argv[])
5857
// }
5958
// std::cout << "After " << source.available() << '\n';
6059
// }
61-
//
60+
//
6261
///************************************************************************
6362
// OLA end to end test
6463
// - Write in data to source, extract with hop
6564
// – window segment, ola into sink
6665
// – pull out from sink and compare with original
6766
// **************************************************************************/
68-
//
67+
//
6968
// size_t framesize = 1024;
7069
// //read with overlap of four
7170
// size_t hop = framesize >> 2;
@@ -74,7 +73,7 @@ int main(int argc, char* argv[])
7473
//
7574
// size_t signal_length = framesize * n_frames;
7675
// size_t padded_length = signal_length + framesize;
77-
//
76+
//
7877
// //Make a tensor for the signal, with half a frame's zero padding each end
7978
// FluidTensor<double, 2> sine(1,padded_length);
8079
// //Grab the bit without zero padding
@@ -88,42 +87,41 @@ int main(int argc, char* argv[])
8887
// FluidTensor<double,2> window(1,framesize);
8988
// std::vector<double> win=fluid::windows::windowFuncs[fluid::windows::WindowType::Hann](framesize);
9089
// std::copy(win.begin(), win.end(), window.begin());
91-
//
90+
//
9291
// //Buffer in
9392
// FluidSource<double> sine_in(padded_length);
9493
// //Buffer out
9594
// FluidSink<double> sine_out(1,padded_length);
9695
// //Normalisation buffer for window
9796
// FluidSink<double> norm_out(1,padded_length);
98-
//
97+
//
9998
// //push signal in
10099
// sine_in.push(sine);
101-
//
100+
//
102101
// //Pull out frames from source, window and push in to sink
103102
// for(int i = 0; i<n_hops;++i)
104103
// {
105104
// FluidTensor<double,2> frame = sine_in.pull(framesize,hop)
106105
// .apply(window,[](double& x, double w){x*=w;});
107-
//
106+
//
108107
// norm_out.push(window,hop);
109108
// sine_out.push(frame,hop);
110109
// }
111-
//
110+
//
112111
// //Grab the whole result from sink
113112
// FluidTensor<double,2> result = sine_out.pull(padded_length);
114-
//
113+
//
115114
// //Apply OLA normalisation
116115
// result.apply(norm_out.pull(padded_length),[](double& x, double y)
117116
// {
118117
// if(x)
119118
// x /= y > 0? y : 1 ;
120119
// });
121-
//
120+
//
122121
// //Subtract original from result
123122
// result.apply(sine, [](double& x, double y){ x -= y; });
124-
// //sum this difference
123+
// //sum this difference
125124
// double sum_of_diff = std::accumulate(result.begin(), result.end(), 0.0);
126125
// //we want it to be small, kthx
127126
// std::cout << "Difference summed " << sum_of_diff << '\n';
128127
}
129-

examples/test_fluidtensor.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#include "FluidTensor.hpp"
21
#include <stdio.h>
32
#include <Eigen/Dense>
3+
#include "data/FluidTensor.hpp"
44
#include "util/audiofile.hpp"
5+
56
using fluid::audiofile::AudioFileData;
67
using fluid::audiofile::readFile;
78

@@ -35,8 +36,8 @@ int main(int argc, char* argv[])
3536

3637
fluid::FluidTensor<double,1> r2(tinit2.row(1));
3738
std::cout << "1 2 3?" << r1 << '\n';
38-
39-
39+
40+
4041
//tinit2.row(1) = r2(fluid::slice(0,3));
4142
//Initialize with vector
4243
std::cout << "tinit2"<<tinit2 << '\n';
@@ -115,7 +116,7 @@ int main(int argc, char* argv[])
115116
//use() with integer types to get elements
116117
assert(c2[i] == twodeecee[i][col_offset]);
117118
}
118-
std::cout << "Col 3: " << c2 << '\n';
119+
std::cout << "Col 3: " << c2 << '\n';
119120

120121
//Free memory from double**, we're done with it
121122
for(int i = 0; i < x; ++i)
@@ -132,7 +133,7 @@ int main(int argc, char* argv[])
132133
copy_col.row(0)(fluid::slice(0,3)) = c2(fluid::slice(0,3,2));
133134

134135
fluid::FluidTensorView<double,1> aa = c2(fluid::slice(0,3,2));
135-
136+
136137
std::cout<<"Original column " << c2 <<'\n';
137138

138139
std::cout<<"Sub-column " << aa[0] <<'\n';
@@ -260,13 +261,13 @@ int main(int argc, char* argv[])
260261
std::cout << "Difference summed " << sum_of_diff << '\n';
261262

262263
double* interleave = new double[100];
263-
264+
264265
std::iota(interleave, interleave+100,0);
265-
266-
//Test for assumption about reading from interleaved structure (e.g multichannel buffers in max and sc)
266+
267+
//Test for assumption about reading from interleaved structure (e.g multichannel buffers in max and sc)
267268
fluid::FluidTensorView<double,2> interT = fluid::FluidTensorView<double,2>({0,{50,2}},interleave);
268-
269+
269270
std::cout << interT.col(0) << '\n';
270-
271-
271+
272+
272273
}

examples/test_nmf.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#include "util/audiofile.hpp"
2-
#include <FluidTensor.hpp>
3-
#include <NMF.hpp>
4-
#include <RatioMask.hpp>
5-
#include <STFT.hpp>
61
#include <iostream>
72
#include <string>
83

4+
#include "util/audiofile.hpp"
5+
#include "data/FluidTensor.hpp"
6+
#include "algorithms/NMF.hpp"
7+
#include "algorithms/RatioMask.hpp"
8+
#include "algorithms/STFT.hpp"
9+
910
int main(int argc, char *argv[]) {
1011
const auto &epsilon = std::numeric_limits<double>::epsilon;
1112

examples/test_sineextraction.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "util/audiofile.hpp"
2-
#include <ConvolutionTools.hpp>
31
#include <Eigen/Dense>
4-
#include <FluidTensor.hpp>
5-
#include <HISSTools_FFT/HISSTools_FFT.h>
6-
#include <STFT.hpp>
7-
#include <SineExtraction.hpp>
2+
#include "util/audiofile.hpp"
3+
#include "algorithms/ConvolutionTools.hpp"
4+
#include "data/FluidTensor.hpp"
5+
#include "HISSTools_FFT/HISSTools_FFT.h"
6+
#include "algorithms/STFT.hpp"
7+
#include "algorithms/SineExtraction.hpp"
88

99
int main(int argc, char *argv[]) {
1010
using std::complex;

examples/test_stft.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "util/audiofile.hpp"
2-
#include <STFT.hpp>
3-
#include <FluidTensor.hpp>
2+
#include "algorithms/STFT.hpp"
3+
#include "data/FluidTensor.hpp"
44

55
int main(int argc, char* argv[])
66
{

examples/test_transient_extractor.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <random>
55
#include <vector>
66

7-
#include "../include/TransientExtraction.hpp"
8-
#include "../3rdparty/HISSTools_AudioFile/IAudioFile.h"
9-
#include "../3rdparty/HISSTools_AudioFile/OAudioFile.h"
7+
#include "algorithms/TransientExtraction.hpp"
8+
#include "HISSTools_AudioFile/IAudioFile.h"
9+
#include "HISSTools_AudioFile/OAudioFile.h"
1010

1111
// ******************* Parameters ******************* //
1212

@@ -48,17 +48,17 @@ bool paramCorruptInput = true;
4848
void corruptInput(double *output, const double *input, int size)
4949
{
5050
// Simple markov chain for probability of switching states
51-
51+
5252
double pOn = paramCorruptInput ? 0.00006 : 0.0;
5353
double pStay = 0.989;
5454
double dev = 0.1;
55-
55+
5656
bool corrupt = false;
5757
unsigned int seed = std::random_device()();
5858
std::mt19937_64 randomGenerator(seed);
5959
std::normal_distribution<double> gaussian(0.0, dev);
6060
std::uniform_real_distribution<double> uniform(0.0, 1.0);
61-
61+
6262
for (int i = 0; i < size; i++)
6363
{
6464
corrupt = uniform(randomGenerator) < (corrupt ? pStay : pOn);
@@ -71,9 +71,9 @@ void corruptInput(double *output, const double *input, int size)
7171
void writeFile(const char *name, const double *output, int size, double samplingRate)
7272
{
7373
using namespace HISSTools;
74-
74+
7575
OAudioFile file(name, BaseAudioFile::kAudioFileWAVE, BaseAudioFile::kAudioFileFloat32, 1, samplingRate);
76-
76+
7777
file.writeChannel(output, size, 0);
7878
}
7979

@@ -82,59 +82,58 @@ void writeFile(const char *name, const double *output, int size, double sampling
8282
int main(int argc, const char * argv[])
8383
{
8484
using fluid::transient_extraction::TransientExtraction;
85-
85+
8686
if (argc < 5)
8787
{
8888
std::cout << "Not enough file paths specified\n";
8989
return -1;
9090
}
91-
91+
9292
const char *inputPath = argv[1];
9393
const char *corruptedOutputPath = argv[2];
9494
const char *fixedOutputPath = argv[3];
9595
const char *transientsOutputPath = argv[4];
96-
96+
9797
HISSTools::IAudioFile file(inputPath);
98-
98+
9999
if (!file.isOpen())
100100
{
101101
std::cout << "File could not be opened\n";
102102
return -2;
103103
}
104-
104+
105105
int frames = file.getFrames();
106106
auto samplingRate = file.getSamplingRate();
107-
107+
108108
std::vector<double> input(frames, 0.0);
109109
std::vector<double> corrupted(frames + paramBlockSize, 0.0);
110110
std::vector<double> fixed(frames + paramBlockSize, 0.0);
111111
std::vector<double> transients(frames + paramBlockSize, 0.0);
112-
112+
113113
file.readChannel(input.data(), frames, 0);
114114
corruptInput(corrupted.data(), input.data(), frames);
115-
115+
116116
TransientExtraction extractor(paramOrder, paramIterations, paramRobustFactor, paramRefine);
117-
117+
118118
extractor.prepareStream(paramBlockSize, paramPad);
119119
extractor.setDetectionParameters(paramDetectPower, paramDetectThreshHi, paramDetectThreshLo, paramDetectHalfWindow, paramDetectHold);
120-
120+
121121
std::cout << "Starting Extraction\n";
122-
122+
123123
for (int i = 0, hopSize = extractor.hopSize(); i < frames; i += hopSize)
124124
{
125125
int size = std::min(extractor.inputSize(), frames - i);
126126
extractor.extract(transients.data() + i, fixed.data() + i, corrupted.data() + i, size);
127127
std::cout << "Done " << (100 * (i + hopSize) / frames) << "%\n";
128128
}
129-
129+
130130
std::cout << "Finished Extraction\n";
131-
131+
132132
// Write files
133-
133+
134134
writeFile(corruptedOutputPath, corrupted.data(), frames, samplingRate);
135135
writeFile(fixedOutputPath, fixed.data(), frames, samplingRate);
136136
writeFile(transientsOutputPath, transients.data(), frames, samplingRate);
137-
137+
138138
return 0;
139139
}
140-

0 commit comments

Comments
 (0)