2024-05-11 22:10:54 +00:00
|
|
|
#pragma once
|
2024-10-23 11:44:31 +00:00
|
|
|
#include "../shape/OsciPoint.h"
|
2024-05-11 22:10:54 +00:00
|
|
|
#include <JuceHeader.h>
|
|
|
|
#include "../shape/Shape.h"
|
|
|
|
#include "../svg/SvgParser.h"
|
|
|
|
#include "../shape/Line.h"
|
2025-04-21 17:05:04 +00:00
|
|
|
#include "../concurrency/ReadProcess.h"
|
2024-05-11 22:10:54 +00:00
|
|
|
|
|
|
|
class OscirenderAudioProcessor;
|
2025-04-21 17:05:04 +00:00
|
|
|
class CommonPluginEditor;
|
|
|
|
|
2024-05-11 22:10:54 +00:00
|
|
|
class ImageParser {
|
|
|
|
public:
|
|
|
|
ImageParser(OscirenderAudioProcessor& p, juce::String fileName, juce::MemoryBlock image);
|
|
|
|
~ImageParser();
|
|
|
|
|
|
|
|
void setFrame(int index);
|
2024-10-23 11:44:31 +00:00
|
|
|
OsciPoint getSample();
|
2024-05-11 22:10:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert);
|
|
|
|
void resetPosition();
|
2024-06-02 16:15:04 +00:00
|
|
|
float getPixelValue(int x, int y, bool invert);
|
2025-04-21 17:05:04 +00:00
|
|
|
int getPixelIndex(int x, int y);
|
2024-06-02 16:15:04 +00:00
|
|
|
void findWhite(double thresholdPow, bool invert);
|
2024-06-01 20:50:56 +00:00
|
|
|
bool isOverThreshold(double pixel, double thresholdValue);
|
2024-05-12 20:12:35 +00:00
|
|
|
int jumpFrequency();
|
2025-02-03 18:30:14 +00:00
|
|
|
void handleError(juce::String message);
|
2025-04-21 17:05:04 +00:00
|
|
|
void processGifFile(juce::File& file);
|
|
|
|
void processImageFile(juce::File& file);
|
|
|
|
void processVideoFile(juce::File& file);
|
|
|
|
bool loadAllVideoFrames(const juce::File& file, const juce::File& ffmpegFile);
|
|
|
|
bool isVideoFile(const juce::String& extension) const;
|
2025-02-08 17:13:54 +00:00
|
|
|
|
|
|
|
const juce::String ALGORITHM = "HILLIGOSS";
|
2024-05-11 22:10:54 +00:00
|
|
|
|
|
|
|
OscirenderAudioProcessor& audioProcessor;
|
|
|
|
juce::Random rng;
|
|
|
|
int frameIndex = 0;
|
|
|
|
std::vector<std::vector<uint8_t>> frames;
|
|
|
|
std::vector<bool> visited;
|
|
|
|
int currentX, currentY;
|
2025-04-21 17:05:04 +00:00
|
|
|
int width = -1;
|
|
|
|
int height = -1;
|
2024-05-11 22:10:54 +00:00
|
|
|
int count = 0;
|
2025-02-08 17:13:54 +00:00
|
|
|
|
2025-04-21 17:05:04 +00:00
|
|
|
// Video processing fields
|
|
|
|
ReadProcess ffmpegProcess;
|
|
|
|
bool isVideo = false;
|
|
|
|
std::unique_ptr<juce::TemporaryFile> temp;
|
|
|
|
std::vector<uint8_t> frameBuffer;
|
|
|
|
int videoFrameSize = 0;
|
|
|
|
|
2025-02-08 17:13:54 +00:00
|
|
|
// experiments
|
|
|
|
double scanX = -1;
|
|
|
|
double scanY = 1;
|
|
|
|
int scanCount = 0;
|
2024-06-01 20:50:56 +00:00
|
|
|
};
|