kopia lustrzana https://github.com/jameshball/osci-render
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
rodzic
9b394e2fd1
commit
43819213a7
|
@ -805,8 +805,7 @@ void OscirenderAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
|
||||||
for (int i = 0; i < fileBlocks.size(); i++) {
|
for (int i = 0; i < fileBlocks.size(); i++) {
|
||||||
auto fileXml = filesXml->createNewChildElement("file");
|
auto fileXml = filesXml->createNewChildElement("file");
|
||||||
fileXml->setAttribute("name", fileNames[i]);
|
fileXml->setAttribute("name", fileNames[i]);
|
||||||
auto fileString = juce::MemoryInputStream(*fileBlocks[i], false).readEntireStreamAsString();
|
fileXml->addTextElement(fileBlocks[i]->toBase64Encoding());
|
||||||
fileXml->addTextElement(juce::Base64::toBase64(fileString));
|
|
||||||
}
|
}
|
||||||
xml->setAttribute("currentFile", currentFile);
|
xml->setAttribute("currentFile", currentFile);
|
||||||
|
|
||||||
|
@ -827,6 +826,7 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
|
||||||
|
|
||||||
if (xml.get() != nullptr && xml->hasTagName("project")) {
|
if (xml.get() != nullptr && xml->hasTagName("project")) {
|
||||||
auto versionXml = xml->getChildByName("version");
|
auto versionXml = xml->getChildByName("version");
|
||||||
|
auto version = versionXml != nullptr ? versionXml->getAllSubText() : ProjectInfo::versionString;
|
||||||
if (versionXml != nullptr && versionXml->getAllSubText().startsWith("v1.")) {
|
if (versionXml != nullptr && versionXml->getAllSubText().startsWith("v1.")) {
|
||||||
openLegacyProject(xml.get());
|
openLegacyProject(xml.get());
|
||||||
return;
|
return;
|
||||||
|
@ -905,9 +905,19 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
|
||||||
if (filesXml != nullptr) {
|
if (filesXml != nullptr) {
|
||||||
for (auto fileXml : filesXml->getChildIterator()) {
|
for (auto fileXml : filesXml->getChildIterator()) {
|
||||||
auto fileName = fileXml->getStringAttribute("name");
|
auto fileName = fileXml->getStringAttribute("name");
|
||||||
|
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();
|
auto stream = juce::MemoryOutputStream();
|
||||||
juce::Base64::convertFromBase64(stream, fileXml->getAllSubText());
|
juce::Base64::convertFromBase64(stream, fileXml->getAllSubText());
|
||||||
auto fileBlock = std::make_shared<juce::MemoryBlock>(stream.getData(), stream.getDataSize());
|
fileBlock = std::make_shared<juce::MemoryBlock>(stream.getData(), stream.getDataSize());
|
||||||
|
} else {
|
||||||
|
fileBlock = std::make_shared<juce::MemoryBlock>();
|
||||||
|
fileBlock->fromBase64Encoding(text);
|
||||||
|
}
|
||||||
|
|
||||||
addFile(fileName, fileBlock);
|
addFile(fileName, fileBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,6 +306,22 @@ private:
|
||||||
double valueFromLegacy(double value, const juce::String& id);
|
double valueFromLegacy(double value, const juce::String& id);
|
||||||
void changeSound(ShapeSound::Ptr sound);
|
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;
|
const double MIN_LENGTH_INCREMENT = 0.000001;
|
||||||
|
|
||||||
juce::AudioPlayHead* playHead;
|
juce::AudioPlayHead* playHead;
|
||||||
|
|
|
@ -63,6 +63,10 @@ void ImageParser::resetPosition() {
|
||||||
currentY = rng.nextInt(height);
|
currentY = rng.nextInt(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ImageParser::jumpFrequency() {
|
||||||
|
return audioProcessor.currentSampleRate * 0.005;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert) {
|
void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert) {
|
||||||
int spiralSteps[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
|
int spiralSteps[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
|
||||||
int maxSteps = 2 * searchRadius; // Maximum steps outwards in the spiral
|
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;
|
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;
|
float pixel = frames[frameIndex][index] / maxValue;
|
||||||
if (invert) {
|
if (invert) {
|
||||||
pixel = 1 - pixel;
|
pixel = 1 - pixel;
|
||||||
|
@ -103,7 +107,7 @@ void ImageParser::findNearestNeighbour(int searchRadius, float thresholdPow, int
|
||||||
}
|
}
|
||||||
|
|
||||||
Point ImageParser::getSample() {
|
Point ImageParser::getSample() {
|
||||||
if (count % 100 == 0) {
|
if (count % jumpFrequency() == 0) {
|
||||||
resetPosition();
|
resetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert);
|
void findNearestNeighbour(int searchRadius, float thresholdPow, int stride, bool invert);
|
||||||
void resetPosition();
|
void resetPosition();
|
||||||
|
int jumpFrequency();
|
||||||
|
|
||||||
OscirenderAudioProcessor& audioProcessor;
|
OscirenderAudioProcessor& audioProcessor;
|
||||||
juce::Random rng;
|
juce::Random rng;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginCharacteristicsValue="pluginWantsMidiIn"
|
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginCharacteristicsValue="pluginWantsMidiIn"
|
||||||
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
|
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
|
||||||
cppLanguageStandard="20" projectLineFeed=" " headerPath="./include"
|
cppLanguageStandard="20" projectLineFeed=" " 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'">
|
companyEmail="james@ball.sh" defines="NOMINMAX=1" pluginAUMainType="'aumu'">
|
||||||
<MAINGROUP id="j5Ge2T" name="osci-render">
|
<MAINGROUP id="j5Ge2T" name="osci-render">
|
||||||
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">
|
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">
|
||||||
|
|
Ładowanie…
Reference in New Issue