Fix bugs with parsing GIFs, make it possible to save/load projects with GIFs, STILL HAVEN'T made it so the code documents ignore binary formats

pull/242/head
James Ball 2024-05-12 21:12:35 +01:00 zatwierdzone przez James H Ball
rodzic 9b394e2fd1
commit 43819213a7
5 zmienionych plików z 39 dodań i 8 usunięć

Wyświetl plik

@ -805,8 +805,7 @@ void OscirenderAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
for (int i = 0; i < fileBlocks.size(); i++) {
auto fileXml = filesXml->createNewChildElement("file");
fileXml->setAttribute("name", fileNames[i]);
auto fileString = juce::MemoryInputStream(*fileBlocks[i], false).readEntireStreamAsString();
fileXml->addTextElement(juce::Base64::toBase64(fileString));
fileXml->addTextElement(fileBlocks[i]->toBase64Encoding());
}
xml->setAttribute("currentFile", currentFile);
@ -827,6 +826,7 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
if (xml.get() != nullptr && xml->hasTagName("project")) {
auto versionXml = xml->getChildByName("version");
auto version = versionXml != nullptr ? versionXml->getAllSubText() : ProjectInfo::versionString;
if (versionXml != nullptr && versionXml->getAllSubText().startsWith("v1.")) {
openLegacyProject(xml.get());
return;
@ -905,9 +905,19 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
if (filesXml != nullptr) {
for (auto fileXml : filesXml->getChildIterator()) {
auto fileName = fileXml->getStringAttribute("name");
auto stream = juce::MemoryOutputStream();
juce::Base64::convertFromBase64(stream, fileXml->getAllSubText());
auto fileBlock = std::make_shared<juce::MemoryBlock>(stream.getData(), stream.getDataSize());
auto text = fileXml->getAllSubText();
std::shared_ptr<juce::MemoryBlock> fileBlock;
if (lessThanVersion(version, "2.2.0")) {
// Older versions of osci-render opened files in a silly way
auto stream = juce::MemoryOutputStream();
juce::Base64::convertFromBase64(stream, fileXml->getAllSubText());
fileBlock = std::make_shared<juce::MemoryBlock>(stream.getData(), stream.getDataSize());
} else {
fileBlock = std::make_shared<juce::MemoryBlock>();
fileBlock->fromBase64Encoding(text);
}
addFile(fileName, fileBlock);
}
}

Wyświetl plik

@ -306,6 +306,22 @@ private:
double valueFromLegacy(double value, const juce::String& id);
void changeSound(ShapeSound::Ptr sound);
void parseVersion(int result[4], const juce::String& input) {
std::istringstream parser(input.toStdString());
parser >> result[0];
for (int idx = 1; idx < 4; idx++) {
parser.get(); //Skip period
parser >> result[idx];
}
}
bool lessThanVersion(const juce::String& a, const juce::String& b) {
int parsedA[4], parsedB[4];
parseVersion(parsedA, a);
parseVersion(parsedB, b);
return std::lexicographical_compare(parsedA, parsedA + 4, parsedB, parsedB + 4);
}
const double MIN_LENGTH_INCREMENT = 0.000001;
juce::AudioPlayHead* playHead;

Wyświetl plik

@ -63,6 +63,10 @@ void ImageParser::resetPosition() {
currentY = rng.nextInt(height);
}
int ImageParser::jumpFrequency() {
return audioProcessor.currentSampleRate * 0.005;
}
void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert) {
int spiralSteps[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int maxSteps = 2 * searchRadius; // Maximum steps outwards in the spiral
@ -80,7 +84,7 @@ void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int
if (x < 0 || x >= width || y < 0 || y >= height) break;
int index = (height - y - 1) * height + x;
int index = (height - y - 1) * width + x;
float pixel = frames[frameIndex][index] / maxValue;
if (invert) {
pixel = 1 - pixel;
@ -103,7 +107,7 @@ void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int
}
Point ImageParser::getSample() {
if (count % 100 == 0) {
if (count % jumpFrequency() == 0) {
resetPosition();
}

Wyświetl plik

@ -17,6 +17,7 @@ public:
private:
void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert);
void resetPosition();
int jumpFrequency();
OscirenderAudioProcessor& audioProcessor;
juce::Random rng;

Wyświetl plik

@ -4,7 +4,7 @@
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginCharacteristicsValue="pluginWantsMidiIn"
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
cppLanguageStandard="20" projectLineFeed="&#10;" headerPath="./include"
version="2.1.7" companyName="James H Ball" companyWebsite="https://osci-render.com"
version="2.2.0" companyName="James H Ball" companyWebsite="https://osci-render.com"
companyEmail="james@ball.sh" defines="NOMINMAX=1" pluginAUMainType="'aumu'">
<MAINGROUP id="j5Ge2T" name="osci-render">
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">