2024-05-11 22:10:54 +00:00
|
|
|
#pragma once
|
|
|
|
#include <JuceHeader.h>
|
2025-04-29 19:43:26 +00:00
|
|
|
|
2024-05-11 22:10:54 +00:00
|
|
|
#include "../svg/SvgParser.h"
|
|
|
|
|
|
|
|
class OscirenderAudioProcessor;
|
2025-04-21 17:05:04 +00:00
|
|
|
class CommonPluginEditor;
|
|
|
|
|
2024-05-11 22:10:54 +00:00
|
|
|
class ImageParser {
|
|
|
|
public:
|
2025-04-26 19:30:10 +00:00
|
|
|
ImageParser(OscirenderAudioProcessor& p, juce::String fileName, juce::MemoryBlock image);
|
|
|
|
// Constructor for live Syphon/Spout input
|
|
|
|
ImageParser(OscirenderAudioProcessor& p);
|
|
|
|
~ImageParser();
|
2025-04-29 19:43:26 +00:00
|
|
|
|
2025-04-26 19:30:10 +00:00
|
|
|
// Update the live frame (for Syphon/Spout)
|
|
|
|
void updateLiveFrame(const juce::Image& newImage);
|
2024-05-11 22:10:54 +00:00
|
|
|
|
2025-04-29 19:43:26 +00:00
|
|
|
void setFrame(int index);
|
|
|
|
osci::Point getSample();
|
|
|
|
int getNumFrames() { return frames.size(); }
|
|
|
|
int getCurrentFrame() const { return frameIndex; }
|
2024-05-11 22:10:54 +00:00
|
|
|
|
|
|
|
private:
|
2025-04-29 19:43:26 +00:00
|
|
|
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);
|
2025-04-29 19:43:26 +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);
|
2025-04-24 10:29:13 +00:00
|
|
|
#if OSCI_PREMIUM
|
2025-04-21 17:05:04 +00:00
|
|
|
void processVideoFile(juce::File& file);
|
|
|
|
bool loadAllVideoFrames(const juce::File& file, const juce::File& ffmpegFile);
|
|
|
|
bool isVideoFile(const juce::String& extension) const;
|
2025-04-24 10:29:13 +00:00
|
|
|
#endif
|
2025-04-29 19:43:26 +00:00
|
|
|
|
2025-02-08 17:13:54 +00:00
|
|
|
const juce::String ALGORITHM = "HILLIGOSS";
|
2024-05-11 22:10:54 +00:00
|
|
|
|
2025-04-29 19:43:26 +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;
|
2025-04-29 19:43:26 +00:00
|
|
|
int count = 0;
|
|
|
|
|
2025-04-30 19:26:40 +00:00
|
|
|
juce::TemporaryFile temp{".temp"};
|
2025-04-29 19:43:26 +00:00
|
|
|
|
2025-04-24 10:29:13 +00:00
|
|
|
#if OSCI_PREMIUM
|
2025-04-21 17:05:04 +00:00
|
|
|
// Video processing fields
|
2025-04-29 19:43:26 +00:00
|
|
|
juce::ChildProcess ffmpegProcess;
|
2025-04-21 17:05:04 +00:00
|
|
|
bool isVideo = false;
|
|
|
|
std::vector<uint8_t> frameBuffer;
|
|
|
|
int videoFrameSize = 0;
|
2025-04-24 10:29:13 +00:00
|
|
|
#endif
|
2025-04-29 19:43:26 +00:00
|
|
|
|
2025-02-08 17:13:54 +00:00
|
|
|
// experiments
|
|
|
|
double scanX = -1;
|
|
|
|
double scanY = 1;
|
|
|
|
int scanCount = 0;
|
2025-04-26 19:30:10 +00:00
|
|
|
|
|
|
|
// Live image support
|
|
|
|
juce::SpinLock liveImageLock;
|
|
|
|
bool usingLiveImage = false;
|
|
|
|
juce::Image liveImage;
|
2024-06-01 20:50:56 +00:00
|
|
|
};
|