-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff1b62d
commit e132eb6
Showing
5 changed files
with
59 additions
and
1 deletion.
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,28 @@ | ||
#include "DashedLineEffect.h" | ||
|
||
DashedLineEffect::DashedLineEffect() {} | ||
|
||
DashedLineEffect::~DashedLineEffect() {} | ||
|
||
Point DashedLineEffect::apply(int index, Point vector, const std::vector<double>& values, double sampleRate) { | ||
// dash length in seconds | ||
double dashLength = values[0] / 400; | ||
int dashLengthSamples = (int)(dashLength * sampleRate); | ||
dashLengthSamples = juce::jmin(dashLengthSamples, MAX_BUFFER); | ||
|
||
if (dashIndex >= dashLengthSamples) { | ||
dashIndex = 0; | ||
bufferIndex = 0; | ||
} | ||
|
||
buffer[bufferIndex] = vector; | ||
bufferIndex++; | ||
|
||
vector = buffer[dashIndex]; | ||
|
||
if (index % 2 == 0) { | ||
dashIndex++; | ||
} | ||
|
||
return vector; | ||
} |
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,17 @@ | ||
#pragma once | ||
#include "EffectApplication.h" | ||
#include "../shape/Point.h" | ||
|
||
class DashedLineEffect : public EffectApplication { | ||
public: | ||
DashedLineEffect(); | ||
~DashedLineEffect(); | ||
|
||
Point apply(int index, Point input, const std::vector<double>& values, double sampleRate) override; | ||
|
||
private: | ||
const static int MAX_BUFFER = 192000; | ||
std::vector<Point> buffer = std::vector<Point>(MAX_BUFFER); | ||
int dashIndex = 0; | ||
int bufferIndex = 0; | ||
}; |
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