kopia lustrzana https://github.com/jameshball/osci-render
Fix bug with negative brightness and add test code for alternative video encoder
rodzic
cc20ca8261
commit
d9c9bf0651
|
@ -181,20 +181,52 @@ void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int
|
|||
}
|
||||
|
||||
OsciPoint ImageParser::getSample() {
|
||||
if (count % jumpFrequency() == 0) {
|
||||
resetPosition();
|
||||
if (ALGORITHM == "HILLIGOSS") {
|
||||
if (count % jumpFrequency() == 0) {
|
||||
resetPosition();
|
||||
}
|
||||
|
||||
if (count % 10 * jumpFrequency() == 0) {
|
||||
std::fill(visited.begin(), visited.end(), false);
|
||||
}
|
||||
|
||||
float thresholdPow = audioProcessor.imageThreshold->getActualValue() * 10 + 1;
|
||||
|
||||
findNearestNeighbour(10, thresholdPow, audioProcessor.imageStride->getActualValue(), audioProcessor.invertImage->getValue());
|
||||
float maxDim = juce::jmax(width, height);
|
||||
count++;
|
||||
float widthDiff = (maxDim - width) / 2;
|
||||
float heightDiff = (maxDim - height) / 2;
|
||||
return OsciPoint(2 * (currentX + widthDiff) / maxDim - 1, 2 * (currentY + heightDiff) / maxDim - 1);
|
||||
} else {
|
||||
double scanIncrement = audioProcessor.imageStride->getActualValue() / 100;
|
||||
|
||||
double pixel = 0;
|
||||
int maxIterations = 10000;
|
||||
while (pixel <= audioProcessor.imageThreshold->getActualValue() && maxIterations > 0) {
|
||||
int x = (int) ((scanX + 1) * width / 2);
|
||||
int y = (int) ((scanY + 1) * height / 2);
|
||||
pixel = getPixelValue(x, y, audioProcessor.invertImage->getValue());
|
||||
|
||||
double increment = 0.01;
|
||||
if (pixel > audioProcessor.imageThreshold->getActualValue()) {
|
||||
increment = (1 - tanh(4 * pixel)) * 0.3;
|
||||
}
|
||||
|
||||
scanX += increment;
|
||||
if (scanX >= 1) {
|
||||
scanX = -1;
|
||||
scanY -= audioProcessor.imageStride->getActualValue() / 100;
|
||||
}
|
||||
if (scanY < -1) {
|
||||
double offset = ((scanCount % 15) / 15.0) * scanIncrement;
|
||||
scanY = 1 - offset;
|
||||
scanCount++;
|
||||
}
|
||||
|
||||
maxIterations--;
|
||||
}
|
||||
|
||||
return OsciPoint(scanX, scanY);
|
||||
}
|
||||
|
||||
if (count % 10 * jumpFrequency() == 0) {
|
||||
std::fill(visited.begin(), visited.end(), false);
|
||||
}
|
||||
|
||||
float thresholdPow = audioProcessor.imageThreshold->getActualValue() * 10 + 1;
|
||||
|
||||
findNearestNeighbour(10, thresholdPow, audioProcessor.imageStride->getActualValue(), audioProcessor.invertImage->getValue());
|
||||
float maxDim = juce::jmax(width, height);
|
||||
count++;
|
||||
float widthDiff = (maxDim - width) / 2;
|
||||
float heightDiff = (maxDim - height) / 2;
|
||||
return OsciPoint(2 * (currentX + widthDiff) / maxDim - 1, 2 * (currentY + heightDiff) / maxDim - 1);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ private:
|
|||
bool isOverThreshold(double pixel, double thresholdValue);
|
||||
int jumpFrequency();
|
||||
void handleError(juce::String message);
|
||||
|
||||
const juce::String ALGORITHM = "HILLIGOSS";
|
||||
|
||||
OscirenderAudioProcessor& audioProcessor;
|
||||
juce::Random rng;
|
||||
|
@ -31,4 +33,9 @@ private:
|
|||
int currentX, currentY;
|
||||
int width, height;
|
||||
int count = 0;
|
||||
|
||||
// experiments
|
||||
double scanX = -1;
|
||||
double scanY = 1;
|
||||
int scanCount = 0;
|
||||
};
|
||||
|
|
|
@ -25,8 +25,8 @@ void main () {
|
|||
|
||||
vec2 aStartPos = aStart.xy;
|
||||
vec2 aEndPos = aEnd.xy;
|
||||
float aStartBrightness = aStart.z;
|
||||
float aEndBrightness = aEnd.z;
|
||||
float aStartBrightness = clamp(aStart.z, 0.0, 1.0);
|
||||
float aEndBrightness = clamp(aEnd.z, 0.0, 1.0);
|
||||
|
||||
// `dir` vector is storing the normalized difference
|
||||
// between end and start
|
||||
|
|
Ładowanie…
Reference in New Issue