-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved some parts of the algorithm from arrays needing lots of data mo…
…ved around to lighted circular buffers
- Loading branch information
Showing
6 changed files
with
129 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// CircularBuffer.cpp | ||
// BTrack Tests | ||
// | ||
// Created by Adam Stark on 04/02/2016. | ||
// Copyright © 2016 Adam Stark. All rights reserved. | ||
// | ||
|
||
#include "CircularBuffer.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// CircularBuffer.hpp | ||
// BTrack Tests | ||
// | ||
// Created by Adam Stark on 04/02/2016. | ||
// Copyright © 2016 Adam Stark. All rights reserved. | ||
// | ||
|
||
#ifndef CircularBuffer_h | ||
#define CircularBuffer_h | ||
|
||
#include <vector> | ||
|
||
class CircularBuffer | ||
{ | ||
public: | ||
CircularBuffer() : writeIndex(0) | ||
{ | ||
|
||
} | ||
|
||
double &operator[](int i) | ||
{ | ||
int index = (i + writeIndex) % buffer.size(); | ||
return buffer[index]; | ||
} | ||
|
||
void addSampleToEnd (double v) | ||
{ | ||
buffer[writeIndex] = v; | ||
writeIndex = (writeIndex + 1) % buffer.size(); | ||
} | ||
|
||
void resize(int size) | ||
{ | ||
buffer.resize(size); | ||
writeIndex = 0; | ||
} | ||
|
||
private: | ||
|
||
std::vector<double> buffer; | ||
int writeIndex; | ||
}; | ||
|
||
#endif /* CircularBuffer_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
#define BOOST_TEST_DYN_LINK | ||
#define BOOST_TEST_MODULE BTrackTests | ||
#include <boost/test/unit_test.hpp> | ||
#include <boost/test/unit_test.hpp> | ||
|
||
//#include "CircularBuffer.h" | ||
//#include <iostream> | ||
// | ||
//int main() | ||
//{ | ||
// CircularBuffer buffer; | ||
// | ||
// buffer.resize(10); | ||
// | ||
// buffer.addSampleToEnd(10); | ||
// buffer.addSampleToEnd(8); | ||
// | ||
// for (int i = 0;i < 10;i++) | ||
// { | ||
// std::cout << buffer[i] << std::endl; | ||
// } | ||
// | ||
// return 0; | ||
//} |